Class AbstractBabelChannelBuilder<T extends BabelChannelBuilder>
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.AbstractBabelChannelBuilder<T>
- Type Parameters:
T- the concrete builder subtype for fluent method chaining
- All Implemented Interfaces:
BabelChannelBuilder
- Direct Known Subclasses:
AbstractIPBabelChannelBuilder, InternalBabelChannelBuilder
public abstract class AbstractBabelChannelBuilder<T extends BabelChannelBuilder>
extends Object
implements BabelChannelBuilder
Abstract base class for
BabelChannelBuilder implementations.
It provides basic management for the number of connections and the set of interested messages.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of connections to expect when initializing the channel.static final intDefault number of message types expected by this channel. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitializes the base channel builder with default connection and message counts. -
Method Summary
Modifier and TypeMethodDescriptionprotected final @Nullable BabelChannelReturns the channel instance created by this builder, ornullif not yet built.protected final intGets the expected number of connections set in this builder.protected final intGets the expected number of messages set in this builder.protected final voidsetChannel(BabelChannel channel) Sets the constructed channel instance created by this builder.final TsetNumberOfConnections(int numberOfConnections) Sets the default number of connections expected.final TsetNumberOfMessages(int numberOfMessages) Sets the expected number of distinct message types handled by this channel.protected final voidValidates that this builder has not yet built its channel instance.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelChannelBuilder
buildModifier and TypeMethodDescriptionbuild(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol) Creates a newBabelChannelinstance, registering it with the givenruntimeand limiting its interest to the provided message types.
-
Field Details
-
DEFAULT_NUMBER_OF_CONNECTIONS
public static final int DEFAULT_NUMBER_OF_CONNECTIONSDefault number of connections to expect when initializing the channel.- See Also:
-
DEFAULT_NUMBER_OF_MESSAGES
public static final int DEFAULT_NUMBER_OF_MESSAGESDefault number of message types expected by this channel.- See Also:
-
-
Constructor Details
-
AbstractBabelChannelBuilder
protected AbstractBabelChannelBuilder()Initializes the base channel builder with default connection and message counts.
-
-
Method Details
-
validateStateOrThrow
protected final void validateStateOrThrow()Validates that this builder has not yet built its channel instance.- Throws:
IllegalStateException- if this builder has already created a channel
-
setNumberOfConnections
Sets the default number of connections expected.- Parameters:
numberOfConnections- the number of connections to expect- Returns:
- this builder
-
setNumberOfMessages
Sets the expected number of distinct message types handled by this channel.- Parameters:
numberOfMessages- the number of messages to expect- Returns:
- this builder
-
setChannel
Sets the constructed channel instance created by this builder.- Parameters:
channel- the constructed channel
-
getChannel
Returns the channel instance created by this builder, ornullif not yet built.- Returns:
- the created channel or
null
-
getNumberOfConnections
protected final int getNumberOfConnections()Gets the expected number of connections set in this builder.- Returns:
- the expected number of connections
-
getNumberOfMessages
protected final int getNumberOfMessages()Gets the expected number of messages set in this builder.- Returns:
- the expected number of messages
-