Package org.eclipse.ditto.things.model
Interface FeatureDefinitionBuilder
- All Superinterfaces:
Iterable<DefinitionIdentifier>
A mutable builder with a fluent API for an immutable
FeatureDefinition.-
Method Summary
Modifier and TypeMethodDescriptionadd(CharSequence identifier) Adds the specified Identifier to this builder if it is not already present.<T extends CharSequence>
FeatureDefinitionBuilderAdds all of the Identifiers in the specified Iterable to this builder if they're not already present.build()Returns an immutable instance ofFeatureDefinitioncontaining the Identifiers which were provided to this builder so far.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.remove(CharSequence identifier) Removes the specified Identifier from this builder if it is present.<T extends CharSequence>
FeatureDefinitionBuilderRemoves from this builder all of its Identifiers that are contained in the specified Iterable.stream()Returns a sequentialStreamwith the Identifiers of this builder as its source.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
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- ifidentifierisnull.DefinitionIdentifierInvalidException- ifidentifieris invalid.
-
addAll
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- ifidentifiersisnull.DefinitionIdentifierInvalidException- if any Identifier ofidentifiersis 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- ifidentifierisnull.DefinitionIdentifierInvalidException- ifidentifieris invalid.
-
removeAll
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- ifidentifiersisnull.DefinitionIdentifierInvalidException- if any Identifier ofidentifiersis invalid.
-
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
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:
IndexOutOfBoundsException- if this builder did not contain any Identifiers.
-