Class CompoundValue

All Implemented Interfaces:
Cloneable

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

    • SPECIAL_SLOT_NAME_TYPE

      public static final 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:
    • nestedElements

      private HashMap<String,Value> nestedElements
  • Constructor Details

    • CompoundValue

      CompoundValue()
      Constructor for serialization.
    • CompoundValue

      CompoundValue(Compound compound) throws ValueDoesNotMatchTypeException
      Constructor for a new CompoundValue.
      Parameters:
      compound - compound which extends this CompoundValue
      Throws:
      ValueDoesNotMatchTypeException - if one of the default values do not comply to the respective types
    • CompoundValue

      CompoundValue(Compound compound, 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 Details

    • initializeAttributeAssignment

      private void initializeAttributeAssignment(AttributeAssignment assng, Map<String,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
    • initialize

      private void initialize(IDecisionVariableContainer container, Map<String,Object> initialValues) throws ValueDoesNotMatchTypeException
      Initializes a variable container.
      Parameters:
      container - the variable container
      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(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(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 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(String name, 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
    • copyValuesFrom

      public void copyValuesFrom(CompoundValue source) throws ValueDoesNotMatchTypeException
      Copies the values from source.
      Parameters:
      source - the source type
      Throws:
      ValueDoesNotMatchTypeException - in case that values do not match
    • setValue

      public void setValue(Object value) throws ValueDoesNotMatchTypeException
      Description copied from class: Value
      Abstract setValue-method.
      Specified by:
      setValue in class Value
      Parameters:
      value - the value to set.
      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 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(Object object)
      Overrides:
      equals in class Value
    • equals

      private boolean equals(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 String getStringValue(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 Boolean getBooleanValue(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 Collection<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.