IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.patterns.framework
Class PatternParameterValue

java.lang.Object
  extended bycom.ibm.xtools.patterns.core.AbstractParameterArgument
      extended bycom.ibm.xtools.patterns.framework.PatternParameterValue
Direct Known Subclasses:
PatternParameterValue.Added, PatternParameterValue.Maintained, PatternParameterValue.Proposed, PatternParameterValue.Removed, PatternParameterValue.Replaced, PatternParameterValue.Unresolved

public abstract class PatternParameterValue
extends AbstractParameterArgument

The pattern parameter value class is a key abstraction in the framework. The pattern parameter value encapsulates all information needed to qualify a value to the proper pattern parameter and pattern instance, plus provides nested subclasses that provide state-specific behavior corresponding to the state that the pattern parameter value is currently in. The state variants of the pattern parameter value class allow for clean and consistent method overloading in the pattern parameter subclasses. For example, when an expand method is called, the specific behavior provided by the pattern author is added to the expand method with the signature referencing the pattern parameter value's direct type. This is implemented similar to the state pattern, but is different because an outside container instance is not holding on to the state. To create a value in a different state, an entire new pattern parameter value must be created and not merely swapped out internally. This paradigm seemed to fit more the design and that is why the state pattern is not followed exactly. This will be referred to as the extrinsic state pattern instead of the state or intrinsic state pattern. A pattern parameter value is the same as the argument value or the actual parameter (in contrast to the pattern parameter which is the formal parameter).


Nested Class Summary
static class PatternParameterValue.Added
          The added subclass of pattern parameter value represents the state of when a pattern parameter value is added.
static class PatternParameterValue.Maintained
          The maintained subclass of the pattern parameter value represents the state of when a pattern parameter value is maintained (it is the current value, not added or removed).
static class PatternParameterValue.Proposed
          The proposed subclass of the pattern parameter value represents the state of when a pattern parameter value is proposed (it is ready for validation but its addition is contingent on the validity of the value.
static class PatternParameterValue.Removed
          The removed subclass of the pattern parameter value represents the state of when a pattern parameter value is removed (it has just been removed as a value)
static class PatternParameterValue.Replaced
          The Replaced subclass of the pattern parameter value represents the state of when a pattern parameter value is replaced by one or more values.
static class PatternParameterValue.Unresolved
          The unresolved subclass of the pattern parameter value represents the state of when a pattern parameter value is unresolved (this state indicates the value is in some alternate form that through a resolve can migrate to another resolved stated such as added).
 
Nested classes inherited from class com.ibm.xtools.patterns.core.AbstractParameterArgument
AbstractParameterArgument.Pair
 
Method Summary
abstract  void accept(com.ibm.xtools.patterns.framework.PatternParameterValue.Consumer consumer)
          An abstract method that is implemented in the subclasses such as added, removed, maintained or proposed.
 AbstractParameterArgument getArgument()
          Gets the current argument as a singular value, if multiple arguments are stored only the first is returned.
 AbstractParameterArgument[] getArguments()
          Gets the current arguments as a multivalue.
 String getImage()
          Retrieves a readable image of the object supplied as the argument for the parameter.
 IPatternMetatype getMetatype()
          Retrieves the metatype of the object supplied as the argument for the parameter.
 AbstractPatternInstance getOwningInstance()
          Get the owning instance.
 AbstractPatternParameter getOwningParameter()
          Get the owning parameter.
 Object getValue()
          Gets the current value as a singular value, if multiple values are stored only the first is returned.
 Object[] getValues()
          Gets the current value as a multivalue.
 boolean hasValue()
          Determine if this pattern parameter value has a value.
 boolean hasValues()
          Determine if this pattern parameter value has values or a value.
 boolean isValueFor(AbstractPatternParameter parameter)
          Determines if the parameter given has the value as specified by this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

accept

public abstract void accept(com.ibm.xtools.patterns.framework.PatternParameterValue.Consumer consumer)
An abstract method that is implemented in the subclasses such as added, removed, maintained or proposed. It is a call me right back method that invokes the consumer providing the most direct type at run-time.

Parameters:
consumer - the callback interface

getArgument

public AbstractParameterArgument getArgument()
Gets the current argument as a singular value, if multiple arguments are stored only the first is returned.

Returns:
the first element of the arguments array

getArguments

public AbstractParameterArgument[] getArguments()
Gets the current arguments as a multivalue. If only one element is stored then an array of length one is returned.

Returns:
returns the arguments as an array

getImage

public String getImage()
Description copied from class: AbstractParameterArgument

Retrieves a readable image of the object supplied as the argument for the parameter.

Specified by:
getImage in class AbstractParameterArgument
Returns:
Returns the image of the object supplied as the argument for the parameter.

getMetatype

public IPatternMetatype getMetatype()
Description copied from class: AbstractParameterArgument

Retrieves the metatype of the object supplied as the argument for the parameter.

Use the isValidArgumentType method to retrieve whether the object of a specific metatype is accepted as an argument of the parameter.

Specified by:
getMetatype in class AbstractParameterArgument
Returns:
Returns the metatype of the object supplied as the argument for the parameter.

getOwningInstance

public AbstractPatternInstance getOwningInstance()
Get the owning instance.

Returns:
the owning instance for this pattern parameter value

getOwningParameter

public AbstractPatternParameter getOwningParameter()
Get the owning parameter.

Returns:
the owning parameter for this pattern parameter value

getValue

public Object getValue()
Gets the current value as a singular value, if multiple values are stored only the first is returned.

Specified by:
getValue in class AbstractParameterArgument
Returns:
the object value of the first element of the arguments array

getValues

public Object[] getValues()
Gets the current value as a multivalue. If only one element is stored then an array of length one is returned.

Returns:
returns the values as an Object array

hasValue

public boolean hasValue()
Determine if this pattern parameter value has a value.

Returns:
indicates whether or not a value exists

hasValues

public boolean hasValues()
Determine if this pattern parameter value has values or a value.

Returns:
indicates whether or not values exist

isValueFor

public boolean isValueFor(AbstractPatternParameter parameter)
Determines if the parameter given has the value as specified by this instance. For example, given a value of this instance, the method can be invoked with a specified parameter to determine if this value is bound to that parameter.

Parameters:
parameter - the parameter to check if this is a value for
Returns:
true if this is a value for the given parameter

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.