Class ContainerValue
java.lang.Object
net.ssehub.easy.varModel.model.values.Value
net.ssehub.easy.varModel.model.values.StructuredValue
net.ssehub.easy.varModel.model.values.ContainerValue
- All Implemented Interfaces:
Cloneable
ContainerValue class.
- Author:
- Marcel Lueder, El-Sharkawy, Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)Constructor for serialization.(package private)ContainerValue(Container container) Constructor for a new ContainerValue.ContainerValue(Container container, boolean check, Object... value) Constructor for a new ContainerValue.(package private)ContainerValue(Container container, Object... value) Constructor for a new ContainerValue.protectedContainerValue(Container container, ContainerValue source) Creates a new compound value by copying the values fromsource. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(IValueVisitor visitor) Abstract accept method.voidaddElement(int pos, Value value) Adds avalueat the positionpos.voidaddElement(Value value) Adds an element to this container.private voidcheckContainedType(Value value) Checks whethervalueis type compliant with thegetContainedType().voidclear()Clears all elements.clone()Clones the this value.voidcopyValuesFrom(ContainerValue source) Copies the values fromsource.private voidAdds/removes all elements to/fromset.private booleanduplicateValues(Object[] values) Checks whether the given array has duplicated values and this value belongs to a set.booleanbooleanequalsPartially(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.Returns the data type explicitly contained in this value.getElement(int index) Returns the specified element.intReturns the number of elements in this container.getValue()Getter for the value.inthashCode()intReturns the (first) index of the specified (nested) value.booleanMethod to check, whether each object of the Value has a value assigned.private booleanChecks whether this value belongs to aSetor aSequence.iterator()Returns an iterator over all values.Turns the nested values into a string.voidremoveElement(int index) Removes a value from this container.voidremoveElement(Value value) Removes a value from this container.voidSets the value for an already existent nested value.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, getType, stringValueOf
-
Field Details
-
nestedElements
-
-
Constructor Details
-
ContainerValue
ContainerValue()Constructor for serialization. -
ContainerValue
ContainerValue(Container container, Object... value) throws ValueDoesNotMatchTypeException Constructor for a new ContainerValue.- Parameters:
container- the container which extends this ContainerValuevalue- the value(s) to be assigned to this container- Throws:
ValueDoesNotMatchTypeException- if the given value does not match this type
-
ContainerValue
public ContainerValue(Container container, boolean check, Object... value) throws ValueDoesNotMatchTypeException Constructor for a new ContainerValue.- Parameters:
container- the container which extends this ContainerValuecheck- for duplicatesvalue- the value(s) to be assigned to this container- Throws:
ValueDoesNotMatchTypeException- if the given value does not match this type
-
ContainerValue
protected ContainerValue(Container container, ContainerValue source) throws ValueDoesNotMatchTypeException Creates a new compound value by copying the values fromsource.- Parameters:
container- the container typesource- the value which acts as a source for data- Throws:
ValueDoesNotMatchTypeException- if the given value does not match this type
-
ContainerValue
ContainerValue(Container container) Constructor for a new ContainerValue.- Parameters:
container- the container which extends this ContainerValue
-
-
Method Details
-
getContainedType
Description copied from class:ValueReturns the data type explicitly contained in this value. This is typically a meta value, i.e. a type expression.- Overrides:
getContainedTypein classValue- Returns:
- the contained type or null if there is none
-
getValue
Getter for the value. Do not use! This value instance has substructures and does not hold a single value. UsegetElement(int)instead. -
nestedValuesToString
Turns the nested values into a string.- Returns:
- the nested values as string
-
toString
-
accept
Description copied from class:ValueAbstract accept method. -
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
-
copyValuesFrom
Copies the values fromsource.- Parameters:
source- the source type- Throws:
ValueDoesNotMatchTypeException- in case that values do not match
-
clone
Description copied from class:ValueClones the this value. -
getElementSize
public int getElementSize()Returns the number of elements in this container.- Returns:
- the number of elements
-
getElement
Returns the specified element.- Parameters:
index- the index of the element to be returned- Returns:
- the specified element
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getElementSize()
-
indexOf
Returns the (first) index of the specified (nested) value.- Parameters:
value- the value to search for- Returns:
- the first index of
valueor-1if not found
-
isSetValue
private boolean isSetValue()Checks whether this value belongs to aSetor aSequence.- Returns:
trueif this value belongs to aSet, otherwisefalse.
-
duplicateValues
Checks whether the given array has duplicated values and this value belongs to a set.- Parameters:
values- The values, which shall be assigned to this ContainerValue.- Returns:
trueif this value belongs to a set and the value array contains duplicates, otherwisefalse.
-
setValue
Sets the value for an already existent nested value.- Parameters:
index- The index of the element to be configured.nestedValue- The new value of the nested element.- Throws:
ValueDoesNotMatchTypeException- IF thisContainerValuerepresents a value of aSetand the newnestedValueis already part of this value.IllegalArgumentException- if some property of the specified element prevents it from being added to this ValueIndexOutOfBoundsException- if the index is out of range (index < 0 || index >= {@link #getElementSize()})
-
hashCode
public int hashCode() -
equals
-
doAll
Adds/removes all elements to/fromset.- Parameters:
set- the set to add/removeadd- add (true) or remove (false)
-
addElement
Adds avalueat the positionpos.- Parameters:
pos- the position after whichvalueshall be addedvalue- the value to be added- Throws:
ValueDoesNotMatchTypeException- in case that the type ofvaluedoes not match the container type of the containers or that index shall be applied to a setIndexOutOfBoundsException- in case that pos is invalid
-
checkContainedType
Checks whethervalueis type compliant with thegetContainedType().- Parameters:
value- the value to check for- Throws:
ValueDoesNotMatchTypeException- in case that the type ofvaluedoes not match the container type of the containers
-
addElement
Adds an element to this container. Shall only be called during dynamic execution.- Parameters:
value- the value to be added- Throws:
ValueDoesNotMatchTypeException- in case that the type ofvaluedoes not match the container type of the containers
-
removeElement
Removes a value from this container.- Parameters:
value- the value to be removed
-
removeElement
public void removeElement(int index) Removes a value from this container.- Parameters:
index- the index position of the value to be removed- Throws:
IndexOutOfBoundsException- in case that the index is illegal
-
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
-
clear
public void clear()Clears all elements. -
iterator
Returns an iterator over all values.- Returns:
- the iterator
-