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 Details

    • DEFAULT_NUMBER_OF_CONNECTIONS

      public static final int DEFAULT_NUMBER_OF_CONNECTIONS
      Default number of connections to expect when initializing the channel.
      See Also:
    • DEFAULT_NUMBER_OF_MESSAGES

      public static final int DEFAULT_NUMBER_OF_MESSAGES
      Default 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

      public final T setNumberOfConnections(int numberOfConnections)
      Sets the default number of connections expected.
      Parameters:
      numberOfConnections - the number of connections to expect
      Returns:
      this builder
    • setNumberOfMessages

      public final T setNumberOfMessages(int numberOfMessages)
      Sets the expected number of distinct message types handled by this channel.
      Parameters:
      numberOfMessages - the number of messages to expect
      Returns:
      this builder
    • setChannel

      protected final void setChannel(BabelChannel channel)
      Sets the constructed channel instance created by this builder.
      Parameters:
      channel - the constructed channel
    • getChannel

      protected final @Nullable BabelChannel getChannel()
      Returns the channel instance created by this builder, or null if 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