Package org.eclipse.ditto.model.things
Interface FeatureDefinitionBuilder
-
- All Superinterfaces:
Iterable<DefinitionIdentifier>
@NotThreadSafe public interface FeatureDefinitionBuilder extends 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 FeatureDefinitionBuilder
add(CharSequence identifier)
Adds the specified Identifier to this builder if it is not already present.<T extends CharSequence>
FeatureDefinitionBuilderaddAll(Iterable<T> identifiers)
Adds all of the Identifiers in the specified Iterable to this builder if they're not already present.FeatureDefinition
build()
Returns an immutable instance ofFeatureDefinition
containing the Identifiers which were provided to this builder so far.DefinitionIdentifier
getFirstIdentifier()
Returns the first Identifier of this builder ornull
if an intermediate state of this builder does not contain any Identifiers - however this should be an utterly exception.int
getSize()
Returns the count of Identifiers of this builder.FeatureDefinitionBuilder
remove(CharSequence identifier)
Removes the specified Identifier from this builder if it is present.<T extends CharSequence>
FeatureDefinitionBuilderremoveAll(Iterable<T> identifiers)
Removes from this builder all of its Identifiers that are contained in the specified Iterable.Stream<DefinitionIdentifier>
stream()
Returns a sequentialStream
with the Identifiers of this builder as its source.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
add
FeatureDefinitionBuilder add(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:
NullPointerException
- ifidentifier
isnull
.DefinitionIdentifierInvalidException
- ifidentifier
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
- ifidentifiers
isnull
.DefinitionIdentifierInvalidException
- if any Identifier ofidentifiers
is invalid.
-
remove
FeatureDefinitionBuilder remove(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:
NullPointerException
- ifidentifier
isnull
.DefinitionIdentifierInvalidException
- ifidentifier
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
- ifidentifiers
isnull
.DefinitionIdentifierInvalidException
- if any Identifier ofidentifiers
is invalid.
-
getFirstIdentifier
@Nullable DefinitionIdentifier getFirstIdentifier()
Returns the first Identifier of this builder ornull
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
Stream<DefinitionIdentifier> stream()
Returns a sequentialStream
with 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 ofFeatureDefinition
containing the Identifiers which were provided to this builder so far.- Returns:
- the instance.
- Throws:
IndexOutOfBoundsException
- if this builder did not contain any Identifiers.
-
-