Class AttributeStatement


  • public class AttributeStatement
    extends Object
    Attribute statement allows for generating dynamic attributes. Attribute statements are assigned to a group for its members.

    Attribute statement is evaluated using a MVEL context. The context is composed of several fixed variables as identities, groups and regular attributes (in the statements's group) of an entity. Additionally the statement can be configured to add to the context attributes of another group: either child or parent.

    Statement contains a condition. The attribute is assigned only if the condition evaluates to true.

    Statement can assign attribute in two alternative ways: either attribute name is provided and an MVEL expression is used to produce values or a fixed attribute is given. The later variant is quite static but allows for editing assigned attribute with the full power of Unity attribute editors in the UI.

    Author:
    K. Benedyczak
    • Constructor Detail

      • AttributeStatement

        public AttributeStatement​(String condition,
                                  String extraAttributesGroup,
                                  AttributeStatement.ConflictResolution conflictResolution,
                                  Attribute fixedAttribute)
        Creates a statement assigning a fixed attribute
        Parameters:
        condition -
        visibility -
        extraAttributesGroup -
        conflictResolution -
        fixedAttribute -
      • AttributeStatement

        public AttributeStatement​(String condition,
                                  String extraAttributesGroup,
                                  AttributeStatement.ConflictResolution conflictResolution,
                                  String dynamicAttributeType,
                                  String dynamicAttributeExpression)
        Creates a statement assigning a dynamic attribute
        Parameters:
        condition -
        visibility -
        extraAttributesGroup -
        conflictResolution -
        dynamicAttributeType -
        dynamicAttributeExpression -
      • AttributeStatement

        public AttributeStatement()
      • AttributeStatement

        public AttributeStatement​(com.fasterxml.jackson.databind.node.ObjectNode src)
    • Method Detail

      • getFixedEverybodyStatement

        public static AttributeStatement getFixedEverybodyStatement​(Attribute toAssign)
        Creates a simple statement that assigns a given attribute to everybody
        Parameters:
        toAssign -
        Returns:
      • getFixedStatement

        public static AttributeStatement getFixedStatement​(Attribute toAssign,
                                                           String extraGroup,
                                                           String condition)
        Creates a statement with a given condition and assigning a fixed attribute and conflict resolution set to skip.
        Parameters:
        toAssign -
        condition -
        Returns:
      • getCondition

        public String getCondition()
      • getExtraAttributesGroup

        public String getExtraAttributesGroup()
      • setCondition

        public void setCondition​(String condition)
      • setExtraAttributesGroup

        public void setExtraAttributesGroup​(String extraAttributesGroup)
      • getFixedAttribute

        public Attribute getFixedAttribute()
      • setFixedAttribute

        public void setFixedAttribute​(Attribute fixedAttribute)
      • getDynamicAttributeType

        public String getDynamicAttributeType()
      • setDynamicAttributeType

        public void setDynamicAttributeType​(String dynamicAttributeType)
      • getDynamicAttributeExpression

        public String getDynamicAttributeExpression()
      • setDynamicAttributeExpression

        public void setDynamicAttributeExpression​(String dynamicAttributeExpression)
      • dynamicAttributeMode

        public boolean dynamicAttributeMode()
      • isSuitableForDirectedEvaluation

        public boolean isSuitableForDirectedEvaluation​(AttributeStatement.Direction direction,
                                                       String groupOfStatement)
        Checks if the statement can be evaluated in course of recursive evaluation of statements, without procuring (infinite) cycles.

        This is done as follows: statement can be always evaluated if it doen't depend on attributes in other groups. If it does it is checked whether a dependency group is in the provided direction of the current evaluation.

        Parameters:
        direction -
        groupOfStatement -
        Returns:
      • getAssignedAttributeName

        public String getAssignedAttributeName()
        Name of the assigned attribute, regardless whether values are fixed or dynamic.
        Returns:
      • getCompiledCondition

        public Serializable getCompiledCondition()
      • getCompiledDynamicAttributeExpression

        public Serializable getCompiledDynamicAttributeExpression()
      • toJson

        public com.fasterxml.jackson.databind.node.ObjectNode toJson()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object