Class IntersectedPropertySet

java.lang.Object
com.inductiveautomation.ignition.common.config.IntersectedPropertySet
All Implemented Interfaces:
Countable, Extendable<PropertySet>, Mergable<PropertySet>, MutablePropertyValueSource, PropertySet, PropertyValueSource, Serializable, Iterable<PropertyValue>
Direct Known Subclasses:
IntersectedBoundPropertySet, IntersectedTagConfig

public class IntersectedPropertySet extends Object implements PropertySet
Represents an intersection of PropertySets. Modification operations happen on all underlying sets. Functions such as the iterator, contains, and getProperties only apply to properties that intersect cleanly (in other words, are the same across all sets).

The class calculates the intersectable properties on construction, so changes to the underlying PropertySets will not be visible unless refresh() is called. Changes made through this class, however, are tracked, so it won't normally be necessary to call refresh().

See Also:
  • Constructor Details

    • IntersectedPropertySet

      public IntersectedPropertySet(List<? extends PropertySet> propertySets)
  • Method Details

    • refresh

      public void refresh()
      Recalculates the intersection. Should be called when underlying data changes. Modifications to the property sets through this class do not require refresh() to be called, they are tracked separately.
    • internalObjects

      protected List<? extends PropertySet> internalObjects()
    • iterator

      public Iterator<PropertyValue> iterator()
      Specified by:
      iterator in interface Iterable<PropertyValue>
    • get

      public <T> T get(Property<T> prop)
      Returns the intersected value, or null if the values don't match or the property isn't present.
      Specified by:
      get in interface PropertyValueSource
    • contains

      public boolean contains(Property<?> prop)
      Specified by:
      contains in interface PropertyValueSource
      Returns:
      True if the source contains a value for prop.
    • getOrDefault

      public <T> T getOrDefault(Property<T> prop)
      Specified by:
      getOrDefault in interface PropertyValueSource
      Returns:
      The value for prop or Property.getDefaultValue() if not present. Can return null if the value is null.
    • getOrElse

      public <T> T getOrElse(Property<T> prop, T value)
      Description copied from interface: PropertyValueSource
      Get the value for a given Property, or else fall back to value if it's not present.
      Specified by:
      getOrElse in interface PropertyValueSource
      Parameters:
      prop - The Property for which a value is to be retrieved.
      value - The value to default to if property isn't present.
      Returns:
      The value of property if present, value if not. Can return null if the value is null.
    • intersect

      protected <T> T intersect(Property<T> prop, boolean orElse, T elseVal, T fallback)
    • isPropIntersectable

      protected <T> boolean isPropIntersectable(Property<T> prop)
    • modifyPossibleProps

      protected void modifyPossibleProps(Property<?> prop, boolean remove)
    • set

      public <T> void set(Property<T> prop, T value)
      Specified by:
      set in interface MutablePropertyValueSource
    • set

      public void set(PropertyValue propValue)
      Specified by:
      set in interface MutablePropertyValueSource
    • setImpl

      protected void setImpl(PropertyValue propValue)
    • remove

      public void remove(Property<?> prop)
      Specified by:
      remove in interface MutablePropertyValueSource
    • getCount

      public int getCount()
      Specified by:
      getCount in interface Countable
    • getProperties

      public Collection<Property<?>> getProperties()
      Specified by:
      getProperties in interface PropertyValueSource
    • getValues

      public List<PropertyValue> getValues()
      Description copied from interface: PropertyValueSource
      Returns the opaque PropertyValue objects. This can be useful when you want to avoid the strict type checking of the value, and it's important to note that if the property is bound, the value will be a BoundValue. Be very careful about overriding, and make sure to maintain the methodology of using getProperties to iterate and get (or getOrDefault), to get the value, because those are all handled differently by BoundPropertySets, ExtendedPropertySets, etc.
      Specified by:
      getValues in interface PropertyValueSource
    • isExtended

      public boolean isExtended(Property<?> prop)
      Description copied from interface: PropertySet
      Returns whether this property set contains a value for the prop, and the prop was actually inherited. In other words, this is true if the property is inherited, and an override value is present.
      Specified by:
      isExtended in interface PropertySet
    • isInherited

      public boolean isInherited(Property<?> prop)
      Description copied from interface: PropertySet
      Indicates whether the property was inherited from a parent type.
      Specified by:
      isInherited in interface PropertySet
    • merge

      public void merge(PropertySet other, boolean localOnly)
      Description copied from interface: Mergable
      Merges the values from other collection into this one. Replaces any currently existing value with those from the other set.
      Specified by:
      merge in interface Mergable<PropertySet>
      Specified by:
      merge in interface MutablePropertyValueSource
    • getIntersectableProperties

      protected Set<Property<?>> getIntersectableProperties()