Record Class EnvironmentAttributeMap
java.lang.Object
java.lang.Record
dev.wyck.wrapper.environment.attribute.EnvironmentAttributeMap
@NullMarked
@AsOf("2.1.0")
public record EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, List<EnvironmentAttributeMap.Pending<?>> pending)
extends Record
A collection of EnvironmentAttributes.
- Since:
- 1.1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for creating WrappedEnvironmentAttributeMap instances.static final recordA deferred attribute entry, holding a supplier and its exposed value. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes) EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, List<EnvironmentAttributeMap.Pending<?>> pending) Creates an instance of aEnvironmentAttributeMaprecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the fully resolved attribute map.builder()Creates a new Builder instance.booleanempty()final booleanIndicates whether some other object is "equal to" this one.<V> @Nullable Vget(EnvironmentAttributeSupplier<V> supplier) Returns the value of the given attribute, or null if it is not present.final inthashCode()Returns a hash code value for this object.static <V> EnvironmentAttributeMapof(EnvironmentAttribute<V>... attributes) Creates a new WrappedEnvironmentAttributeMap from the given attributes.pending()Returns the value of thependingrecord component.final StringtoString()Returns a string representation of this record class.values()Returns the wrapped attributes as a collection.with(EnvironmentAttributeSupplier<V> supplier, @Nullable V value) Creates a new WrappedEnvironmentAttributeMap with the given attribute added.with(FriendlyColorSupplier supplier, @Nullable String hex) Creates a new WrappedEnvironmentAttributeMap with the given color attribute added.
-
Field Details
-
EMPTY
-
-
Constructor Details
-
EnvironmentAttributeMap
@AsOf("2.1.0") public EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, List<EnvironmentAttributeMap.Pending<?>> pending) Creates an instance of aEnvironmentAttributeMaprecord class.- Parameters:
attributes- the value for theattributesrecord componentpending- the value for thependingrecord component
-
EnvironmentAttributeMap
-
-
Method Details
-
attributes
Returns the fully resolved attribute map.- Returns:
- the resolved attributes, in an unmodifiable map
- Since:
- 2.1.0
-
values
Returns the wrapped attributes as a collection. Order matches insertion order.- Returns:
- the wrapped attributes
- Since:
- 2.1.0
-
get
Returns the value of the given attribute, or null if it is not present. Pending values take precedence over resolved ones, and the most recently set pending value wins.- Type Parameters:
V- the type of the attribute- Parameters:
supplier- the attribute supplier- Returns:
- the value associated with the supplier, or null if absent
- Since:
- 3.0.0
-
empty
- Returns:
- true if the map is empty, false otherwise.
- Since:
- 1.1.0
-
toBuilder
- Returns:
- a new builder pre-populated with this map's attributes.
- Since:
- 2.1.0
-
with
@AsOf("2.1.0") public <V> EnvironmentAttributeMap with(EnvironmentAttributeSupplier<V> supplier, @Nullable V value) Creates a new WrappedEnvironmentAttributeMap with the given attribute added.- Type Parameters:
V- the type of the attribute- Parameters:
supplier- the attribute suppliervalue- the value to set- Returns:
- a new WrappedEnvironmentAttributeMap with the given attribute added
- Since:
- 2.1.0
-
with
@AsOf("2.1.0") public EnvironmentAttributeMap with(FriendlyColorSupplier supplier, @Nullable String hex) Creates a new WrappedEnvironmentAttributeMap with the given color attribute added.- Parameters:
supplier- the color attribute supplierhex- the hex value (e.g."#FF10F0")- Returns:
- a new WrappedEnvironmentAttributeMap with the given color attribute added
- Since:
- 2.1.0
-
builder
Creates a new Builder instance.- Returns:
- a new Builder instance
- Since:
- 1.1.0
-
of
@SafeVarargs @AsOf("2.1.0") public static <V> EnvironmentAttributeMap of(EnvironmentAttribute<V>... attributes) Creates a new WrappedEnvironmentAttributeMap from the given attributes.- Parameters:
attributes- the attributes to include- Returns:
- a new WrappedEnvironmentAttributeMap
- Since:
- 2.1.0
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
pending
Returns the value of thependingrecord component.- Returns:
- the value of the
pendingrecord component
-