Class BasicTagConfigurationModel
- java.lang.Object
-
- com.inductiveautomation.ignition.common.tags.config.BasicTagConfigurationModel
-
- All Implemented Interfaces:
BoundPropertySet
,Countable
,Extendable<PropertySet>
,Mergable<PropertySet>
,MutablePropertyValueSource
,PropertySet
,PropertyValueSource
,TagConfiguration
,TagConfigurationModel
,java.io.Serializable
,java.lang.Iterable<PropertyValue>
public class BasicTagConfigurationModel extends java.lang.Object implements TagConfigurationModel
This class combines a single tag's configuration (the "local" propertyset) with any inherited configuration. If the tag is not inherited, the parent set will be null. Any changes will be applied to the local set, and then can be sent back to the tag system to save through getEdit(), which returns a TagEdit. TagEdit is just local changes and identifying information.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.ignition.common.config.PropertySet
EMPTY
-
-
Constructor Summary
Constructors Constructor Description BasicTagConfigurationModel(TagConfiguration config, boolean isInherited)
BasicTagConfigurationModel(TagPath path, boolean mutable, boolean inherited, boolean isNew, TagObjectType type)
BasicTagConfigurationModel(TagPath path, BoundPropertySet localConfig, BoundPropertySet parentModel, boolean inherited, boolean isNew, TagObjectType type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(TagConfiguration childModel)
Add a TagEditModel that is beneath this TagEditModel in the hierarchy, such as a child tag in a folder.boolean
contains(Property<?> prop)
void
delete()
<T> T
get(Property<T> prop)
Retrieves the value of the property, or null if this set doesn't contain that property.java.util.Collection<Property<?>>
getBoundProperties()
BoundValue
getBoundValue(Property<?> prop)
java.util.List<TagConfigurationModel>
getChildren()
Returns the models of the children, if the model was retrieved with the option to include children.int
getCount()
PropertySet
getExtension()
This returns an object that represents the value only for the most "local" level.BoundPropertySet
getInheritedConfiguration()
BoundPropertySet
getLocal()
TagConfiguration
getLocalConfiguration()
Returns a tag edit that encompasses the local properties.java.lang.String
getName()
<T> T
getOrDefault(Property<T> prop)
<T> T
getOrElse(Property<T> property, T value)
Get the value for a givenProperty
, or else fall back to value if it's not present.BoundPropertySet
getParent()
<T> T
getParentProperty(Property<T> prop)
TagPath
getPath()
java.util.Collection<Property<?>>
getProperties()
BoundPropertySet
getTagProperties()
Returns just the properties of this tag.TagObjectType
getType()
java.util.List<PropertyValue>
getValues()
Returns the opaque PropertyValue objects.boolean
isBound(Property<?> prop)
boolean
isEditable()
boolean
isExtended(Property<?> prop)
Returns whether this property set contains a value for the prop, and the prop was actually inherited.boolean
isInherited()
boolean
isInherited(Property<?> prop)
In the context of tags, we say that all props are inherited.boolean
isNew()
boolean
isRemoved()
java.util.Iterator<PropertyValue>
iterator()
void
merge(PropertySet other, boolean localDefinitionsOnly)
Merges the values from other collection into this one.static BasicTagConfigurationModel
newTag(TagPath path)
void
remove(Property<?> prop)
<T> void
set(Property<T> prop, T value)
void
set(PropertyValue propValue)
void
setBoundValue(Property<?> prop, BoundValue value)
void
setEditable(boolean value)
void
setLocal(BoundPropertySet value)
void
setName(java.lang.String name)
void
setNew(boolean value)
void
setParent(BoundPropertySet value)
void
setPath(TagPath path)
void
setType(TagObjectType type)
Set the core object type of this node.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.ignition.common.config.BoundPropertySet
extend, getBoundOrDefault, newDefaultInstance, newExtension
-
Methods inherited from interface com.inductiveautomation.ignition.common.config.PropertyValueSource
getNonNull, getNonNull
-
-
-
-
Constructor Detail
-
BasicTagConfigurationModel
public BasicTagConfigurationModel(TagPath path, boolean mutable, boolean inherited, boolean isNew, TagObjectType type)
-
BasicTagConfigurationModel
public BasicTagConfigurationModel(TagPath path, BoundPropertySet localConfig, BoundPropertySet parentModel, boolean inherited, boolean isNew, TagObjectType type)
-
BasicTagConfigurationModel
public BasicTagConfigurationModel(TagConfiguration config, boolean isInherited)
-
-
Method Detail
-
newTag
public static BasicTagConfigurationModel newTag(TagPath path)
-
isNew
public boolean isNew()
- Specified by:
isNew
in interfaceTagConfiguration
-
setNew
public void setNew(boolean value)
- Specified by:
setNew
in interfaceTagConfiguration
-
isRemoved
public boolean isRemoved()
- Specified by:
isRemoved
in interfaceTagConfiguration
-
isInherited
public boolean isInherited()
- Specified by:
isInherited
in interfaceTagConfigurationModel
-
isInherited
public boolean isInherited(Property<?> prop)
In the context of tags, we say that all props are inherited. This isn't true for custom properties, but for all core properties of a tag, they are essentially inherited because we say that any tag could have any property implicitly.- Specified by:
isInherited
in interfacePropertySet
-
isEditable
public boolean isEditable()
- Specified by:
isEditable
in interfaceTagConfigurationModel
-
setEditable
public void setEditable(boolean value)
-
getPath
public TagPath getPath()
- Specified by:
getPath
in interfaceTagConfiguration
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceTagConfiguration
-
setName
public void setName(java.lang.String name)
- Specified by:
setName
in interfaceTagConfiguration
-
getType
public TagObjectType getType()
- Specified by:
getType
in interfaceTagConfiguration
-
setType
public void setType(TagObjectType type)
Set the core object type of this node. Should not be called very often, it would be rare to really change the type.- Specified by:
setType
in interfaceTagConfiguration
-
setPath
public void setPath(TagPath path)
- Specified by:
setPath
in interfaceTagConfiguration
-
getLocalConfiguration
public TagConfiguration getLocalConfiguration()
Returns a tag edit that encompasses the local properties. Does not clone the property set, so changes to the tag edit will continue to affect the TagEditModel.- Specified by:
getLocalConfiguration
in interfaceTagConfigurationModel
-
getInheritedConfiguration
public BoundPropertySet getInheritedConfiguration()
- Specified by:
getInheritedConfiguration
in interfaceTagConfigurationModel
-
getTagProperties
public BoundPropertySet getTagProperties()
Description copied from interface:TagConfiguration
Returns just the properties of this tag.- Specified by:
getTagProperties
in interfaceTagConfiguration
-
delete
public void delete()
-
getChildren
public java.util.List<TagConfigurationModel> getChildren()
Description copied from interface:TagConfigurationModel
Returns the models of the children, if the model was retrieved with the option to include children. Otherwise returns an empty list.- Specified by:
getChildren
in interfaceTagConfiguration
- Specified by:
getChildren
in interfaceTagConfigurationModel
- Returns:
- TagEditModels that are beneath this TagEditModel in the hierarchy, such as child tags in a folder.
-
addChild
public void addChild(TagConfiguration childModel)
Add a TagEditModel that is beneath this TagEditModel in the hierarchy, such as a child tag in a folder.- Specified by:
addChild
in interfaceTagConfiguration
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isBound
public boolean isBound(Property<?> prop)
- Specified by:
isBound
in interfaceBoundPropertySet
-
getLocal
public BoundPropertySet getLocal()
-
getParent
public BoundPropertySet getParent()
-
setBoundValue
public void setBoundValue(Property<?> prop, BoundValue value)
- Specified by:
setBoundValue
in interfaceBoundPropertySet
-
setLocal
public void setLocal(BoundPropertySet value)
-
setParent
public void setParent(BoundPropertySet value)
-
getBoundValue
public BoundValue getBoundValue(Property<?> prop)
- Specified by:
getBoundValue
in interfaceBoundPropertySet
-
getBoundProperties
public java.util.Collection<Property<?>> getBoundProperties()
- Specified by:
getBoundProperties
in interfaceBoundPropertySet
-
get
public <T> T get(Property<T> prop)
Description copied from interface:PropertyValueSource
Retrieves the value of the property, or null if this set doesn't contain that property.- Specified by:
get
in interfacePropertyValueSource
-
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> property, 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:
property
- 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.
-
getParentProperty
public <T> T getParentProperty(Property<T> prop)
-
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
-
remove
public void remove(Property<?> prop)
- Specified by:
remove
in interfaceMutablePropertyValueSource
-
contains
public boolean contains(Property<?> prop)
- Specified by:
contains
in interfacePropertyValueSource
- Returns:
- True if the source contains a value for prop.
-
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 interfaceBoundPropertySet
- Specified by:
getValues
in interfacePropertyValueSource
-
iterator
public java.util.Iterator<PropertyValue> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<PropertyValue>
-
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
-
getExtension
public PropertySet getExtension()
Description copied from interface:Extendable
This returns an object that represents the value only for the most "local" level. That is, this is the difference between the inherited base and the current extension. Complex objects should ensure that trait is true for all aspects of the returned value.- Specified by:
getExtension
in interfaceExtendable<PropertySet>
- Specified by:
getExtension
in interfacePropertySet
-
merge
public void merge(PropertySet other, boolean localDefinitionsOnly)
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
-
-