From dc3d82e5a814cb4076ba02eed9bd1bc226cde83d Mon Sep 17 00:00:00 2001
From: Pavel Vojtechovsky
Date: Tue, 24 Oct 2017 21:58:57 +0200
Subject: [PATCH 01/14] feature: role based access to model values
---
.../spoon/reflect/declaration/CtElement.java | 36 +
.../spoon/reflect/meta/ContainerKind.java | 43 +
.../java/spoon/reflect/meta/RoleHandler.java | 62 +
.../meta/impl/AbstractRoleHandler.java | 376 ++++
.../reflect/meta/impl/ModelRoleHandlers.java | 1889 +++++++++++++++++
.../meta/impl/RoleHandlerProvider.java | 74 +
.../reflect/declaration/CtElementImpl.java | 39 +
.../generating/RoleHandlersGenerator.java | 205 ++
.../meta/ModelRoleHandlerTemplate.java | 31 +
.../generating/meta/RoleHandlerTemplate.java | 119 ++
10 files changed, 2874 insertions(+)
create mode 100644 src/main/java/spoon/reflect/meta/ContainerKind.java
create mode 100644 src/main/java/spoon/reflect/meta/RoleHandler.java
create mode 100644 src/main/java/spoon/reflect/meta/impl/AbstractRoleHandler.java
create mode 100644 src/main/java/spoon/reflect/meta/impl/ModelRoleHandlers.java
create mode 100644 src/main/java/spoon/reflect/meta/impl/RoleHandlerProvider.java
create mode 100644 src/test/java/spoon/generating/RoleHandlersGenerator.java
create mode 100644 src/test/java/spoon/generating/meta/ModelRoleHandlerTemplate.java
create mode 100644 src/test/java/spoon/generating/meta/RoleHandlerTemplate.java
diff --git a/src/main/java/spoon/reflect/declaration/CtElement.java b/src/main/java/spoon/reflect/declaration/CtElement.java
index 97199180a88..76a81d4e350 100644
--- a/src/main/java/spoon/reflect/declaration/CtElement.java
+++ b/src/main/java/spoon/reflect/declaration/CtElement.java
@@ -32,6 +32,7 @@
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import static spoon.reflect.path.CtRole.ANNOTATION;
@@ -314,4 +315,39 @@ List getAnnotatedChildren(
* Clone the element which calls this method in a new object.
*/
CtElement clone();
+
+ /**
+ * @param role defines, which attribute has to be returned
+ * @return a value of the `role` attribute of this model node.
+ * It can return a single value, List, Set or Map depending on this `element` and `role`.
+ * In all cases the returned value is READ ONLY
+ */
+ T getValueByRole(CtRole role);
+
+ /**
+ * @param role defines, which attribute has to be returned
+ * @return a value of the `role` attribute of this model node adapted to modifiable Collection
+ */
+ Collection getValueByRoleAsCollection(CtRole role);
+ /**
+ * @param role defines, which attribute has to be returned
+ * @return a value of the `role` attribute of this model node adapted to modifiable List
+ */
+ List getValueByRoleAsList(CtRole role);
+ /**
+ * @param role defines, which attribute has to be returned
+ * @return a value of the `role` attribute of this model node adapted to modifiable Set
+ */
+ Set getValueByRoleAsSet(CtRole role);
+ /**
+ * @param role defines, which attribute has to be returned
+ * @return a value of the `role` attribute of this model node adapted to modifiable Map
+ */
+ Map getValueByRoleAsMap(CtRole role);
+
+ /**
+ * @param role defines, which attribute has to be returned
+ * @param value to be assigned value
+ */
+ E setValueByRole(CtRole role, T value);
}
diff --git a/src/main/java/spoon/reflect/meta/ContainerKind.java b/src/main/java/spoon/reflect/meta/ContainerKind.java
new file mode 100644
index 00000000000..15ea37cbca8
--- /dev/null
+++ b/src/main/java/spoon/reflect/meta/ContainerKind.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2006-2017 INRIA and contributors
+ * Spoon - http://spoon.gforge.inria.fr/
+ *
+ * This software is governed by the CeCILL-C License under French law and
+ * abiding by the rules of distribution of free software. You can use, modify
+ * and/or redistribute the software under the terms of the CeCILL-C license as
+ * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+package spoon.reflect.meta;
+
+/**
+ * Defines kind of container, which is used in an attribute of Spoon model
+ */
+public enum ContainerKind {
+ /**
+ * it is a single value field
+ * Example: CtClassImpl.simpleName
+ */
+ SINGLE,
+ /**
+ * It is a list of values
+ * Example: CtClassImpl.typeMembers
+ */
+ LIST,
+ /**
+ * It is a set of values
+ * Example: CtPackageImpl.types
+ */
+ SET,
+ /**
+ * It is a map<String, T> of values
+ * Example: CtAnnotationImpl.elementValues
+ */
+ MAP;
+}
diff --git a/src/main/java/spoon/reflect/meta/RoleHandler.java b/src/main/java/spoon/reflect/meta/RoleHandler.java
new file mode 100644
index 00000000000..86ad2bf5a93
--- /dev/null
+++ b/src/main/java/spoon/reflect/meta/RoleHandler.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2006-2017 INRIA and contributors
+ * Spoon - http://spoon.gforge.inria.fr/
+ *
+ * This software is governed by the CeCILL-C License under French law and
+ * abiding by the rules of distribution of free software. You can use, modify
+ * and/or redistribute the software under the terms of the CeCILL-C license as
+ * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+package spoon.reflect.meta;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import spoon.reflect.path.CtRole;
+
+/**
+ * Has all knowledge about a role of an target type
+ */
+public interface RoleHandler {
+ /**
+ * @return a role of this handler
+ */
+ CtRole getRole();
+ /**
+ * @return a type of the class, which this handler can be applied to
+ */
+ Class> getTargetType();
+ /**
+ * @param element a element whose value will be get
+ * @return a value of the element on the role defined by {@link #getRole()}
+ */
+ U getValue(T element);
+ /**
+ * @param element a element whose value will be set
+ * @param value new value, which will be assigned to the element's attribute defined by role defined by {@link #getRole()}
+ */
+ void setValue(T element, U value);
+ /**
+ * @return a Class of value of the attribute of {@link #getTargetType()} defined by {@link #getRole()}
+ */
+ Class> getValueClass();
+
+ /**
+ * @return true if value can contain only one element. It is not a collection or map
+ */
+ ContainerKind getContainerKind();
+
+ Collection asCollection(T element);
+ Set asSet(T element);
+ List asList(T element);
+ Map asMap(T element);
+}
diff --git a/src/main/java/spoon/reflect/meta/impl/AbstractRoleHandler.java b/src/main/java/spoon/reflect/meta/impl/AbstractRoleHandler.java
new file mode 100644
index 00000000000..d382b92ce0c
--- /dev/null
+++ b/src/main/java/spoon/reflect/meta/impl/AbstractRoleHandler.java
@@ -0,0 +1,376 @@
+/**
+ * Copyright (C) 2006-2017 INRIA and contributors
+ * Spoon - http://spoon.gforge.inria.fr/
+ *
+ * This software is governed by the CeCILL-C License under French law and
+ * abiding by the rules of distribution of free software. You can use, modify
+ * and/or redistribute the software under the terms of the CeCILL-C license as
+ * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+package spoon.reflect.meta.impl;
+
+import java.util.AbstractList;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import spoon.SpoonException;
+import spoon.reflect.meta.ContainerKind;
+import spoon.reflect.meta.RoleHandler;
+import spoon.reflect.path.CtRole;
+
+/**
+ * common implementation of {@link RoleHandler}
+ * @param the type of node whose attribute has to be manipulated
+ * @param the type of container value of the attribute
+ * @param the type of item value of the attribute
+ */
+abstract class AbstractRoleHandler implements RoleHandler {
+
+ private final CtRole role;
+ private final Class targetClass;
+ private final Class valueClass;
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ protected AbstractRoleHandler(CtRole role, Class targetType, Class> valueType) {
+ this.role = role;
+ this.targetClass = targetType;
+ this.valueClass = (Class) valueType;
+ }
+
+ @Override
+ public CtRole getRole() {
+ return role;
+ }
+
+ @Override
+ public Class> getTargetType() {
+ return targetClass;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ protected T castTarget(Object element) {
+ return (T) element;
+ }
+ @SuppressWarnings("unchecked")
+ protected U castValue(Object value) {
+ return (U) value;
+ }
+
+ protected void checkItemsClass(Iterable> iterable) {
+ //check that each item has expected class
+ for (Object value : iterable) {
+ castItemValue(value);
+ }
+ }
+ @SuppressWarnings("unchecked")
+ protected V castItemValue(Object value) {
+ //check that item has expected class
+ if (value != null && valueClass.isInstance(value) == false) {
+ throw new ClassCastException(value.getClass().getName() + " cannot be cast to " + valueClass.getName());
+ }
+ return (V) value;
+ }
+
+ public void setValue(W element, X value) {
+ throw new SpoonException("Setting of CtRole." + role.name() + " is not supported for " + element.getClass().getSimpleName());
+ };
+
+ @Override
+ public Class> getValueClass() {
+ return valueClass;
+ }
+
+ public List asList(W element) {
+ throw new SpoonException("The value of CtRole." + getRole().name() + " cannot be adapted to List for " + element.getClass().getSimpleName());
+ };
+
+ public Set asSet(W element) {
+ throw new SpoonException("The value of CtRole." + getRole().name() + " cannot be adapted to Set for " + element.getClass().getSimpleName());
+ };
+
+ public Map asMap(W element) {
+ throw new SpoonException("The value of CtRole." + getRole().name() + " cannot be adapted to Map for " + element.getClass().getSimpleName());
+ };
+
+// protected abstract Iterator iterator(T element);
+// protected abstract int size(T element);
+// protected abstract V get(T element, int index);
+// protected abstract boolean contains(T element, Object o);
+// protected abstract boolean add(T element, V o);
+// protected abstract boolean remove(T element, Object o);
+
+
+ abstract static class SingleHandler extends AbstractRoleHandler {
+
+ protected SingleHandler(CtRole role, Class targetType, Class> valueClass) {
+ super(role, targetType, valueClass);
+ }
+
+ @Override
+ public ContainerKind getContainerKind() {
+ return ContainerKind.SINGLE;
+ }
+
+ public java.util.Collection asCollection(W element) {
+ return asList(element);
+ };
+
+ public java.util.List asList(W element) {
+ return Collections.singletonList(getValue(element));
+ };
+
+ public java.util.Set asSet(W element) {
+ return Collections.singleton(getValue(element));
+ };
+ }
+
+ abstract static class ListHandler extends AbstractRoleHandler, V> {
+
+ protected ListHandler(CtRole role, Class targetType, Class> valueClass) {
+ super(role, targetType, valueClass);
+ }
+
+ @Override
+ public ContainerKind getContainerKind() {
+ return ContainerKind.LIST;
+ }
+
+ @Override
+ protected List castValue(Object value) {
+ List list = super.castValue(value);
+ //check that each item has expected class
+ checkItemsClass(list);
+ return list;
+ }
+
+ public java.util.Collection asCollection(W element) {
+ return asList(element);
+ };
+
+ public java.util.List asList(W e) {
+ return new AbstractList() {
+ T element = castTarget(e);
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Iterator iterator() {
+ return (Iterator) ListHandler.this.iterator(element);
+ }
+
+ @Override
+ public int size() {
+ return ListHandler.this.size(element);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public X get(int index) {
+ return (X) ListHandler.this.get(element, index);
+ }
+ @Override
+ public boolean add(X value) {
+ return ListHandler.this.add(element, castItemValue(value));
+ }
+
+ @Override
+ public boolean remove(Object value) {
+ return ListHandler.this.remove(element, value);
+ }
+ };
+ }
+
+ protected boolean remove(T element, Object value) {
+ List values = new ArrayList<>(this.>getValue(element));
+ boolean ret = values.remove(value);
+ if (ret) {
+ setValue(element, values);
+ }
+ return ret;
+ }
+
+ protected boolean add(T element, V value) {
+ List values = new ArrayList<>(this.>getValue(element));
+ boolean ret = values.add(value);
+ setValue(element, values);
+ return ret;
+ }
+
+ protected V get(T element, int index) {
+ return this.>getValue(element).get(index);
+ }
+
+ protected int size(T element) {
+ return this.>getValue(element).size();
+ }
+
+ protected Iterator iterator(T element) {
+ return this.>getValue(element).iterator();
+ };
+ }
+
+ abstract static class SetHandler extends AbstractRoleHandler, V> {
+
+ protected SetHandler(CtRole role, Class targetType, Class> valueClass) {
+ super(role, targetType, valueClass);
+ }
+
+ @Override
+ public ContainerKind getContainerKind() {
+ return ContainerKind.SET;
+ }
+
+ @Override
+ protected Set castValue(Object value) {
+ Set set = super.castValue(value);
+ //check that each item has expected class
+ checkItemsClass(set);
+ return set;
+ }
+
+ public Collection asCollection(W element) {
+ return asSet(element);
+ };
+
+ @Override
+ public Set asSet(W e) {
+ return new AbstractSet() {
+ T element = castTarget(e);
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Iterator iterator() {
+ return (Iterator) SetHandler.this.iterator(element);
+ }
+
+ @Override
+ public int size() {
+ return SetHandler.this.size(element);
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return SetHandler.this.contains(element, o);
+ }
+
+ @Override
+ public boolean add(X value) {
+ return SetHandler.this.add(element, castItemValue(value));
+ }
+
+ @Override
+ public boolean remove(Object value) {
+ return SetHandler.this.remove(element, value);
+ }
+ };
+ }
+
+ protected boolean remove(T element, Object value) {
+ Set values = new HashSet<>(this.>getValue(element));
+ boolean ret = values.remove(value);
+ if (ret) {
+ setValue(element, values);
+ }
+ return false;
+ }
+
+ protected boolean add(T element, V value) {
+ Set values = new HashSet<>(this.>getValue(element));
+ boolean ret = values.add(value);
+ if (ret) {
+ setValue(element, values);
+ }
+ return ret;
+ }
+
+ protected boolean contains(T element, Object o) {
+ return this.>getValue(element).contains(o);
+ }
+
+ protected int size(T element) {
+ return this.>getValue(element).size();
+ }
+
+ protected Iterator iterator(T element) {
+ return this.>getValue(element).iterator();
+ }
+ }
+
+ abstract static class MapHandler extends AbstractRoleHandler, V> {
+
+ protected MapHandler(CtRole role, Class targetType, Class> valueClass) {
+ super(role, targetType, valueClass);
+ }
+
+ @Override
+ public ContainerKind getContainerKind() {
+ return ContainerKind.MAP;
+ }
+
+ @Override
+ protected Map castValue(Object value) {
+ Map map = super.castValue(value);
+ //check that each item has expected class
+ checkItemsClass(map.values());
+ return map;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public java.util.Collection asCollection(W element) {
+ return (Collection) asMap(element).values();
+ };
+
+ @Override
+ public Map asMap(W e) {
+ // TODO Auto-generated method stub
+ return new AbstractMap() {
+ T element = castTarget(e);
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Set> entrySet() {
+ return (Set) MapHandler.this.entrySet(element);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public X get(Object key) {
+ return (X) MapHandler.this.get(element, key);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public X put(String key, X value) {
+ return (X) MapHandler.this.put(element, key, castItemValue(value));
+ }
+ };
+ }
+
+ protected V get(T element, Object key) {
+ return this.>getValue(element).get(key);
+ }
+
+ protected V put(T element, String key, V value) {
+ return this.>getValue(element).put(key, value);
+ }
+
+ protected Set> entrySet(T element) {
+ return this.>getValue(element).entrySet();
+ }
+ }
+}
diff --git a/src/main/java/spoon/reflect/meta/impl/ModelRoleHandlers.java b/src/main/java/spoon/reflect/meta/impl/ModelRoleHandlers.java
new file mode 100644
index 00000000000..e6a35bd6100
--- /dev/null
+++ b/src/main/java/spoon/reflect/meta/impl/ModelRoleHandlers.java
@@ -0,0 +1,1889 @@
+/**
+ * Copyright (C) 2006-2017 INRIA and contributors
+ * Spoon - http://spoon.gforge.inria.fr/
+ *
+ * This software is governed by the CeCILL-C License under French law and
+ * abiding by the rules of distribution of free software. You can use, modify
+ * and/or redistribute the software under the terms of the CeCILL-C license as
+ * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+package spoon.reflect.meta.impl;
+
+
+import java.lang.annotation.Annotation;
+import spoon.reflect.code.BinaryOperatorKind;
+import spoon.reflect.code.CtAbstractInvocation;
+import spoon.reflect.code.CtArrayAccess;
+import spoon.reflect.code.CtAssert;
+import spoon.reflect.code.CtAssignment;
+import spoon.reflect.code.CtBinaryOperator;
+import spoon.reflect.code.CtBlock;
+import spoon.reflect.code.CtBodyHolder;
+import spoon.reflect.code.CtCase;
+import spoon.reflect.code.CtCatch;
+import spoon.reflect.code.CtCatchVariable;
+import spoon.reflect.code.CtComment;
+import spoon.reflect.code.CtConditional;
+import spoon.reflect.code.CtDo;
+import spoon.reflect.code.CtExecutableReferenceExpression;
+import spoon.reflect.code.CtExpression;
+import spoon.reflect.code.CtFor;
+import spoon.reflect.code.CtForEach;
+import spoon.reflect.code.CtIf;
+import spoon.reflect.code.CtJavaDoc;
+import spoon.reflect.code.CtJavaDocTag;
+import spoon.reflect.code.CtLabelledFlowBreak;
+import spoon.reflect.code.CtLambda;
+import spoon.reflect.code.CtLiteral;
+import spoon.reflect.code.CtLocalVariable;
+import spoon.reflect.code.CtNewArray;
+import spoon.reflect.code.CtNewClass;
+import spoon.reflect.code.CtOperatorAssignment;
+import spoon.reflect.code.CtRHSReceiver;
+import spoon.reflect.code.CtReturn;
+import spoon.reflect.code.CtStatement;
+import spoon.reflect.code.CtStatementList;
+import spoon.reflect.code.CtSwitch;
+import spoon.reflect.code.CtSynchronized;
+import spoon.reflect.code.CtTargetedExpression;
+import spoon.reflect.code.CtThrow;
+import spoon.reflect.code.CtTry;
+import spoon.reflect.code.CtTryWithResource;
+import spoon.reflect.code.CtTypeAccess;
+import spoon.reflect.code.CtUnaryOperator;
+import spoon.reflect.code.CtVariableAccess;
+import spoon.reflect.code.CtWhile;
+import spoon.reflect.code.UnaryOperatorKind;
+import spoon.reflect.cu.SourcePosition;
+import spoon.reflect.declaration.CtAnnotation;
+import spoon.reflect.declaration.CtAnnotationMethod;
+import spoon.reflect.declaration.CtAnonymousExecutable;
+import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtCodeSnippet;
+import spoon.reflect.declaration.CtConstructor;
+import spoon.reflect.declaration.CtElement;
+import spoon.reflect.declaration.CtEnum;
+import spoon.reflect.declaration.CtEnumValue;
+import spoon.reflect.declaration.CtExecutable;
+import spoon.reflect.declaration.CtField;
+import spoon.reflect.declaration.CtFormalTypeDeclarer;
+import spoon.reflect.declaration.CtMethod;
+import spoon.reflect.declaration.CtModifiable;
+import spoon.reflect.declaration.CtMultiTypedElement;
+import spoon.reflect.declaration.CtNamedElement;
+import spoon.reflect.declaration.CtPackage;
+import spoon.reflect.declaration.CtParameter;
+import spoon.reflect.declaration.CtShadowable;
+import spoon.reflect.declaration.CtType;
+import spoon.reflect.declaration.CtTypeInformation;
+import spoon.reflect.declaration.CtTypeMember;
+import spoon.reflect.declaration.CtTypeParameter;
+import spoon.reflect.declaration.CtTypedElement;
+import spoon.reflect.declaration.CtVariable;
+import spoon.reflect.declaration.ModifierKind;
+import spoon.reflect.meta.RoleHandler;
+import spoon.reflect.meta.impl.AbstractRoleHandler.ListHandler;
+import spoon.reflect.meta.impl.AbstractRoleHandler.MapHandler;
+import spoon.reflect.meta.impl.AbstractRoleHandler.SetHandler;
+import spoon.reflect.meta.impl.AbstractRoleHandler.SingleHandler;
+import spoon.reflect.path.CtRole;
+import spoon.reflect.reference.CtActualTypeContainer;
+import spoon.reflect.reference.CtArrayTypeReference;
+import spoon.reflect.reference.CtExecutableReference;
+import spoon.reflect.reference.CtFieldReference;
+import spoon.reflect.reference.CtIntersectionTypeReference;
+import spoon.reflect.reference.CtPackageReference;
+import spoon.reflect.reference.CtParameterReference;
+import spoon.reflect.reference.CtReference;
+import spoon.reflect.reference.CtTypeParameterReference;
+import spoon.reflect.reference.CtTypeReference;
+import spoon.reflect.reference.CtVariableReference;
+
+
+/**
+ * Contains implementations of {@link RoleHandler}s for all {@link CtRole}s of all model elements
+ */
+class ModelRoleHandlers {
+ static final RoleHandler[] roleHandlers = new RoleHandler[]{ new CtNamedElement_NAME_RoleHandler(), new CtReference_NAME_RoleHandler(), new CtArrayTypeReference_TYPE_RoleHandler(), new CtExecutableReference_TYPE_RoleHandler(), new CtMultiTypedElement_TYPE_RoleHandler(), new CtTypedElement_TYPE_RoleHandler(), new CtVariableReference_TYPE_RoleHandler(), new CtExecutableReference_DECLARING_TYPE_RoleHandler(), new CtFieldReference_DECLARING_TYPE_RoleHandler(), new CtTypeReference_DECLARING_TYPE_RoleHandler(), new CtPackage_CONTAINED_TYPE_RoleHandler(), new CtBodyHolder_BODY_RoleHandler(), new CtSynchronized_BODY_RoleHandler(), new CtShadowable_IS_SHADOW_RoleHandler(), new CtIntersectionTypeReference_BOUND_RoleHandler(), new CtTypeParameterReference_BOUNDING_TYPE_RoleHandler(), new CtFieldReference_IS_FINAL_RoleHandler(), new CtExecutableReference_IS_STATIC_RoleHandler(), new CtFieldReference_IS_STATIC_RoleHandler(), new CtTypeParameterReference_IS_UPPER_RoleHandler(), new CtElement_IS_IMPLICIT_RoleHandler(), new CtMethod_IS_DEFAULT_RoleHandler(), new CtParameter_IS_VARARGS_RoleHandler(), new CtAnnotationMethod_DEFAULT_EXPRESSION_RoleHandler(), new CtVariable_DEFAULT_EXPRESSION_RoleHandler(), new CtConditional_THEN_RoleHandler(), new CtIf_THEN_RoleHandler(), new CtConditional_ELSE_RoleHandler(), new CtIf_ELSE_RoleHandler(), new CtTypeReference_PACKAGE_REF_RoleHandler(), new CtPackage_SUB_PACKAGE_RoleHandler(), new CtAssert_CONDITION_RoleHandler(), new CtConditional_CONDITION_RoleHandler(), new CtIf_CONDITION_RoleHandler(), new CtBinaryOperator_RIGHT_OPERAND_RoleHandler(), new CtBinaryOperator_LEFT_OPERAND_RoleHandler(), new CtStatement_LABEL_RoleHandler(), new CtSwitch_CASE_RoleHandler(), new CtBinaryOperator_OPERATOR_KIND_RoleHandler(), new CtOperatorAssignment_OPERATOR_KIND_RoleHandler(), new CtUnaryOperator_OPERATOR_KIND_RoleHandler(), new CtCatch_PARAMETER_RoleHandler(), new CtExecutable_PARAMETER_RoleHandler(), new CtExecutableReference_ARGUMENT_TYPE_RoleHandler(), new CtArrayAccess_EXPRESSION_RoleHandler(), new CtAssert_EXPRESSION_RoleHandler(), new CtCase_EXPRESSION_RoleHandler(), new CtDo_EXPRESSION_RoleHandler(), new CtFor_EXPRESSION_RoleHandler(), new CtForEach_EXPRESSION_RoleHandler(), new CtLambda_EXPRESSION_RoleHandler(), new CtNewArray_EXPRESSION_RoleHandler(), new CtReturn_EXPRESSION_RoleHandler(), new CtSwitch_EXPRESSION_RoleHandler(), new CtSynchronized_EXPRESSION_RoleHandler(), new CtThrow_EXPRESSION_RoleHandler(), new CtUnaryOperator_EXPRESSION_RoleHandler(), new CtWhile_EXPRESSION_RoleHandler(), new CtTargetedExpression_TARGET_RoleHandler(), new CtVariableAccess_VARIABLE_RoleHandler(), new CtTry_FINALIZER_RoleHandler(), new CtExecutable_THROWN_RoleHandler(), new CtRHSReceiver_ASSIGNMENT_RoleHandler(), new CtAssignment_ASSIGNED_RoleHandler(), new CtModifiable_MODIFIER_RoleHandler(), new CtTypeInformation_MODIFIER_RoleHandler(), new CtElement_COMMENT_RoleHandler(), new CtAnnotation_ANNOTATION_TYPE_RoleHandler(), new CtTypeInformation_INTERFACE_RoleHandler(), new CtElement_ANNOTATION_RoleHandler(), new CtStatementList_STATEMENT_RoleHandler(), new CtAbstractInvocation_ARGUMENT_RoleHandler(), new CtTypeInformation_SUPER_TYPE_RoleHandler(), new CtNewClass_NESTED_TYPE_RoleHandler(), new CtType_NESTED_TYPE_RoleHandler(), new CtClass_CONSTRUCTOR_RoleHandler(), new CtAbstractInvocation_EXECUTABLE_REF_RoleHandler(), new CtExecutableReferenceExpression_EXECUTABLE_REF_RoleHandler(), new CtParameterReference_EXECUTABLE_REF_RoleHandler(), new CtType_METHOD_RoleHandler(), new CtClass_ANNONYMOUS_EXECUTABLE_RoleHandler(), new CtType_FIELD_RoleHandler(), new CtType_TYPE_MEMBER_RoleHandler(), new CtExpression_CAST_RoleHandler(), new CtAnnotation_VALUE_RoleHandler(), new CtEnum_VALUE_RoleHandler(), new CtLiteral_VALUE_RoleHandler(), new CtFor_FOR_UPDATE_RoleHandler(), new CtFor_FOR_INIT_RoleHandler(), new CtForEach_FOREACH_VARIABLE_RoleHandler(), new CtTryWithResource_TRY_RESOURCE_RoleHandler(), new CtNewArray_DIMENSION_RoleHandler(), new CtTry_CATCH_RoleHandler(), new CtLabelledFlowBreak_TARGET_LABEL_RoleHandler(), new CtFormalTypeDeclarer_TYPE_PARAMETER_RoleHandler(), new CtActualTypeContainer_TYPE_ARGUMENT_RoleHandler(), new CtJavaDoc_COMMENT_TAG_RoleHandler(), new CtComment_COMMENT_CONTENT_RoleHandler(), new CtJavaDocTag_COMMENT_CONTENT_RoleHandler(), new CtComment_COMMENT_TYPE_RoleHandler(), new CtJavaDocTag_DOCUMENTATION_TYPE_RoleHandler(), new CtJavaDocTag_JAVADOC_TAG_VALUE_RoleHandler(), new CtElement_POSITION_RoleHandler(), new CtCodeSnippet_SNIPPET_RoleHandler(), new CtTypeAccess_ACCESSED_TYPE_RoleHandler() };
+
+ private ModelRoleHandlers() {
+ }
+
+ static class CtNamedElement_NAME_RoleHandler extends SingleHandler {
+ private CtNamedElement_NAME_RoleHandler() {
+ super(CtRole.NAME, CtNamedElement.class, String.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getSimpleName())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setSimpleName(castValue(value));
+ }
+ }
+
+ static class CtReference_NAME_RoleHandler extends SingleHandler {
+ private CtReference_NAME_RoleHandler() {
+ super(CtRole.NAME, CtReference.class, String.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getSimpleName())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setSimpleName(castValue(value));
+ }
+ }
+
+ static class CtArrayTypeReference_TYPE_RoleHandler extends SingleHandler> {
+ private CtArrayTypeReference_TYPE_RoleHandler() {
+ super(CtRole.TYPE, CtArrayTypeReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getComponentType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setComponentType(castValue(value));
+ }
+ }
+
+ static class CtExecutableReference_TYPE_RoleHandler extends SingleHandler> {
+ private CtExecutableReference_TYPE_RoleHandler() {
+ super(CtRole.TYPE, CtExecutableReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setType(castValue(value));
+ }
+ }
+
+ static class CtMultiTypedElement_TYPE_RoleHandler extends ListHandler> {
+ private CtMultiTypedElement_TYPE_RoleHandler() {
+ super(CtRole.TYPE, CtMultiTypedElement.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getMultiTypes())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setMultiTypes(castValue(value));
+ }
+ }
+
+ static class CtTypedElement_TYPE_RoleHandler extends SingleHandler> {
+ private CtTypedElement_TYPE_RoleHandler() {
+ super(CtRole.TYPE, CtTypedElement.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setType(castValue(value));
+ }
+ }
+
+ static class CtVariableReference_TYPE_RoleHandler extends SingleHandler> {
+ private CtVariableReference_TYPE_RoleHandler() {
+ super(CtRole.TYPE, CtVariableReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setType(castValue(value));
+ }
+ }
+
+ static class CtExecutableReference_DECLARING_TYPE_RoleHandler extends SingleHandler> {
+ private CtExecutableReference_DECLARING_TYPE_RoleHandler() {
+ super(CtRole.DECLARING_TYPE, CtExecutableReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getDeclaringType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDeclaringType(castValue(value));
+ }
+ }
+
+ static class CtFieldReference_DECLARING_TYPE_RoleHandler extends SingleHandler> {
+ private CtFieldReference_DECLARING_TYPE_RoleHandler() {
+ super(CtRole.DECLARING_TYPE, CtFieldReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getDeclaringType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDeclaringType(castValue(value));
+ }
+ }
+
+ static class CtTypeReference_DECLARING_TYPE_RoleHandler extends SingleHandler> {
+ private CtTypeReference_DECLARING_TYPE_RoleHandler() {
+ super(CtRole.DECLARING_TYPE, CtTypeReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getDeclaringType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDeclaringType(castValue(value));
+ }
+ }
+
+ static class CtPackage_CONTAINED_TYPE_RoleHandler extends SetHandler> {
+ private CtPackage_CONTAINED_TYPE_RoleHandler() {
+ super(CtRole.CONTAINED_TYPE, CtPackage.class, CtType.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getTypes())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setTypes(castValue(value));
+ }
+ }
+
+ static class CtBodyHolder_BODY_RoleHandler extends SingleHandler {
+ private CtBodyHolder_BODY_RoleHandler() {
+ super(CtRole.BODY, CtBodyHolder.class, CtStatement.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getBody())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setBody(castValue(value));
+ }
+ }
+
+ static class CtSynchronized_BODY_RoleHandler extends SingleHandler> {
+ private CtSynchronized_BODY_RoleHandler() {
+ super(CtRole.BODY, CtSynchronized.class, CtBlock.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getBlock())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setBlock(castValue(value));
+ }
+ }
+
+ static class CtShadowable_IS_SHADOW_RoleHandler extends SingleHandler {
+ private CtShadowable_IS_SHADOW_RoleHandler() {
+ super(CtRole.IS_SHADOW, CtShadowable.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isShadow())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setShadow(castValue(value));
+ }
+ }
+
+ static class CtIntersectionTypeReference_BOUND_RoleHandler extends ListHandler> {
+ private CtIntersectionTypeReference_BOUND_RoleHandler() {
+ super(CtRole.BOUND, CtIntersectionTypeReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getBounds())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setBounds(castValue(value));
+ }
+ }
+
+ static class CtTypeParameterReference_BOUNDING_TYPE_RoleHandler extends SingleHandler> {
+ private CtTypeParameterReference_BOUNDING_TYPE_RoleHandler() {
+ super(CtRole.BOUNDING_TYPE, CtTypeParameterReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getBoundingType())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setBoundingType(castValue(value));
+ }
+ }
+
+ static class CtFieldReference_IS_FINAL_RoleHandler extends SingleHandler {
+ private CtFieldReference_IS_FINAL_RoleHandler() {
+ super(CtRole.IS_FINAL, CtFieldReference.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isFinal())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setFinal(castValue(value));
+ }
+ }
+
+ static class CtExecutableReference_IS_STATIC_RoleHandler extends SingleHandler {
+ private CtExecutableReference_IS_STATIC_RoleHandler() {
+ super(CtRole.IS_STATIC, CtExecutableReference.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isStatic())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setStatic(castValue(value));
+ }
+ }
+
+ static class CtFieldReference_IS_STATIC_RoleHandler extends SingleHandler {
+ private CtFieldReference_IS_STATIC_RoleHandler() {
+ super(CtRole.IS_STATIC, CtFieldReference.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isStatic())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setStatic(castValue(value));
+ }
+ }
+
+ static class CtTypeParameterReference_IS_UPPER_RoleHandler extends SingleHandler {
+ private CtTypeParameterReference_IS_UPPER_RoleHandler() {
+ super(CtRole.IS_UPPER, CtTypeParameterReference.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isUpper())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setUpper(castValue(value));
+ }
+ }
+
+ static class CtElement_IS_IMPLICIT_RoleHandler extends SingleHandler {
+ private CtElement_IS_IMPLICIT_RoleHandler() {
+ super(CtRole.IS_IMPLICIT, CtElement.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isImplicit())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setImplicit(castValue(value));
+ }
+ }
+
+ static class CtMethod_IS_DEFAULT_RoleHandler extends SingleHandler {
+ private CtMethod_IS_DEFAULT_RoleHandler() {
+ super(CtRole.IS_DEFAULT, CtMethod.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isDefaultMethod())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDefaultMethod(castValue(value));
+ }
+ }
+
+ static class CtParameter_IS_VARARGS_RoleHandler extends SingleHandler {
+ private CtParameter_IS_VARARGS_RoleHandler() {
+ super(CtRole.IS_VARARGS, CtParameter.class, Boolean.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).isVarArgs())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setVarArgs(castValue(value));
+ }
+ }
+
+ static class CtAnnotationMethod_DEFAULT_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtAnnotationMethod_DEFAULT_EXPRESSION_RoleHandler() {
+ super(CtRole.DEFAULT_EXPRESSION, CtAnnotationMethod.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getDefaultExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDefaultExpression(castValue(value));
+ }
+ }
+
+ static class CtVariable_DEFAULT_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtVariable_DEFAULT_EXPRESSION_RoleHandler() {
+ super(CtRole.DEFAULT_EXPRESSION, CtVariable.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getDefaultExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setDefaultExpression(castValue(value));
+ }
+ }
+
+ static class CtConditional_THEN_RoleHandler extends SingleHandler> {
+ private CtConditional_THEN_RoleHandler() {
+ super(CtRole.THEN, CtConditional.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getThenExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setThenExpression(castValue(value));
+ }
+ }
+
+ static class CtIf_THEN_RoleHandler extends SingleHandler {
+ private CtIf_THEN_RoleHandler() {
+ super(CtRole.THEN, CtIf.class, CtStatement.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getThenStatement())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setThenStatement(castValue(value));
+ }
+ }
+
+ static class CtConditional_ELSE_RoleHandler extends SingleHandler> {
+ private CtConditional_ELSE_RoleHandler() {
+ super(CtRole.ELSE, CtConditional.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getElseExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setElseExpression(castValue(value));
+ }
+ }
+
+ static class CtIf_ELSE_RoleHandler extends SingleHandler {
+ private CtIf_ELSE_RoleHandler() {
+ super(CtRole.ELSE, CtIf.class, CtStatement.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getElseStatement())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setElseStatement(castValue(value));
+ }
+ }
+
+ static class CtTypeReference_PACKAGE_REF_RoleHandler extends SingleHandler {
+ private CtTypeReference_PACKAGE_REF_RoleHandler() {
+ super(CtRole.PACKAGE_REF, CtTypeReference.class, CtPackageReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getPackage())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setPackage(castValue(value));
+ }
+ }
+
+ static class CtPackage_SUB_PACKAGE_RoleHandler extends SetHandler {
+ private CtPackage_SUB_PACKAGE_RoleHandler() {
+ super(CtRole.SUB_PACKAGE, CtPackage.class, CtPackage.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getPackages())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setPackages(castValue(value));
+ }
+ }
+
+ static class CtAssert_CONDITION_RoleHandler extends SingleHandler> {
+ private CtAssert_CONDITION_RoleHandler() {
+ super(CtRole.CONDITION, CtAssert.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getAssertExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setAssertExpression(castValue(value));
+ }
+ }
+
+ static class CtConditional_CONDITION_RoleHandler extends SingleHandler> {
+ private CtConditional_CONDITION_RoleHandler() {
+ super(CtRole.CONDITION, CtConditional.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getCondition())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setCondition(castValue(value));
+ }
+ }
+
+ static class CtIf_CONDITION_RoleHandler extends SingleHandler> {
+ private CtIf_CONDITION_RoleHandler() {
+ super(CtRole.CONDITION, CtIf.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getCondition())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setCondition(castValue(value));
+ }
+ }
+
+ static class CtBinaryOperator_RIGHT_OPERAND_RoleHandler extends SingleHandler> {
+ private CtBinaryOperator_RIGHT_OPERAND_RoleHandler() {
+ super(CtRole.RIGHT_OPERAND, CtBinaryOperator.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getRightHandOperand())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setRightHandOperand(castValue(value));
+ }
+ }
+
+ static class CtBinaryOperator_LEFT_OPERAND_RoleHandler extends SingleHandler> {
+ private CtBinaryOperator_LEFT_OPERAND_RoleHandler() {
+ super(CtRole.LEFT_OPERAND, CtBinaryOperator.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getLeftHandOperand())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setLeftHandOperand(castValue(value));
+ }
+ }
+
+ static class CtStatement_LABEL_RoleHandler extends SingleHandler {
+ private CtStatement_LABEL_RoleHandler() {
+ super(CtRole.LABEL, CtStatement.class, String.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getLabel())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setLabel(castValue(value));
+ }
+ }
+
+ static class CtSwitch_CASE_RoleHandler extends ListHandler> {
+ private CtSwitch_CASE_RoleHandler() {
+ super(CtRole.CASE, CtSwitch.class, CtCase.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getCases())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setCases(castValue(value));
+ }
+ }
+
+ static class CtBinaryOperator_OPERATOR_KIND_RoleHandler extends SingleHandler {
+ private CtBinaryOperator_OPERATOR_KIND_RoleHandler() {
+ super(CtRole.OPERATOR_KIND, CtBinaryOperator.class, BinaryOperatorKind.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getKind())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setKind(castValue(value));
+ }
+ }
+
+ static class CtOperatorAssignment_OPERATOR_KIND_RoleHandler extends SingleHandler {
+ private CtOperatorAssignment_OPERATOR_KIND_RoleHandler() {
+ super(CtRole.OPERATOR_KIND, CtOperatorAssignment.class, BinaryOperatorKind.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getKind())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setKind(castValue(value));
+ }
+ }
+
+ static class CtUnaryOperator_OPERATOR_KIND_RoleHandler extends SingleHandler {
+ private CtUnaryOperator_OPERATOR_KIND_RoleHandler() {
+ super(CtRole.OPERATOR_KIND, CtUnaryOperator.class, UnaryOperatorKind.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getKind())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setKind(castValue(value));
+ }
+ }
+
+ static class CtCatch_PARAMETER_RoleHandler extends SingleHandler> {
+ private CtCatch_PARAMETER_RoleHandler() {
+ super(CtRole.PARAMETER, CtCatch.class, CtCatchVariable.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getParameter())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setParameter(castValue(value));
+ }
+ }
+
+ static class CtExecutable_PARAMETER_RoleHandler extends ListHandler> {
+ private CtExecutable_PARAMETER_RoleHandler() {
+ super(CtRole.PARAMETER, CtExecutable.class, CtParameter.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getParameters())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setParameters(castValue(value));
+ }
+ }
+
+ static class CtExecutableReference_ARGUMENT_TYPE_RoleHandler extends ListHandler> {
+ private CtExecutableReference_ARGUMENT_TYPE_RoleHandler() {
+ super(CtRole.ARGUMENT_TYPE, CtExecutableReference.class, CtTypeReference.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getParameters())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setParameters(castValue(value));
+ }
+ }
+
+ static class CtArrayAccess_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtArrayAccess_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtArrayAccess.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getIndexExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setIndexExpression(castValue(value));
+ }
+ }
+
+ static class CtAssert_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtAssert_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtAssert.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setExpression(castValue(value));
+ }
+ }
+
+ static class CtCase_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtCase_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtCase.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getCaseExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setCaseExpression(castValue(value));
+ }
+ }
+
+ static class CtDo_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtDo_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtDo.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getLoopingExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setLoopingExpression(castValue(value));
+ }
+ }
+
+ static class CtFor_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtFor_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtFor.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public U getValue(T element) {
+ return ((U) ((Object) (castTarget(element).getExpression())));
+ }
+
+ @Override
+ public void setValue(T element, U value) {
+ castTarget(element).setExpression(castValue(value));
+ }
+ }
+
+ static class CtForEach_EXPRESSION_RoleHandler extends SingleHandler> {
+ private CtForEach_EXPRESSION_RoleHandler() {
+ super(CtRole.EXPRESSION, CtForEach.class, CtExpression.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public