Class CompoundValue

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class CompoundValue
    extends StructuredValue
    implements java.lang.Cloneable
    CompoundValue class.
    Author:
    Marcel Lueder, El-Sharkawy, Holger Eichelberger
    • Field Detail

      • SPECIAL_SLOT_NAME_TYPE

        public static final java.lang.String SPECIAL_SLOT_NAME_TYPE
        Denotes an internal compound slot name during initialization which specifies the actual type of the compound (in case of container initializations defined on a refined compound).
        See Also:
        Constant Field Values
      • nestedElements

        private java.util.HashMap<java.lang.String,​Value> nestedElements
    • Constructor Detail

      • CompoundValue

        CompoundValue()
        Constructor for serialization.
      • CompoundValue

        CompoundValue​(Compound compound,
                      java.lang.Object... value)
               throws ValueDoesNotMatchTypeException
        Constructor for a new CompoundValue.
        Parameters:
        compound - compound which extends this CompoundValue
        value - initial value(s), two entries for each compound given as name and value
        Throws:
        ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
      • CompoundValue

        protected CompoundValue​(Compound compound,
                                CompoundValue source)
        Creates a new compound value by copying the values from source.
        Parameters:
        compound - the compound type
        source - the value which acts as a source for data
    • Method Detail

      • initializeAttributeAssignment

        private void initializeAttributeAssignment​(AttributeAssignment assng,
                                                   java.util.Map<java.lang.String,​java.lang.Object> initialValues)
                                            throws ValueDoesNotMatchTypeException
        Initializes an attribute assignment.
        Parameters:
        assng - the assignment to initialize
        initialValues - the initial values
        Throws:
        ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
      • getActualType

        public static final IDatatype getActualType​(java.lang.Object[] slotValues)
        Returns the actual type if stored as SPECIAL_SLOT_NAME_TYPE parameter in the given array.
        Parameters:
        slotValues - the slot values, may be null
        Returns:
        the actual type or null
      • getNestedValue

        public Value getNestedValue​(java.lang.String name)
        Returns the value for the variable with the given name.
        Parameters:
        name - the name of the variable.
        Returns:
        the value to which the specified name is mapped, or null if this Compound contains no variable with the specified name
      • getValue

        public java.lang.Object getValue()
        Description copied from class: Value
        Abstract getValue method. The result of this method must comply to the input conventions of ValueFactory and the constructor of the respective implementing class.
        Specified by:
        getValue in class Value
        Returns:
        the Value of the Datatype
      • accept

        public void accept​(IValueVisitor visitor)
        Description copied from class: Value
        Abstract accept method.
        Specified by:
        accept in class Value
        Parameters:
        visitor - The visitor
      • configureValue

        public void configureValue​(java.lang.String name,
                                   java.lang.Object value)
                            throws ValueDoesNotMatchTypeException
        Method to get the object which a specific name of the hashMap.
        Parameters:
        name - the key for the hashMap
        value - the value, which should be assigned to the key-object.
        Throws:
        ValueDoesNotMatchTypeException - if the given value does not match this type
      • isFullyConfigured

        public boolean isFullyConfigured()
        Description copied from class: StructuredValue
        Method to check, whether each object of the Value has a value assigned.
        Specified by:
        isFullyConfigured in class StructuredValue
        Returns:
        true if all sub-elements are configured, else false
      • clone

        public CompoundValue clone()
        Description copied from class: Value
        Clones the this value.
        Overrides:
        clone in class Value
        Returns:
        the clone of the value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Value
      • hashCode

        private int hashCode​(Compound type)
        Returns the hashCode for a compound type.
        Parameters:
        type - the type to calculate the hashCode for
        Returns:
        the hashCode
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class Value
      • equals

        private boolean equals​(java.lang.Object object,
                               boolean ignoreUndefinedInObject)
        Checks for equality potentially ignoring undefined values in the given object.
        Parameters:
        object - the object to check for
        ignoreUndefinedInObject - whether undefined values in object shall be ignored (partial equality)
        Returns:
        true if object is considered equal to this, false else
      • equals

        private boolean equals​(Compound type,
                               CompoundValue otherValue,
                               boolean ignoreUndefinedInObject)
        Checks for equality potentially ignoring undefined values in the given type.
        Parameters:
        type - the compound to check for
        otherValue - the value to check for
        ignoreUndefinedInObject - whether undefined values in type shall be ignored (partial equality)
        Returns:
        true if type is considered equal to this, false else
      • checkAssignments

        private boolean checkAssignments​(IDecisionVariableContainer container,
                                         CompoundValue otherValue,
                                         boolean ignoreUndefinedInObject)
        Checks the assignments for equality.
        Parameters:
        container - the container to check
        otherValue - the other value to compare against
        ignoreUndefinedInObject - whether undefined values in object shall be ignored (partial equality)
        Returns:
        true if other is considered equal to container, false else
      • checkElements

        private boolean checkElements​(IDecisionVariableContainer container,
                                      CompoundValue otherValue,
                                      boolean ignoreUndefinedInObject)
        Checks the elements for equality.
        Parameters:
        container - the container to check
        otherValue - the other value to compare against
        ignoreUndefinedInObject - whether undefined values in object shall be ignored (partial equality)
        Returns:
        true if other is considered equal to container, false else
      • equalsPartially

        public boolean equalsPartially​(Value value)
        Description copied from class: Value
        Returns whether the provided value is partially equal to this value, i.e., whether the nested elements of value (if they exist) have the same contents as in this value. Other values of this value are not considered. The check is transitive on nested elements. Please consider that this method is not symmetric as opposed to equals. This method is important to cope with default values.
        Specified by:
        equalsPartially in class Value
        Parameters:
        value - the value to be checked for partial equality.
        Returns:
        true if value is partially equal to this, false else
      • getStringValue

        public java.lang.String getStringValue​(java.lang.String slot)
        Returns the string value of slot. [utility method]
        Parameters:
        slot - the slot to return the string value for
        Returns:
        the string value, null if not configured or if slot does not contain a string value
      • getBooleanValue

        public java.lang.Boolean getBooleanValue​(java.lang.String slot)
        Returns the boolean value of slot. [utility method]
        Parameters:
        slot - the slot to return the string value for
        Returns:
        the boolean value, null if not configured or if slot does not contain a boolean value
      • getSlotNames

        public java.util.Collection<java.lang.String> getSlotNames()
        Returns the names of the assigned slots in this value.
        Returns:
        the names of the assigned slots
      • getNestedElementsSize

        public int getNestedElementsSize()
        Get the number of nested elements.
        Returns:
        size of nestedelements.