Package wtf.choco.arrows.api.property
Class PropertyMap
java.lang.Object
wtf.choco.arrows.api.property.PropertyMap
public final class PropertyMap extends Object
A map backed by a HashMap to associate a property to its set value. If no value has been
explicitly set for a property, its default value will be returned.
- Author:
- Parker Hawke - Choco
-
Constructor Summary
Constructors Constructor Description PropertyMap()
-
Method Summary
Modifier and Type Method Description void
clearProperties()
Clear all properties and their values from the map.@NotNull Set<ArrowProperty>
getProperties()
Get an immutable set of all properties that have been explicitly set.@NotNull ArrowPropertyValue
getProperty(@NotNull ArrowProperty property)
Get the value of the specified property.@NotNull ArrowPropertyValue
getProperty(@NotNull ArrowProperty property, @Nullable Object defaultValue)
Get the value of the specified property.boolean
hasProperty(@NotNull ArrowProperty property)
Check whether the specified property has been explicitly set or not.void
removeProperty(@NotNull ArrowProperty property)
Remove a property and its value.void
setProperty(@NotNull ArrowProperty property, @NotNull Supplier<Object> value)
Set a property's value that is to be recomputed every time it is fetched.void
setProperty(@NotNull ArrowProperty property, @Nullable Object value)
Set a property's value.
-
Constructor Details
-
PropertyMap
public PropertyMap()
-
-
Method Details
-
setProperty
public void setProperty(@NotNull @NotNull ArrowProperty property, @NotNull @NotNull Supplier<Object> value)Set a property's value that is to be recomputed every time it is fetched.- Parameters:
property
- the property whose value to setvalue
- the value to set
-
setProperty
public void setProperty(@NotNull @NotNull ArrowProperty property, @Nullable @Nullable Object value)Set a property's value.- Parameters:
property
- the property whose value to setvalue
- the value to set
-
removeProperty
Remove a property and its value.- Parameters:
property
- the property to remove
-
hasProperty
Check whether the specified property has been explicitly set or not.- Parameters:
property
- the property to check- Returns:
- true if set, false otherwise
-
getProperty
@NotNull public @NotNull ArrowPropertyValue getProperty(@NotNull @NotNull ArrowProperty property, @Nullable @Nullable Object defaultValue)Get the value of the specified property. If the property has not yet been set explicitly, the specified default value will instead be returned.- Parameters:
property
- the property whose value to getdefaultValue
- the default value to return if not explicitly set- Returns:
- the property's value
-
getProperty
Get the value of the specified property. If the property has not yet been set explicitly, the property's default value will be returned instead.- Parameters:
property
- the property whose value to get- Returns:
- the property's value
-
getProperties
Get an immutable set of all properties that have been explicitly set.- Returns:
- all set properties
-
clearProperties
public void clearProperties()Clear all properties and their values from the map.
-