Interface CMPField
-
public interface CMPFieldThis interface provides an alternative access mechanism to a single CMP field.
- Since:
- Rhino 2.6.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetName()Get the CMP field name.Set<String>getTags()Get the set of CMP field tags associated with this CMP field.Class<?>getType()Get the expected or current type of this CMP field.<T> TgetValue()Get the value of this CMP field.booleanhasValue()Determine if this CMP field currently has a value.booleanisPredefined()Determine if this CMP field is defined in the SBB abstract class or any CMP extension interface.voidreset()Reset this CMP field to its initial value.<T> voidsetValue(T value)Set the CMP field to the specified value.
-
-
-
Method Detail
-
getName
String getName()
Get the CMP field name.
This method is a non-transactional method.
- Returns:
- the CMP field name.
- Since:
- Rhino 2.6.1
-
getType
Class<?> getType() throws UnrecognisedFieldNameException
Get the expected or current type of this CMP field. <p> If the CMP field is defined in the SBB abstract class or a CMP extension interface then the value returned from this method will be the declared class type. Otherwise the CMP field must be an arbitrary CMP field and the value returned will be the class type of the current value assigned to the CMP field, if any.
This method is a non-transactional method when invoked for a CMP field defined in the SBB abstract class or a CMP extension interface. It is a mandatory transactional method when invoked for an arbitrary CMP field.
- Returns:
- the type of the CMP field’s value, or
nullif this CMP field is an arbitrary CMP field that has been set tonull. - Throws:
UnrecognisedFieldNameException- if thisCMPFieldobject refers to an arbitrary CMP field that does not exist or has no current value.- Since:
- Rhino 2.6.1
-
getTags
Set<String> getTags()
Get the set of CMP field tags associated with this CMP field.
This method is a non-transactional method.
- Returns:
- the set of CMP field tags. The returned set is unmodifiable, and may be empty if the CMP field has not been tagged.
- Since:
- Rhino 2.6.1
-
getValue
<T> T getValue() throws ClassCastExceptionGet the value of this CMP field.
This method is a mandatory transactional method.
- Type Parameters:
T- the expected type of the value.- Returns:
- the field value, or
nullif it currently has no value. - Throws:
ClassCastException- ifTis not a compatible type for the field’s value.- Since:
- Rhino 2.6.1
-
setValue
<T> void setValue(T value) throws NullPointerException, ClassCastExceptionSet the CMP field to the specified value.
This method is a mandatory transactional method.
- Type Parameters:
T- the value type.- Parameters:
value- the value. May benullif the CMP field does not have a primitive type.- Throws:
NullPointerException- if the CMP field was defined in the SBB abstract class or a CMP extension interface with a primitive type andvalueisnull.ClassCastException- if the CMP field was defined in the SBB abstract class or a CMP extension interface and the specified value is not a compatible type.- Since:
- Rhino 2.6.1
-
hasValue
boolean hasValue()
Determine if this CMP field currently has a value.
This method is a mandatory transactional method.
- Returns:
trueif this CMP field currently has a value,falseotherwise. This method will always returntruefor primitive type CMP fields defined in the SBB abstract class or a CMP extension interface.- Since:
- Rhino 2.6.1
-
reset
void reset()
Reset this CMP field to its initial value. The initial value for a CMP field is defined as follows:
-
If the CMP field was defined in the SBB abstract class or a CMP extension interface and has an
@InitialValueFieldannotation, then the CMP field is reset to the specified initial value. -
If the CMP field was defined in the SBB abstract class or a CMP extension interface without an
@InitialValueFieldannotation, then the CMP field is reset to the default Java-defined initial value for that type, eg. 0 for numeric primitives,nullfor object references. -
Otherwise the named CMP field must be an arbitrary CMP field, and the CMP field is reset to
null.
This method is a mandatory transactional method.
- Since:
- Rhino 2.6.1
-
-
isPredefined
boolean isPredefined()
Determine if this CMP field is defined in the SBB abstract class or any CMP extension interface.
This method is a non-transactional method.
- Returns:
trueif this CMP field is defined in the SBB abstract class or a CMP extension interface,falseotherwise, ie. it is an arbitrary CMP field.- Since:
- Rhino 2.6.1
-
-