Class AttributeState

java.lang.Object
com.aquima.interactions.profile.model.AttributeState
All Implemented Interfaces:
IEventChannel, IPropertyContainer, IAttributeValue, Serializable

public class AttributeState extends Object implements IAttributeValue
This class holds the state of a single attribute.
Since:
5.0
Author:
O. Kerpershoek, Friso van der Meer, v.jansen
See Also:
  • Constructor Details

  • Method Details

    • setParentInstance

      protected void setParentInstance(EntityInstance instance)
    • getSupportedEvents

      public int getSupportedEvents()
      Description copied from interface: IEventChannel
      This method returns a bit-mask containing all event types that are supported by this event channel. The bit-mask is a bitwise OR of the diverse event types. To check whether a specific event-listener is supported, you can do the following:
       // This checks if a VALUE listener is supported
       if ((channel.getSupportedEvents() & IEvent.Mask.VALUE) != 0) {
         // VALUE event listeners that are supported
       }
       
      Specified by:
      getSupportedEvents in interface IEventChannel
      Returns:
      Bit-mask containing the event types that are supported by this event channel.
    • addEventListener

      public boolean addEventListener(IEventListener listener)
      Description copied from interface: IEventChannel
      This method will add the passed event listener to the list of listeners.
      Specified by:
      addEventListener in interface IEventChannel
      Parameters:
      listener - The event listener that should be added.
      Returns:
      boolean indicating is the listener was actually added.
    • removeEventListener

      public boolean removeEventListener(IEventListener listener)
      Description copied from interface: IEventChannel
      This method will remove the specified event listener from the list of listeners.
      Specified by:
      removeEventListener in interface IEventChannel
      Parameters:
      listener - The event listener that should be removed.
      Returns:
      boolean indicating if the listener was actually removed.
    • getEventDispatcher

      protected IEventDispatcher getEventDispatcher()
    • getPropertyNames

      public String[] getPropertyNames()
      Description copied from interface: IPropertyContainer
      Returns the names of the properties.
      Specified by:
      getPropertyNames in interface IPropertyContainer
      Returns:
      All available properties.
    • hasProperty

      public boolean hasProperty(String name)
      Description copied from interface: IPropertyContainer
      This method will return a boolean indicating if a property with the specified name is present.
      Specified by:
      hasProperty in interface IPropertyContainer
      Parameters:
      name - The name of the property that should be checked.
      Returns:
      boolean indicating if a property with the specified name is present.
    • getProperty

      public IValue getProperty(String name)
      Description copied from interface: IPropertyContainer
      This method will return the value of the specified property.
      Specified by:
      getProperty in interface IPropertyContainer
      Parameters:
      name - The name of the property whose value is requested.
      Returns:
      The value of the property.
    • setProperty

      public boolean setProperty(String name, IValue propertyValue)
      Description copied from interface: IPropertyContainer
      This method may be used to set the value of a property.
      Specified by:
      setProperty in interface IPropertyContainer
      Parameters:
      name - The name of the property whose value should be set.
      propertyValue - The new value of the property.
      Returns:
      boolean indicating if the set operation was successful.
    • getValueReference

      public ValueReference getValueReference()
      Description copied from interface: IAttributeValue
      This method return an object containing a reference to this attribute value. The method is available to simplify interaction with legacy components using the old profile interface.
      Specified by:
      getValueReference in interface IAttributeValue
      Returns:
      ValueReference object containing various ids needed to locate this specific attribute value.
    • getDataType

      public DataType getDataType()
      Description copied from interface: IAttributeValue
      This method returns the data type of the value.
      Specified by:
      getDataType in interface IAttributeValue
      Returns:
      the data type of the value.
    • getDefinition

      public IAttributeDefinition getDefinition()
      This method caches the attributeDefinition if it is null and returns the cached definition. The cachedAttributeDefinition could be null after deserialization of the AttributeState after it was stored in the session store.
      Specified by:
      getDefinition in interface IAttributeValue
      Returns:
      the cached attribute definition
    • setValue

      protected boolean setValue(IEntityInstance instance, IValue attributeValue)
    • addValue

      protected boolean addValue(IEntityInstance instance, ISingleValue obj)
    • removeValue

      protected boolean removeValue(IEntityInstance instance, ISingleValue obj)
    • clearValue

      protected boolean clearValue(IEntityInstance instance)
    • isAnswered

      public boolean isAnswered()
      Description copied from interface: IAttributeValue
      This method returns a boolean indicating if the attributes has been assigned a value.
      Specified by:
      isAnswered in interface IAttributeValue
      Returns:
      boolean indicating if the attributes has been assigned a value.
    • getSourceType

      public SourceType getSourceType()
      Description copied from interface: IAttributeValue
      This method returns the source type of the value. The source type can be used to identify how the attribute got it's value.
      Specified by:
      getSourceType in interface IAttributeValue
      Returns:
      SourceType identifying the source of the value.
    • isUnknown

      public boolean isUnknown()
      Description copied from interface: IAttributeValue
      This method can be used to determine if the value of the attribute is empty. Note: An empty attribute can still be answered.
      Specified by:
      isUnknown in interface IAttributeValue
      Returns:
      boolean indicating if the value of the attribute is empty.
    • isMultiValue

      public boolean isMultiValue()
      Description copied from interface: IAttributeValue
      This method returns a boolean indicating if the attribute can have multiple values. Use the hasMultipleValues or hasSingleValue to determine if the attribute actually hold multiple values.
      Specified by:
      isMultiValue in interface IAttributeValue
      Returns:
      boolean indicating if the attribute can hold multiple values.
    • hasSingleValue

      public boolean hasSingleValue()
      Description copied from interface: IAttributeValue
      This method returns a boolean indicating if the attribute holds exactly one value.
      Specified by:
      hasSingleValue in interface IAttributeValue
      Returns:
      boolean indicating if the attribute holds exactly one value.
    • hasMultipleValues

      public boolean hasMultipleValues()
      Description copied from interface: IAttributeValue
      This method returns a boolean indicating if this value consists of multiple primitive values. When this value is unknown or only represents a single value, this method will return false.
      Specified by:
      hasMultipleValues in interface IAttributeValue
      Returns:
      boolean indicating if this value contains multiple primitive values.
    • getValue

      public IValue getValue()
      Description copied from interface: IAttributeValue
      This states value, as defined in IEntityInstance.getValue(String).
      Specified by:
      getValue in interface IAttributeValue
      Returns:
      IValue containing the current value of the attribute.
    • getDomain

      public IDomain getDomain()
      Description copied from interface: IAttributeValue
      This method returns the domain (set of values) that is currently valid for the attribute. This domain will hold at most all values from the domain definition, but this domain may also be empty when there is no value valid in the current context. The domain definition for this attribute may be requested through this domain, or by using the getDomain method from the attribute definition. This method may return null for attributes that don't have a domain.
      Specified by:
      getDomain in interface IAttributeValue
      Returns:
      The actual domain for this attribute.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setAttachment

      public void setAttachment(String key, Serializable attachment)
      Description copied from interface: IAttributeValue
      Associates the specified value with the specified key in the attachments map. If the map previously contained a mapping for the key, the old value is replaced. An attachment can be anything as long as it is Serializable
      For a null key, nothing will be set
      Specified by:
      setAttachment in interface IAttributeValue
      Parameters:
      key - the key for which to set the attachment
      attachment - - the Serializable attachment to be stored
    • getAttachment

      public Serializable getAttachment(String key)
      Description copied from interface: IAttributeValue
      Returns the available attachment that this attribute value has and is located at the specified key, otherwise returns null
      Specified by:
      getAttachment in interface IAttributeValue
      Parameters:
      key - the key for with to return the value for
      Returns:
      the Serializable object that is stored at the specified key, if nothing found for the key, null is returned