Commit 753c635e authored by Adam Gausmann's avatar Adam Gausmann

addConnection now returns the created connection

parent 002c2932
Pipeline #5059001 passed with stages
in 15 seconds
......@@ -15,9 +15,9 @@ public interface ConnectionManager {
Connection getConnection(String name);
void addConnection(ConnectionBuilder builder);
Connection addConnection(ConnectionBuilder builder);
void addConnection(String name, ConnectionBuilder builder);
Connection addConnection(String name, ConnectionBuilder builder);
default void removeConnection(Connection connection) {
removeConnection(connection.getName());
......
......@@ -44,21 +44,25 @@ public class ConnectionManagerImpl implements ConnectionManager {
}
@Override
public void addConnection(ConnectionBuilder builder) {
public Connection addConnection(ConnectionBuilder builder) {
builder.username(System.getProperty("user.name"));
builder.realname("Samurai IRC Bot");
ConnectionImpl connection = new ConnectionImpl(bot, builder.build());
connections.put(connection.getName(), connection);
return connection;
}
@Override
public void addConnection(String name, ConnectionBuilder builder) {
public Connection addConnection(String name, ConnectionBuilder builder) {
builder.username(System.getProperty("user.name"));
builder.realname("Samurai IRC Bot");
connections.put(name, new ConnectionImpl(bot, name, builder.build()));
ConnectionImpl connection = new ConnectionImpl(bot, name, builder.build());
connections.put(name, connection);
return connection;
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment