Interface CMPField
-
public interface CMPField
This 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 String
getName()
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> T
getValue()
Get the value of this CMP field.boolean
hasValue()
Determine if this CMP field currently has a value.boolean
isPredefined()
Determine if this CMP field is defined in the SBB abstract class or any CMP extension interface.void
reset()
Reset this CMP field to its initial value.<T> void
setValue(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
null
if this CMP field is an arbitrary CMP field that has been set tonull
. - Throws:
UnrecognisedFieldNameException
- if thisCMPField
object 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 ClassCastException
Get 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
null
if it currently has no value. - Throws:
ClassCastException
- ifT
is not a compatible type for the field’s value.- Since:
- Rhino 2.6.1
-
setValue
<T> void setValue(T value) throws NullPointerException, ClassCastException
Set 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 benull
if 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 andvalue
isnull
.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:
true
if this CMP field currently has a value,false
otherwise. This method will always returntrue
for 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
@InitialValueField
annotation, 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
@InitialValueField
annotation, then the CMP field is reset to the default Java-defined initial value for that type, eg. 0 for numeric primitives,null
for 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:
true
if this CMP field is defined in the SBB abstract class or a CMP extension interface,false
otherwise, ie. it is an arbitrary CMP field.- Since:
- Rhino 2.6.1
-
-