Package org.eclipse.ditto.things.model
Interface FeatureDefinitionBuilder
-
- All Superinterfaces:
java.lang.Iterable<DefinitionIdentifier>
@NotThreadSafe public interface FeatureDefinitionBuilder extends java.lang.Iterable<DefinitionIdentifier>
A mutable builder with a fluent API for an immutableFeatureDefinition.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FeatureDefinitionBuilderadd(java.lang.CharSequence identifier)Adds the specified Identifier to this builder if it is not already present.<T extends java.lang.CharSequence>
FeatureDefinitionBuilderaddAll(java.lang.Iterable<T> identifiers)Adds all of the Identifiers in the specified Iterable to this builder if they're not already present.FeatureDefinitionbuild()Returns an immutable instance ofFeatureDefinitioncontaining the Identifiers which were provided to this builder so far.DefinitionIdentifiergetFirstIdentifier()Returns the first Identifier of this builder ornullif an intermediate state of this builder does not contain any Identifiers - however this should be an utterly exception.intgetSize()Returns the count of Identifiers of this builder.FeatureDefinitionBuilderremove(java.lang.CharSequence identifier)Removes the specified Identifier from this builder if it is present.<T extends java.lang.CharSequence>
FeatureDefinitionBuilderremoveAll(java.lang.Iterable<T> identifiers)Removes from this builder all of its Identifiers that are contained in the specified Iterable.java.util.stream.Stream<DefinitionIdentifier>stream()Returns a sequentialStreamwith the Identifiers of this builder as its source.
-
-
-
Method Detail
-
add
FeatureDefinitionBuilder add(java.lang.CharSequence identifier)
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:
java.lang.NullPointerException- ifidentifierisnull.DefinitionIdentifierInvalidException- ifidentifieris invalid.
-
addAll
<T extends java.lang.CharSequence> FeatureDefinitionBuilder addAll(java.lang.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:
java.lang.NullPointerException- ifidentifiersisnull.DefinitionIdentifierInvalidException- if any Identifier ofidentifiersis invalid.
-
remove
FeatureDefinitionBuilder remove(java.lang.CharSequence identifier)
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:
java.lang.NullPointerException- ifidentifierisnull.DefinitionIdentifierInvalidException- ifidentifieris invalid.
-
removeAll
<T extends java.lang.CharSequence> FeatureDefinitionBuilder removeAll(java.lang.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:
java.lang.NullPointerException- ifidentifiersisnull.DefinitionIdentifierInvalidException- if any Identifier ofidentifiersis invalid.
-
getFirstIdentifier
@Nullable DefinitionIdentifier getFirstIdentifier()
Returns the first Identifier of this builder ornullif 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
java.util.stream.Stream<DefinitionIdentifier> stream()
Returns a sequentialStreamwith the Identifiers of this builder as its source.- Returns:
- a sequential stream of the Identifiers of this builder.
-
build
FeatureDefinition build()
Returns an immutable instance ofFeatureDefinitioncontaining the Identifiers which were provided to this builder so far.- Returns:
- the instance.
- Throws:
java.lang.IndexOutOfBoundsException- if this builder did not contain any Identifiers.
-
-