edu.cmu.sei.aadl.model.properties
Class ReflectiveValueWrapper

java.lang.Object
  extended by edu.cmu.sei.aadl.model.properties.ReflectiveValueWrapper
All Implemented Interfaces:
AadlPropertyValue, ReflectiveAadlPropertyValue

public final class ReflectiveValueWrapper
extends java.lang.Object
implements ReflectiveAadlPropertyValue

Wrapper around an AadlPropertyValue that adds the reflective information.

Author:
aarong

Constructor Summary
ReflectiveValueWrapper(AadlPropertyValue value)
           
ReflectiveValueWrapper(java.util.Map modes, AadlPropertyValue value)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 AadlPropertyValue evaluate(PropertyHolder context, java.util.Map modes)
          Evaluate a property value in the given context and with the given mode bindings.
 boolean exists()
          Does the value exist at all?
 java.util.List getDefiningAssociations()
          Get the property associations/property declaration that determines this value.
 java.util.Map getModeBinding()
          Get the map from ModeContexts to Modes that was used to generate this property value.
 PropertyValue getScalarValue()
          Get the scalar value of the property.
 java.util.List getValue()
          Get the value of the property.
 int hashCode()
           
 AadlPropertyValue instantiate(ComponentInstance root)
          Update the property value so that it makes sense in an instance model.
 boolean isList()
          Is the value a list value?
 boolean isNotPresent()
          Is the value not present.
 java.util.Set preEvaluate(PropertyHolder context)
          Determine which modes this value may depend on.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectiveValueWrapper

public ReflectiveValueWrapper(java.util.Map modes,
                              AadlPropertyValue value)

ReflectiveValueWrapper

public ReflectiveValueWrapper(AadlPropertyValue value)
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getModeBinding

public java.util.Map getModeBinding()
Description copied from interface: ReflectiveAadlPropertyValue
Get the map from ModeContexts to Modes that was used to generate this property value.

Specified by:
getModeBinding in interface ReflectiveAadlPropertyValue

exists

public boolean exists()
Description copied from interface: AadlPropertyValue
Does the value exist at all? A value does not exist if the component does not exist in the particular mode. This is not the same as the value being not present, which indicates that the property value is not set for the component in the given mode.

Specified by:
exists in interface AadlPropertyValue
Returns:
true if the value exists.
See Also:
AadlPropertyValue.isNotPresent()

isNotPresent

public boolean isNotPresent()
Description copied from interface: AadlPropertyValue
Is the value not present.

Specified by:
isNotPresent in interface AadlPropertyValue
Returns:
true if the value is "not present". A non existent property value is not "not present", and thus this returns false if the AadlPropertyValue.exists()is false.

isList

public boolean isList()
Description copied from interface: AadlPropertyValue
Is the value a list value?

Specified by:
isList in interface AadlPropertyValue
Returns:
true if the value is a list. Returns false if AadlPropertyValue.exists()or AadlPropertyValue.isNotPresent()is true.

getValue

public java.util.List getValue()
Description copied from interface: AadlPropertyValue
Get the value of the property.

Specified by:
getValue in interface AadlPropertyValue
Returns:
The value of the property as an immutable list. If the value does not exist or is not present this returns null. If AadlPropertyValue.isList()is false then this list is a one-element list, whose first (and only) element is the property value. Otherwise, the returned list is the property value.

getScalarValue

public PropertyValue getScalarValue()
Description copied from interface: AadlPropertyValue
Get the scalar value of the property.

Specified by:
getScalarValue in interface AadlPropertyValue
Returns:
The scalar value. If the value does not exist or is not present this returns null.

preEvaluate

public java.util.Set preEvaluate(PropertyHolder context)
                          throws InvalidModelException
Description copied from interface: AadlPropertyValue
Determine which modes this value may depend on.

Specified by:
preEvaluate in interface AadlPropertyValue
Parameters:
context - The element this value comes from.
Returns:
The model elements whose modes influence the value
Throws:
InvalidModelException - Thrown if the property value cannot be pre-evaluated because the model is incomplete or malformed.

evaluate

public AadlPropertyValue evaluate(PropertyHolder context,
                                  java.util.Map modes)
                           throws InvalidModelException
Description copied from interface: ReflectiveAadlPropertyValue
Evaluate a property value in the given context and with the given mode bindings. Returns a ReflectiveAadlPropertyValue with same mode bindings as this value.

Specified by:
evaluate in interface AadlPropertyValue
Specified by:
evaluate in interface ReflectiveAadlPropertyValue
Parameters:
context - The element any property references should be looked up against.
modes - A map from ComponentImpl to Modedefining the mode bindings to use for the evaluation.
Returns:
The evaluated property value as a ReflectiveAadlPropertyValue.
Throws:
InvalidModelException - Thrown if the property value cannot be evaluated because the model is incomplete or malformed.

instantiate

public AadlPropertyValue instantiate(ComponentInstance root)
                              throws InvalidModelException
Description copied from interface: AadlPropertyValue
Update the property value so that it makes sense in an instance model. For example, ReferencePropertyValue objects are replaced with InstanceReferencePropertyValue objects.

Specified by:
instantiate in interface AadlPropertyValue
Parameters:
root - The component instance to be used as the root of subcomponent paths. (This is also the component whose declared modes may be used in any in modes clauses.)
Returns:
The instantiated property value.
Throws:
InvalidModelException - Thrown if the property value cannot be instantiated because the model is incomplete or malformed.

getDefiningAssociations

public java.util.List getDefiningAssociations()
Description copied from interface: AadlPropertyValue
Get the property associations/property declaration that determines this value. This is list of at least length one. It contains zero or more property associations followed by at most one property declaration. Specifically, if the value is not list-valued, then this returns a list of length one, where the element is either the PropertyAssociation that provides the value, or the PropertyDefinition of the property in the case that the value is the default value. If the value is list-valued, then the list represents those property assocations and possibly the property defintiion that contribute to the value of the list. This list may be of non-zero length even when AadlPropertyValue.isNotPresent() is true because the value actually be defined to be a reference to another property value and that property value might be undefined.

Specified by:
getDefiningAssociations in interface AadlPropertyValue