@NotThreadSafe public static final class ImmutableAttribute.Builder<O,T> extends Object
ImmutableAttribute.
Initialize attributes and then invoke the build() method to create an
immutable instance.
Builder is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
| Modifier and Type | Method and Description |
|---|---|
ImmutableAttribute<O,T> |
build()
Builds a new
ImmutableAttribute. |
ImmutableAttribute.Builder<O,T> |
from(Attribute<O,T> instance)
Fill a builder with attribute values from the provided
Attribute instance. |
ImmutableAttribute.Builder<O,T> |
getter(Function<O,T> getter)
Initializes the value for the
getter attribute. |
ImmutableAttribute.Builder<O,T> |
name(String name)
Initializes the value for the
name attribute. |
ImmutableAttribute.Builder<O,T> |
objectType(Class<O> objectType)
Initializes the value for the
objectType attribute. |
ImmutableAttribute.Builder<O,T> |
setter(BiConsumer<O,T> setter)
Initializes the value for the
setter attribute. |
@CanIgnoreReturnValue public final ImmutableAttribute.Builder<O,T> from(Attribute<O,T> instance)
Attribute instance.
Regular attribute values will be replaced with those from the given instance.
Absent optional values will not replace present values.instance - The instance from which to copy valuesthis builder for use in a chained invocation@CanIgnoreReturnValue public final ImmutableAttribute.Builder<O,T> objectType(Class<O> objectType)
objectType attribute.objectType - The value for objectTypethis builder for use in a chained invocation@CanIgnoreReturnValue public final ImmutableAttribute.Builder<O,T> name(String name)
name attribute.name - The value for namethis builder for use in a chained invocation@CanIgnoreReturnValue public final ImmutableAttribute.Builder<O,T> getter(Function<O,T> getter)
getter attribute.getter - The value for getterthis builder for use in a chained invocation@CanIgnoreReturnValue public final ImmutableAttribute.Builder<O,T> setter(BiConsumer<O,T> setter)
setter attribute.setter - The value for setterthis builder for use in a chained invocationpublic ImmutableAttribute<O,T> build()
ImmutableAttribute.IllegalStateException - if any required attributes are missingCopyright © 2023. All rights reserved.