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 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 set
      value - 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 set
      value - the value to set
    • removeProperty

      public void removeProperty​(@NotNull @NotNull ArrowProperty property)
      Remove a property and its value.
      Parameters:
      property - the property to remove
    • hasProperty

      public boolean hasProperty​(@NotNull @NotNull ArrowProperty property)
      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 get
      defaultValue - the default value to return if not explicitly set
      Returns:
      the property's value
    • getProperty

      @NotNull public @NotNull ArrowPropertyValue getProperty​(@NotNull @NotNull ArrowProperty property)
      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

      @NotNull public @NotNull Set<ArrowProperty> 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.