public abstract class FieldAugment<T,F> extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T,F> FieldAugment<T,F> |
augment(Class<T> type,
Class<? super F> fieldType,
String name)
(Virtually) adds a field to an existing type and returns an object that can be used to read and write this field.
|
static <T,F> FieldAugment<T,F> |
circularSafeAugment(Class<T> type,
Class<? super F> fieldType,
String name)
(Virtually) adds a field to an existing type and returns an object that can be used to read and write this field.
|
abstract F |
clear(T object) |
abstract F |
compareAndClear(T object,
F expected) |
abstract F |
compareAndSet(T object,
F expected,
F value) |
abstract F |
get(T object) |
abstract F |
getAndSet(T object,
F value) |
void |
set(T object,
F value) |
abstract F |
setIfAbsent(T object,
F value) |
public static <T,F> FieldAugment<T,F> augment(Class<T> type, Class<? super F> fieldType, String name)
If the type already declares a non-final instance field with the given name and a compatible field type, that field will be used. Otherwise the field will be provided virtually.
WARNING: The values put into the augment should NOT reference in any way the object you've added the augment to, or memory leaks may occur.
If you do need to add such references, use #circularSafeAugment(Class, Class, String, Object) instead.
This code assumes that for any combination of type and name this method is only called once.
Otherwise, whether state is shared is undefined.
type - to augmentfieldType - type of the fieldname - of the fielddefaultValue - the value of the augment if it hasn't been set yet.NullPointerException - if type, fieldType or name is nullpublic static <T,F> FieldAugment<T,F> circularSafeAugment(Class<T> type, Class<? super F> fieldType, String name)
This method does the same as #augment(Class, Class, String, Object), except it is safe to set values that reference back to their containing object.
public abstract F get(T object)
NullPointerException - if object is nullpublic final void set(T object, F value)
NullPointerException - if object or value is nullpublic abstract F getAndSet(T object, F value)
NullPointerException - if object or value is null.public abstract F clear(T object)
NullPointerException - if object is nullpublic abstract F compareAndClear(T object, F expected)
expected or already cleared null, otherwise the current value.NullPointerException - if object or expected is nullpublic abstract F setIfAbsent(T object, F value)
NullPointerException - if object or value is nullpublic abstract F compareAndSet(T object, F expected, F value)
NullPointerException - if object, expected or value is nullCopyright © 2011-2015 The Project Lombok Authors, licensed under the MIT licence.