Interface FeatureDefinitionBuilder

All Superinterfaces:
Iterable<DefinitionIdentifier>

@NotThreadSafe public interface FeatureDefinitionBuilder extends Iterable<DefinitionIdentifier>
A mutable builder with a fluent API for an immutable FeatureDefinition.
  • Method Details

    • add

      Adds the specified Identifier to this builder if it is not already present.
      Parameters:
      identifier - the Identifier to be added.
      Returns:
      this builder instance to allow method chaining.
      Throws:
      NullPointerException - if identifier is null.
      DefinitionIdentifierInvalidException - if identifier is invalid.
    • addAll

      <T extends CharSequence> FeatureDefinitionBuilder addAll(Iterable<T> identifiers)
      Adds all of the Identifiers in the specified Iterable to this builder if they're not already present.
      Parameters:
      identifiers - the Identifiers to be added.
      Returns:
      this builder instance to allow method chaining.
      Throws:
      NullPointerException - if identifiers is null.
      DefinitionIdentifierInvalidException - if any Identifier of identifiers is invalid.
    • remove

      Removes the specified Identifier from this builder if it is present.
      Parameters:
      identifier - the Identifier to be removed.
      Returns:
      this builder instance to allow method chaining.
      Throws:
      NullPointerException - if identifier is null.
      DefinitionIdentifierInvalidException - if identifier is invalid.
    • removeAll

      <T extends CharSequence> FeatureDefinitionBuilder removeAll(Iterable<T> identifiers)
      Removes from this builder all of its Identifiers that are contained in the specified Iterable.
      Parameters:
      identifiers - the Identifiers to be removed.
      Returns:
      this builder instance to allow method chaining.
      Throws:
      NullPointerException - if identifiers is null.
      DefinitionIdentifierInvalidException - if any Identifier of identifiers is invalid.
    • getFirstIdentifier

      @Nullable DefinitionIdentifier getFirstIdentifier()
      Returns the first Identifier of this builder or null if an intermediate state of this builder does not contain any Identifiers - however this should be an utterly exception.
      Returns:
      the Identifier or null.
    • getSize

      int getSize()
      Returns the count of Identifiers of this builder. The size is guaranteed to be at least one.
      Returns:
      the size.
    • stream

      Returns a sequential Stream with the Identifiers of this builder as its source.
      Returns:
      a sequential stream of the Identifiers of this builder.
    • build

      Returns an immutable instance of FeatureDefinition containing the Identifiers which were provided to this builder so far.
      Returns:
      the instance.
      Throws:
      IndexOutOfBoundsException - if this builder did not contain any Identifiers.