aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/core
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-12-19 11:44:31 +0100
committerRawi01 <Rawi01@users.noreply.github.com>2020-12-20 14:03:28 +0100
commit626c33255bbac12ddab72dda7de2447132f29ae4 (patch)
tree2d4ad6ba4229cf9a6feb1e4c6c81286ab29ae702 /src/utils/lombok/core
parentf17dd036384242971546bc443749ad527b8cd21c (diff)
downloadlombok-626c33255bbac12ddab72dda7de2447132f29ae4.tar.gz
lombok-626c33255bbac12ddab72dda7de2447132f29ae4.tar.bz2
lombok-626c33255bbac12ddab72dda7de2447132f29ae4.zip
[tests] Support javadoc in ecj tests
Diffstat (limited to 'src/utils/lombok/core')
-rw-r--r--src/utils/lombok/core/FieldAugment.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/utils/lombok/core/FieldAugment.java b/src/utils/lombok/core/FieldAugment.java
index 4a32ad04..0982bcb5 100644
--- a/src/utils/lombok/core/FieldAugment.java
+++ b/src/utils/lombok/core/FieldAugment.java
@@ -24,6 +24,7 @@ package lombok.core;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -69,6 +70,10 @@ public abstract class FieldAugment<T, F> {
checkNotNull(fieldType, "fieldType");
checkNotNull(name, "name");
+ if (type.isInterface()) {
+ return new InterfaceFieldAugment<T, F>(name, fieldType);
+ }
+
@SuppressWarnings("unchecked")
F defaultValue = (F) getDefaultValue(fieldType);
FieldAugment<T, F> ret = tryCreateReflectionAugment(type, fieldType, name, defaultValue);
@@ -175,6 +180,54 @@ public abstract class FieldAugment<T, F> {
*/
public abstract F compareAndSet(T object, F expected, F value);
+ private static final class InterfaceFieldAugment<T, F> extends FieldAugment<T, F> {
+ private final String name;
+ private final Class<? super F> fieldType;
+
+ private Map<Class<T>, FieldAugment<T, F>> map = new HashMap<Class<T>, FieldAugment<T,F>>();
+
+ private InterfaceFieldAugment(String name, Class<? super F> fieldType) {
+ this.name = name;
+ this.fieldType = fieldType;
+ }
+
+ private synchronized FieldAugment<T, F> getDelegate(T object) {
+ @SuppressWarnings("unchecked")
+ Class<T> c = (Class<T>) object.getClass();
+
+ FieldAugment<T,F> fieldAugment = map.get(c);
+ if (fieldAugment == null) {
+ fieldAugment = augment(c, fieldType, name);
+ map.put(c, fieldAugment);
+ }
+ return fieldAugment;
+ }
+
+ @Override public F get(T object) {
+ return getDelegate(object).get(object);
+ }
+
+ @Override public F getAndSet(T object, F value) {
+ return getDelegate(object).getAndSet(object, value);
+ }
+
+ @Override public F clear(T object) {
+ return getDelegate(object).clear(object);
+ }
+
+ @Override public F compareAndClear(T object, F expected) {
+ return getDelegate(object).compareAndClear(object, expected);
+ }
+
+ @Override public F setIfAbsent(T object, F value) {
+ return getDelegate(object).setIfAbsent(object, value);
+ }
+
+ @Override public F compareAndSet(T object, F expected, F value) {
+ return getDelegate(object).compareAndSet(object, expected, value);
+ }
+ }
+
private static class ReflectionFieldAugment<T, F> extends FieldAugment<T, F> {
private final Object lock = new Object();
private final Field field;