Class IntersectedPropertySet
- java.lang.Object
-
- com.inductiveautomation.ignition.common.config.IntersectedPropertySet
-
- All Implemented Interfaces:
Countable
,Extendable<PropertySet>
,Mergable<PropertySet>
,MutablePropertyValueSource
,PropertySet
,PropertyValueSource
,java.io.Serializable
,java.lang.Iterable<PropertyValue>
- Direct Known Subclasses:
IntersectedBoundPropertySet
,IntersectedTagConfig
public class IntersectedPropertySet extends java.lang.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 callrefresh()
.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.ignition.common.config.PropertySet
EMPTY
-
-
Constructor Summary
Constructors Constructor Description IntersectedPropertySet(java.util.List<? extends PropertySet> propertySets)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Property<?> prop)
<T> T
get(Property<T> prop)
Returns the intersected value, or null if the values don't match or the property isn't present.int
getCount()
protected java.util.Set<Property<?>>
getIntersectableProperties()
<T> T
getOrDefault(Property<T> prop)
<T> T
getOrElse(Property<T> prop, T value)
Get the value for a givenProperty
, or else fall back to value if it's not present.java.util.Collection<Property<?>>
getProperties()
java.util.List<PropertyValue>
getValues()
Returns the opaque PropertyValue objects.protected java.util.List<? extends PropertySet>
internalObjects()
protected <T> T
intersect(Property<T> prop, boolean orElse, T elseVal, T fallback)
boolean
isExtended(Property<?> prop)
Returns whether this property set contains a value for the prop, and the prop was actually inherited.boolean
isInherited(Property<?> prop)
Indicates whether the property was inherited from a parent type.protected <T> boolean
isPropIntersectable(Property<T> prop)
java.util.Iterator<PropertyValue>
iterator()
void
merge(PropertySet other, boolean localOnly)
Merges the values from other collection into this one.protected void
modifyPossibleProps(Property<?> prop, boolean remove)
void
refresh()
Recalculates the intersection.void
remove(Property<?> prop)
<T> void
set(Property<T> prop, T value)
void
set(PropertyValue propValue)
protected void
setImpl(PropertyValue propValue)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.ignition.common.config.PropertySet
extend, getExtension, newDefaultInstance, newExtension
-
Methods inherited from interface com.inductiveautomation.ignition.common.config.PropertyValueSource
getNonNull, getNonNull
-
-
-
-
Constructor Detail
-
IntersectedPropertySet
public IntersectedPropertySet(java.util.List<? extends PropertySet> propertySets)
-
-
Method Detail
-
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 java.util.List<? extends PropertySet> internalObjects()
-
iterator
public java.util.Iterator<PropertyValue> iterator()
- Specified by:
iterator
in interfacejava.lang.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 interfacePropertyValueSource
-
contains
public boolean contains(Property<?> prop)
- Specified by:
contains
in interfacePropertyValueSource
- Returns:
- True if the source contains a value for prop.
-
getOrDefault
public <T> T getOrDefault(Property<T> prop)
- Specified by:
getOrDefault
in interfacePropertyValueSource
- 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 givenProperty
, or else fall back to value if it's not present.- Specified by:
getOrElse
in interfacePropertyValueSource
- Parameters:
prop
- TheProperty
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 interfaceMutablePropertyValueSource
-
set
public void set(PropertyValue propValue)
- Specified by:
set
in interfaceMutablePropertyValueSource
-
setImpl
protected void setImpl(PropertyValue propValue)
-
remove
public void remove(Property<?> prop)
- Specified by:
remove
in interfaceMutablePropertyValueSource
-
getProperties
public java.util.Collection<Property<?>> getProperties()
- Specified by:
getProperties
in interfacePropertyValueSource
-
getValues
public java.util.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 interfacePropertyValueSource
-
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 interfacePropertySet
-
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 interfacePropertySet
-
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 interfaceMergable<PropertySet>
- Specified by:
merge
in interfaceMutablePropertyValueSource
-
getIntersectableProperties
protected java.util.Set<Property<?>> getIntersectableProperties()
-
-