@NotThreadSafe public static final class ImmutableAttributeMap.Builder extends Object
Builder pattern for the ImmutableAttributeMap
class.
Effective Java, 2nd Ed. : Item 2: Builder Pattern.
This Builder is not thread-safe but is thread-compliant, it is supposed to be used by only one thread.
Constructor and Description |
---|
Builder() |
Builder(ImmutableAttributeMap.Builder copy) |
Builder(ImmutableAttributeMap copy) |
Builder(Map<AttributeDefinition<?>,? extends Iterable<? extends AttributeValue<?>>> copy) |
Modifier and Type | Method and Description |
---|---|
ImmutableAttributeMap |
build()
Builds the
ImmutableAttributeMap instance. |
<T> ImmutableAttributeMap.Builder |
put(AttributeDefinition<T> attribute) |
<T> ImmutableAttributeMap.Builder |
put(AttributeDefinition<T> attribute,
AttributeValue<T>... values) |
<T> ImmutableAttributeMap.Builder |
put(AttributeDefinition<T> attribute,
Iterable<? extends AttributeValue<T>> values) |
<T> ImmutableAttributeMap.Builder |
put(AttributeDefinition<T> attribute,
String primaryValue)
Puts a value marshalled as a
String which is first unmarshalled and then put into the map. |
ImmutableAttributeMap.Builder |
putAll(Collection<AttributeDefinition<?>> attributeDefinitions)
put all a collection of attributeDefinitions without values
|
ImmutableAttributeMap.Builder |
putAll(ImmutableAttributeMap attributeMap) |
ImmutableAttributeMap.Builder |
putAll(Map<AttributeDefinition<?>,? extends Iterable<? extends AttributeValue<?>>> attributeMap) |
<T> ImmutableAttributeMap.Builder |
putPrimaryValues(AttributeDefinition<T> attribute,
Iterable<String> primaryValues)
Puts values marshalled as
String s which are first unmarshalled and then put into the map. |
<T> ImmutableAttributeMap.Builder |
putPrimaryValues(AttributeDefinition<T> attribute,
String... primaryValues)
Puts values marshalled as
String s which are first unmarshalled and then put into the map. |
public Builder()
public Builder(@Nonnull ImmutableAttributeMap.Builder copy)
public Builder(@Nonnull ImmutableAttributeMap copy)
public Builder(@Nonnull Map<AttributeDefinition<?>,? extends Iterable<? extends AttributeValue<?>>> copy)
@Nonnull public ImmutableAttributeMap build()
ImmutableAttributeMap
instance.
This method first calls the validation logic which iterates over all entries put in the Map and detects
missing transliterations for attribute definitions which are defined as transliterationMandatory ==
true
. When a missing transliteration is detected, an IllegalArgumentException is thrown
ImmutableAttributeMap
instance.IllegalArgumentException
- when the state of the builder is not consistent, for example when a
mandatory transliteration is missing.@Nonnull public <T> ImmutableAttributeMap.Builder put(@Nonnull AttributeDefinition<T> attribute)
@Nonnull public <T> ImmutableAttributeMap.Builder put(@Nonnull AttributeDefinition<T> attribute, @Nonnull Iterable<? extends AttributeValue<T>> values)
@Nonnull public <T> ImmutableAttributeMap.Builder put(@Nonnull AttributeDefinition<T> attribute, @Nonnull AttributeValue<T>... values)
@Nonnull public <T> ImmutableAttributeMap.Builder put(@Nonnull AttributeDefinition<T> attribute, @Nonnull String primaryValue)
String
which is first unmarshalled and then put into the map.
Important note: this method automatically transliterates any given value which is not in Latin
Script for attribute definitions which have the AttributeDefinition.isTransliterationMandatory()
flag
set to true
.
T
- the type of this Builder.attribute
- the definitionprimaryValue
- a value marshalled as a String
which is to be unmarshalled first using the attribute-value marshaller
.putPrimaryValues(AttributeDefinition, String...)
@Nonnull public ImmutableAttributeMap.Builder putAll(@Nonnull Collection<AttributeDefinition<?>> attributeDefinitions)
attributeDefinitions
- the collection of attributeDefinitions@Nonnull public ImmutableAttributeMap.Builder putAll(@Nonnull Map<AttributeDefinition<?>,? extends Iterable<? extends AttributeValue<?>>> attributeMap)
@Nonnull public ImmutableAttributeMap.Builder putAll(@Nonnull ImmutableAttributeMap attributeMap)
@Nonnull public <T> ImmutableAttributeMap.Builder putPrimaryValues(@Nonnull AttributeDefinition<T> attribute, @Nonnull Iterable<String> primaryValues)
String
s which are first unmarshalled and then put into the map.
Important note: this method automatically transliterates values which are not in Latin Script for
attribute definitions which have the AttributeDefinition.isTransliterationMandatory()
flag set to
true
.
T
- the type of this Builder.attribute
- the definitionprimaryValues
- values marshalled as String
s which are to be unmarshalled first using the attribute-value marshaller
.@Nonnull public <T> ImmutableAttributeMap.Builder putPrimaryValues(@Nonnull AttributeDefinition<T> attribute, @Nonnull String... primaryValues)
String
s which are first unmarshalled and then put into the map.
Important note: this method automatically transliterates values which are not in Latin Script for
attribute definitions which have the AttributeDefinition.isTransliterationMandatory()
flag set to
true
.
T
- the type of this Builder.attribute
- the definitionprimaryValues
- values marshalled as String
s which are to be unmarshalled first using the AttributeDefinition.getAttributeValueMarshaller()
attribute-value marshaller}.Copyright © 2020. All Rights Reserved.