Class 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 Detail

      • PropertyMap

        public PropertyMap()
    • Method Detail

      • setProperty

        public <T> void setProperty​(@NotNull
                                    @NotNull ArrowProperty<T> property,
                                    @NotNull
                                    T value)
        Set a property's value.
        Type Parameters:
        T - the arrow property value type
        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
      • getPropertyValue

        @NotNull
        public <T> T getPropertyValue​(@NotNull
                                      @NotNull ArrowProperty<T> property,
                                      @NotNull
                                      T 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.
        Type Parameters:
        T - the arrow property value type
        Parameters:
        property - the property whose value to get
        defaultValue - the default value to return if not explicitly set
        Returns:
        the property's value
      • getPropertyValue

        @NotNull
        public <T> T getPropertyValue​(@NotNull
                                      @NotNull ArrowProperty<T> 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.
        Type Parameters:
        T - the arrow property value type
        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.