public class VolatileField
extends java.lang.Object
Constructor and Description |
---|
VolatileField(java.lang.reflect.Field field,
java.lang.Object container)
Initializes a volatile field with an associated object.
|
VolatileField(java.lang.reflect.Field field,
java.lang.Object container,
boolean forceAccess)
Initializes a volatile field with an associated object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
java.lang.Object |
getContainer()
Retrieves the object the field is stored.
|
java.lang.reflect.Field |
getField()
Retrieves the current field.
|
java.lang.Object |
getOldValue()
Retrieves the field value before the previous setValue(), unless saveValue() has been called.
|
java.lang.Object |
getValue()
Retrieves the current field value.
|
boolean |
isForceAccess()
Retrieves whether or not not to override any scope restrictions.
|
void |
revertValue()
Revert to the previously set value.
|
void |
saveValue()
Ensure that the current value is still set after this class has been garbaged collected.
|
void |
setForceAccess(boolean forceAccess)
Sets whether or not not to override any scope restrictions.
|
void |
setValue(java.lang.Object newValue)
Sets the current value.
|
public VolatileField(java.lang.reflect.Field field, java.lang.Object container)
field
- - the field.container
- - the object this field belongs to.public VolatileField(java.lang.reflect.Field field, java.lang.Object container, boolean forceAccess)
field
- - the field.container
- - the object this field belongs to.forceAccess
- - whether or not to override any scope restrictions.public java.lang.reflect.Field getField()
public java.lang.Object getContainer()
public boolean isForceAccess()
public void setForceAccess(boolean forceAccess)
forceAccess
- - TRUE if we override scope, FALSE otherwise.public java.lang.Object getValue()
public java.lang.Object getOldValue()
public void setValue(java.lang.Object newValue)
newValue
- - new field value.public void saveValue()
public void revertValue()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable