Class CompoundValue
java.lang.Object
net.ssehub.easy.varModel.model.values.Value
net.ssehub.easy.varModel.model.values.StructuredValue
net.ssehub.easy.varModel.model.values.CompoundValue
- All Implemented Interfaces:
Cloneable
CompoundValue class.
- Author:
- Marcel Lueder, El-Sharkawy, Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDenotes 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). -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Constructor for serialization.(package private)CompoundValue(Compound compound) Constructor for a new CompoundValue.(package private)CompoundValue(Compound compound, Object... value) Constructor for a new CompoundValue.protectedCompoundValue(Compound compound, CompoundValue source) Creates a new compound value by copying the values fromsource. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IValueVisitor visitor) Abstract accept method.private booleancheckAssignments(IDecisionVariableContainer container, CompoundValue otherValue, boolean ignoreUndefinedInObject) Checks the assignments for equality.private booleancheckElements(IDecisionVariableContainer container, CompoundValue otherValue, boolean ignoreUndefinedInObject) Checks the elements for equality.clone()Clones the this value.voidconfigureValue(String name, Object value) Method to get the object which a specific name of the hashMap.voidcopyValuesFrom(CompoundValue source) Copies the values fromsource.booleanprivate booleanChecks for equality potentially ignoring undefined values in the givenobject.private booleanequals(Compound type, CompoundValue otherValue, boolean ignoreUndefinedInObject) Checks for equality potentially ignoring undefined values in the giventype.booleanequalsPartially(Value value) Returns whether the providedvalueis partially equal to this value, i.e., whether the nested elements ofvalue(if they exist) have the same contents as in this value.static final IDatatypegetActualType(Object[] slotValues) Returns the actual type if stored asSPECIAL_SLOT_NAME_TYPEparameter in the given array.getBooleanValue(String slot) Returns the boolean value ofslot.intGet the number of nested elements.getNestedValue(String name) Returns the value for the variable with the given name.Returns the names of the assigned slots in this value.getStringValue(String slot) Returns the string value ofslot.getValue()Abstract getValue method.inthashCode()private intReturns the hashCode for a compound type.private voidinitialize(IDecisionVariableContainer container, Map<String, Object> initialValues) Initializes a variable container.private voidinitializeAttributeAssignment(AttributeAssignment assng, Map<String, Object> initialValues) Initializes an attribute assignment.booleanMethod to check, whether each object of the Value has a value assigned.voidAbstract setValue-method.toString()Methods inherited from class net.ssehub.easy.varModel.model.values.StructuredValue
getValueParent, isConfigured, setValueParentMethods inherited from class net.ssehub.easy.varModel.model.values.Value
equals, equalsPartially, getContainedType, getType, stringValueOf
-
Field Details
-
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
-
-
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 CompoundValuevalue- 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
Creates a new compound value by copying the values fromsource.- Parameters:
compound- the compound typesource- the value which acts as a source for data
-
-
Method Details
-
initializeAttributeAssignment
private void initializeAttributeAssignment(AttributeAssignment assng, Map<String, Object> initialValues) throws ValueDoesNotMatchTypeExceptionInitializes an attribute assignment.- Parameters:
assng- the assignment to initializeinitialValues- 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 ValueDoesNotMatchTypeExceptionInitializes a variable container.- Parameters:
container- the variable containerinitialValues- the initial values- Throws:
ValueDoesNotMatchTypeException- if one of the default values do not comply to the respective types
-
getActualType
Returns the actual type if stored asSPECIAL_SLOT_NAME_TYPEparameter in the given array.- Parameters:
slotValues- the slot values, may be null- Returns:
- the actual type or null
-
getNestedValue
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
Description copied from class:ValueAbstract getValue method. The result of this method must comply to the input conventions ofValueFactoryand the constructor of the respective implementing class. -
accept
Description copied from class:ValueAbstract accept method. -
configureValue
Method to get the object which a specific name of the hashMap.- Parameters:
name- the key for the hashMapvalue- the value, which should be assigned to the key-object.- Throws:
ValueDoesNotMatchTypeException- if the given value does not match this type
-
copyValuesFrom
Copies the values fromsource.- Parameters:
source- the source type- Throws:
ValueDoesNotMatchTypeException- in case that values do not match
-
setValue
Description copied from class:ValueAbstract setValue-method.- Specified by:
setValuein classValue- 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:StructuredValueMethod to check, whether each object of the Value has a value assigned.- Specified by:
isFullyConfiguredin classStructuredValue- Returns:
- true if all sub-elements are configured, else false
-
clone
Description copied from class:ValueClones the this value. -
toString
-
hashCode
public int hashCode() -
hashCode
Returns the hashCode for a compound type.- Parameters:
type- the type to calculate the hashCode for- Returns:
- the hashCode
-
equals
-
equals
Checks for equality potentially ignoring undefined values in the givenobject.- Parameters:
object- the object to check forignoreUndefinedInObject- whether undefined values inobjectshall be ignored (partial equality)- Returns:
trueifobjectis considered equal to this,falseelse
-
equals
Checks for equality potentially ignoring undefined values in the giventype.- Parameters:
type- the compound to check forotherValue- the value to check forignoreUndefinedInObject- whether undefined values intypeshall be ignored (partial equality)- Returns:
trueiftypeis considered equal to this,falseelse
-
checkAssignments
private boolean checkAssignments(IDecisionVariableContainer container, CompoundValue otherValue, boolean ignoreUndefinedInObject) Checks the assignments for equality.- Parameters:
container- the container to checkotherValue- the other value to compare againstignoreUndefinedInObject- whether undefined values inobjectshall be ignored (partial equality)- Returns:
trueifotheris considered equal to container,falseelse
-
checkElements
private boolean checkElements(IDecisionVariableContainer container, CompoundValue otherValue, boolean ignoreUndefinedInObject) Checks the elements for equality.- Parameters:
container- the container to checkotherValue- the other value to compare againstignoreUndefinedInObject- whether undefined values inobjectshall be ignored (partial equality)- Returns:
trueifotheris considered equal to container,falseelse
-
equalsPartially
Description copied from class:ValueReturns whether the providedvalueis partially equal to this value, i.e., whether the nested elements ofvalue(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 toequals. This method is important to cope with default values.- Specified by:
equalsPartiallyin classValue- Parameters:
value- the value to be checked for partial equality.- Returns:
trueifvalueis partially equal to this,falseelse
-
getStringValue
Returns the string value ofslot. [utility method]- Parameters:
slot- the slot to return the string value for- Returns:
- the string value, null if not configured or if
slotdoes not contain a string value
-
getBooleanValue
Returns the boolean value ofslot. [utility method]- Parameters:
slot- the slot to return the string value for- Returns:
- the boolean value, null if not configured or if
slotdoes not contain a boolean value
-
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.
-