public class VolatileField
extends java.lang.Object
Constructor and Description |
---|
VolatileField(FieldAccessor accessor,
java.lang.Object container)
Initializes a volatile field with the given accessor and associated object.
|
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 |
isCurrentSet()
Determine whether or not we'll need to revert the value.
|
boolean |
isForceAccess()
Retrieves whether or not not to override any scope restrictions.
|
void |
refreshValue()
Reapply the current changed value.
|
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.
|
java.lang.String |
toString() |
VolatileField |
toSynchronized()
Retrieve a synchronized version of the current field.
|
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 VolatileField(FieldAccessor accessor, java.lang.Object container)
accessor
- - the field accessor.container
- - the object this field belongs to.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 refreshValue()
Also refresh the previously set value.
public void saveValue()
public void revertValue()
public VolatileField toSynchronized()
public boolean isCurrentSet()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.lang.String toString()
toString
in class java.lang.Object