Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorbvosburgh2007-05-11 18:23:13 +0000
committerbvosburgh2007-05-11 18:23:13 +0000
commit15aa6e4307c8304539aad970d618ce44e4c29137 (patch)
tree9d84c53706d584e27ae312880d6058438650b2c8 /jpa
parent4503398a30221f09000dc63b4f08f732fd92c1bd (diff)
downloadwebtools.dali-15aa6e4307c8304539aad970d618ce44e4c29137.tar.gz
webtools.dali-15aa6e4307c8304539aad970d618ce44e4c29137.tar.xz
webtools.dali-15aa6e4307c8304539aad970d618ce44e4c29137.zip
New Set
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasicProvider.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTable.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationElementAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/DeclarationAnnotationElementAdapter.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionDeclarationAnnotationElementAdapter.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/FieldAttribute.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MemberAnnotationElementAdapter.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MethodAttribute.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullDeclarationAnnotationElementAdapter.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitAnnotationElementAdapter.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitArrayAnnotationElementAdapter.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Type.java23
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java221
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java4
43 files changed, 451 insertions, 369 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
index ac0f4b46b1..3e7c259f12 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
@@ -537,7 +537,7 @@ public class JpaProject extends JpaEObject implements IJpaProject
for (IJpaFile jpaFile : persistenceFiles) {
JpaCompilationUnit compilationUnit = (JpaCompilationUnit) jpaFile.getContent();
for (JavaPersistentType persistentType : compilationUnit.getTypes()) {
- if (type.equals(persistentType.getType().jdtType())) {
+ if (type.equals(persistentType.getType().getJdtMember())) {
return persistentType;
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
index 822aba10ff..2bc29129c2 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
@@ -51,6 +51,7 @@ import org.eclipse.jpt.core.internal.content.java.mappings.JavaJoinTable;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaManyToMany;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaManyToOne;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaMappedSuperclassProvider;
+import org.eclipse.jpt.core.internal.content.java.mappings.JavaMultiRelationshipMapping;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaNullTypeMappingProvider;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaOneToMany;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaOneToOne;
@@ -228,11 +229,11 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
adapters.add(JavaId.DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaJoinColumn.SINGLE_DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaJoinColumn.MULTIPLE_DECLARATION_ANNOTATION_ADAPTER); // JoinColumns
- adapters.add(JavaJoinTable.DECLARATION_ANNOTATION_ADAPTER);
+ adapters.add(JavaJoinTable.DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaBasic.LOB_ADAPTER);
adapters.add(JavaManyToMany.DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaManyToOne.DECLARATION_ANNOTATION_ADAPTER);
- // TODO ? adapters.add(JavaMultiRelationshipMapping.MAP_KEY_ADAPTER);
+ adapters.add(JavaMultiRelationshipMapping.MAP_KEY_ADAPTER);
adapters.add(JavaOneToMany.DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaOneToOne.DECLARATION_ANNOTATION_ADAPTER);
adapters.add(JavaOrderBy.DECLARATION_ANNOTATION_ADAPTER);
@@ -648,7 +649,7 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
}
public IType jdtType() {
- return getType().jdtType();
+ return getType().getJdtMember();
}
/**
@@ -799,7 +800,7 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
}
public IJpaContentNode contentNodeAt(int offset) {
- ICompilationUnit unit = this.type.jdtType().getCompilationUnit();
+ ICompilationUnit unit = this.type.compilationUnit();
if (unit == null) {
return null;
}
@@ -816,7 +817,7 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
}
switch (javaElement.getElementType()) {
case IJavaElement.TYPE :
- if (((IType) javaElement).getKey().equals(this.type.jdtType().getKey())) {
+ if (((IType) javaElement).getKey().equals(this.type.getJdtMember().getKey())) {
return this;
}
break;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java
index dfb63ebc30..02411a88e3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java
@@ -136,11 +136,11 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery
}
protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, nameElementName());
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, nameElementName());
}
protected DeclarationAnnotationElementAdapter queryAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, queryElementName());
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, queryElementName());
}
protected abstract String nameElementName();
@@ -625,6 +625,6 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery
// ********** static methods **********
protected static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName);
}
} // JavaAbstractQuery
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasicProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasicProvider.java
index 24cefa0a12..e08673bf43 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasicProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasicProvider.java
@@ -53,7 +53,7 @@ public class JavaBasicProvider
}
public boolean defaultApplies(Attribute attribute, DefaultsContext defaultsContext) {
- return signatureIsBasic(attribute.typeSignature(), attribute.getDeclaringType().jdtType());
+ return signatureIsBasic(attribute.typeSignature(), attribute.getDeclaringType().getJdtMember());
}
public IJavaAttributeMapping buildMapping(Attribute attribute) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java
index 2082cb0503..be6fc590c0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java
@@ -404,7 +404,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity
}
private static DeclarationAnnotationElementAdapter buildNameAdapter() {
- return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty
}
/**
@@ -2911,7 +2911,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity
}
private static DeclarationAnnotationElementAdapter buildDiscriminatorValueAdapter() {
- return new ConversionDeclarationAnnotationElementAdapter(DISCRIMINATOR_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DISCRIMINATOR_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE);
}
// ********** static methods **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java
index e76d6e55cd..c270591ba3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java
@@ -338,6 +338,6 @@ public class JavaGeneratedValue extends JavaEObject implements IGeneratedValue
}
private static DeclarationAnnotationElementAdapter buildGeneratorAdapter() {
- return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false);
}
} // JavaGeneratedValue
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java
index a91470905a..700eb06e7b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java
@@ -560,7 +560,7 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator
// ********** static methods **********
protected static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName);
}
protected static DeclarationAnnotationElementAdapter buildNumberAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java
index cf2921820f..c71b6e2f00 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java
@@ -87,11 +87,11 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.JOIN_TABLE);
- private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__NAME);
+ private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__NAME);
- private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__SCHEMA);
+ private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__SCHEMA);
- private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__CATALOG);
+ private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__CATALOG);
protected JavaJoinTable() {
super();
@@ -106,19 +106,19 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable
// ********** AbstractJavaTable implementation **********
@Override
- protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> nameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @JoinTable is never nested
return NAME_ADAPTER;
}
@Override
- protected DeclarationAnnotationElementAdapter schemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> schemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @JoinTable is never nested
return SCHEMA_ADAPTER;
}
@Override
- protected DeclarationAnnotationElementAdapter catalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> catalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @JoinTable is never nested
return CATALOG_ADAPTER;
}
@@ -149,6 +149,7 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable
}
}
+ @SuppressWarnings("unchecked")
void specifiedJoinColumnsChanged(Notification notification) {
switch (notification.getEventType()) {
case Notification.ADD :
@@ -185,6 +186,7 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable
}
}
+ @SuppressWarnings("unchecked")
void specifiedInverseJoinColumnsChanged(Notification notification) {
switch (notification.getEventType()) {
case Notification.ADD :
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
index b84f0cc9bd..911216fa02 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
@@ -25,7 +25,6 @@ import org.eclipse.jpt.core.internal.jdtutility.Attribute;
import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.jdtutility.EnumDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter;
import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter;
@@ -71,7 +70,7 @@ public abstract class JavaMultiRelationshipMapping
*/
protected String mappedBy = MAPPED_BY_EDEFAULT;
- private final AnnotationElementAdapter mappedByAdapter;
+ private final AnnotationElementAdapter<String> mappedByAdapter;
/**
* The default value of the '{@link #getFetch() <em>Fetch</em>}' attribute.
@@ -135,11 +134,11 @@ public abstract class JavaMultiRelationshipMapping
private final AnnotationAdapter mapKeyAnnotationAdapter;
- private final AnnotationElementAdapter mapKeyNameAdapter;
+ private final AnnotationElementAdapter<String> mapKeyNameAdapter;
public static final DeclarationAnnotationAdapter MAP_KEY_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.MAP_KEY);
- private static final DeclarationAnnotationElementAdapter MAP_KEY_NAME_ADAPTER = buildMapKeyNameAdapter();
+ private static final DeclarationAnnotationElementAdapter<String> MAP_KEY_NAME_ADAPTER = buildMapKeyNameAdapter();
protected JavaMultiRelationshipMapping() {
throw new UnsupportedOperationException("Use JavaMultiRelationshipMapping(Attribute) instead");
@@ -149,7 +148,7 @@ public abstract class JavaMultiRelationshipMapping
super(attribute);
this.mappedByAdapter = this.buildAnnotationElementAdapter(this.mappedByAdapter());
this.mapKeyAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), MAP_KEY_ADAPTER);
- this.mapKeyNameAdapter = new ShortCircuitAnnotationElementAdapter(attribute, MAP_KEY_NAME_ADAPTER);
+ this.mapKeyNameAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, MAP_KEY_NAME_ADAPTER);
this.joinTable = JpaJavaMappingsFactory.eINSTANCE.createJavaJoinTable(buildOwner(), attribute);
((InternalEObject) this.joinTable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_MULTI_RELATIONSHIP_MAPPING__JOIN_TABLE, null, null);
this.orderBy = JpaJavaMappingsFactory.eINSTANCE.createJavaOrderBy(attribute);
@@ -161,12 +160,12 @@ public abstract class JavaMultiRelationshipMapping
super.notifyChanged(notification);
switch (notification.getFeatureID(IMultiRelationshipMapping.class)) {
case JpaCoreMappingsPackage.IMULTI_RELATIONSHIP_MAPPING__MAP_KEY :
- String mapKey = (String) notification.getNewValue();
- if (mapKey == null) {
+ String mk = (String) notification.getNewValue();
+ if (mk == null) {
this.mapKeyAnnotationAdapter.removeAnnotation();
}
else {
- this.mapKeyNameAdapter.setValue(mapKey);
+ this.mapKeyNameAdapter.setValue(mk);
}
break;
case JpaCoreMappingsPackage.IMULTI_RELATIONSHIP_MAPPING__FETCH :
@@ -177,7 +176,7 @@ public abstract class JavaMultiRelationshipMapping
}
switch (notification.getFeatureID(INonOwningMapping.class)) {
case JpaCoreMappingsPackage.INON_OWNING_MAPPING__MAPPED_BY :
- this.mappedByAdapter.setValue(notification.getNewValue());
+ this.mappedByAdapter.setValue((String) notification.getNewValue());
break;
default :
break;
@@ -199,7 +198,7 @@ public abstract class JavaMultiRelationshipMapping
/**
* return the Java adapter's 'mappedBy' element adapter config
*/
- protected abstract DeclarationAnnotationElementAdapter mappedByAdapter();
+ protected abstract DeclarationAnnotationElementAdapter<String> mappedByAdapter();
/**
* <!-- begin-user-doc -->
@@ -576,7 +575,7 @@ public abstract class JavaMultiRelationshipMapping
@Override
public void updateFromJava(CompilationUnit astRoot) {
super.updateFromJava(astRoot);
- setMappedBy((String) this.mappedByAdapter.getValue(astRoot));
+ setMappedBy(this.mappedByAdapter.getValue(astRoot));
this.getJavaOrderBy().updateFromJava(astRoot);
this.getJavaJoinTable().updateFromJava(astRoot);
updateMapKeyFromJava(astRoot);
@@ -587,7 +586,7 @@ public abstract class JavaMultiRelationshipMapping
this.setMapKey(null);
}
else {
- this.setMapKey((String) this.mapKeyNameAdapter.getValue(astRoot));
+ this.setMapKey(this.mapKeyNameAdapter.getValue(astRoot));
}
}
@@ -604,6 +603,10 @@ public abstract class JavaMultiRelationshipMapping
setFetch(DefaultLazyFetchType.fromJavaAnnotationValue(this.getFetchAdapter().getValue(astRoot)));
}
+ public boolean mappedByTouches(int pos, CompilationUnit astRoot) {
+ return this.elementTouches(this.mappedByAdapter(), pos, astRoot);
+ }
+
@Override
public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) {
Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot);
@@ -614,6 +617,9 @@ public abstract class JavaMultiRelationshipMapping
if (result != null) {
return result;
}
+ if (this.mappedByTouches(pos, astRoot)) {
+ return this.quotedCandidateMappedByAttributeNames(filter);
+ }
return null;
}
@@ -640,7 +646,7 @@ public abstract class JavaMultiRelationshipMapping
}
// ********** static methods **********
- private static DeclarationAnnotationElementAdapter buildMapKeyNameAdapter() {
- return new ConversionDeclarationAnnotationElementAdapter(MAP_KEY_ADAPTER, JPA.MAP_KEY__NAME, false);
+ private static DeclarationAnnotationElementAdapter<String> buildMapKeyNameAdapter() {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(MAP_KEY_ADAPTER, JPA.MAP_KEY__NAME, false);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java
index f0cf1d9c3e..c25a4dffd6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java
@@ -13,7 +13,9 @@ import java.util.Iterator;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.jdt.core.dom.BooleanLiteral;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.NumberLiteral;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.content.java.JavaEObject;
import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter;
@@ -124,11 +126,11 @@ public abstract class JavaNamedColumn extends JavaEObject
private final DeclarationAnnotationAdapter daa;
// hold this so we can get the 'name' text range
- private final DeclarationAnnotationElementAdapter nameDeclarationAdapter;
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
- private final AnnotationElementAdapter nameAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
- private final AnnotationElementAdapter columnDefinitionAdapter;
+ private final AnnotationElementAdapter<String> columnDefinitionAdapter;
protected JavaNamedColumn() {
super();
@@ -145,27 +147,27 @@ public abstract class JavaNamedColumn extends JavaEObject
this.columnDefinitionAdapter = this.buildShortCircuitStringElementAdapter(this.columnDefinitionElementName());
}
- protected DeclarationAnnotationElementAdapter buildStringElementAdapter(String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName);
+ protected DeclarationAnnotationElementAdapter<String> buildStringElementAdapter(String elementName) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName);
}
- protected DeclarationAnnotationElementAdapter buildBooleanElementAdapter(String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, BooleanStringExpressionConverter.instance());
+ protected DeclarationAnnotationElementAdapter<String> buildBooleanElementAdapter(String elementName) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(this.daa, elementName, BooleanStringExpressionConverter.instance());
}
- protected DeclarationAnnotationElementAdapter buildIntElementAdapter(String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, NumberStringExpressionConverter.instance());
+ protected DeclarationAnnotationElementAdapter<String> buildIntElementAdapter(String elementName) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, NumberLiteral>(this.daa, elementName, NumberStringExpressionConverter.instance());
}
- protected AnnotationElementAdapter buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter daea) {
- return new ShortCircuitAnnotationElementAdapter(this.member, daea);
+ protected AnnotationElementAdapter<String> buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
}
- protected AnnotationElementAdapter buildShortCircuitStringElementAdapter(String elementName) {
+ protected AnnotationElementAdapter<String> buildShortCircuitStringElementAdapter(String elementName) {
return this.buildShortCircuitElementAdapter(this.buildStringElementAdapter(elementName));
}
- protected AnnotationElementAdapter buildShortCircuitBooleanElementAdapter(String elementName) {
+ protected AnnotationElementAdapter<String> buildShortCircuitBooleanElementAdapter(String elementName) {
return this.buildShortCircuitElementAdapter(this.buildBooleanElementAdapter(elementName));
}
@@ -182,10 +184,10 @@ public abstract class JavaNamedColumn extends JavaEObject
super.notifyChanged(notification);
switch (notification.getFeatureID(INamedColumn.class)) {
case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_NAME :
- this.nameAdapter.setValue(notification.getNewValue());
+ this.nameAdapter.setValue((String) notification.getNewValue());
break;
case JpaJavaMappingsPackage.JAVA_COLUMN__COLUMN_DEFINITION :
- this.columnDefinitionAdapter.setValue(notification.getNewValue());
+ this.columnDefinitionAdapter.setValue((String) notification.getNewValue());
break;
default :
break;
@@ -452,11 +454,11 @@ public abstract class JavaNamedColumn extends JavaEObject
return (textRange != null) ? textRange : this.owner.getTextRange();
}
- protected ITextRange elementTextRange(DeclarationAnnotationElementAdapter elementAdapter) {
+ protected ITextRange elementTextRange(DeclarationAnnotationElementAdapter<?> elementAdapter) {
return this.elementTextRange(this.member.annotationElementTextRange(elementAdapter));
}
- protected ITextRange elementTextRange(DeclarationAnnotationElementAdapter elementAdapter, CompilationUnit astRoot) {
+ protected ITextRange elementTextRange(DeclarationAnnotationElementAdapter<?> elementAdapter, CompilationUnit astRoot) {
return this.elementTextRange(this.member.annotationElementTextRange(elementAdapter, astRoot));
}
@@ -472,13 +474,13 @@ public abstract class JavaNamedColumn extends JavaEObject
return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot);
}
- protected boolean elementTouches(DeclarationAnnotationElementAdapter elementAdapter, int pos, CompilationUnit astRoot) {
+ protected boolean elementTouches(DeclarationAnnotationElementAdapter<?> elementAdapter, int pos, CompilationUnit astRoot) {
return this.elementTouches(this.member.annotationElementTextRange(elementAdapter, astRoot), pos);
}
public void updateFromJava(CompilationUnit astRoot) {
- this.setSpecifiedName((String) this.nameAdapter.getValue(astRoot));
- this.setColumnDefinition((String) this.columnDefinitionAdapter.getValue(astRoot));
+ this.setSpecifiedName(this.nameAdapter.getValue(astRoot));
+ this.setColumnDefinition(this.columnDefinitionAdapter.getValue(astRoot));
}
public boolean isConnected() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java
index cbef2c8468..fd2161bae3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java
@@ -97,11 +97,11 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery
// ********** initialization **********
protected DeclarationAnnotationElementAdapter resultClassAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS);
}
protected DeclarationAnnotationElementAdapter resultSetMappingAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java
index 4d8828ae4e..1f99b9b8e8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java
@@ -432,6 +432,6 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy
// ********** static methods **********
private static DeclarationAnnotationElementAdapter buildValueAdapter() {
- return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false);
}
} // JavaOrderBy
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java
index 00e36db785..1163728e49 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java
@@ -83,7 +83,7 @@ public abstract class JavaOverride extends JavaEObject implements IOverride
protected abstract String nameElementName();
private AnnotationElementAdapter buildAdapter(String elementName) {
- return new ShortCircuitAnnotationElementAdapter(this.member, new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName));
+ return new ShortCircuitAnnotationElementAdapter(this.member, ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName));
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java
index a20bcd5c14..1065816b3c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java
@@ -111,11 +111,11 @@ public class JavaQueryHint extends JavaEObject implements IQueryHint
}
protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.QUERY_HINT__NAME);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__NAME);
}
protected DeclarationAnnotationElementAdapter valueAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.QUERY_HINT__VALUE);
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__VALUE);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
index 958583787a..b109a0c622 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jpt.core.internal.IPersistentAttribute;
import org.eclipse.jpt.core.internal.IPersistentType;
import org.eclipse.jpt.core.internal.ITypeMapping;
@@ -38,7 +39,10 @@ import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage;
import org.eclipse.jpt.core.internal.mappings.RelationshipMappingTools;
import org.eclipse.jpt.core.internal.platform.DefaultsContext;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.Filter;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
@@ -54,7 +58,7 @@ import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
public abstract class JavaRelationshipMapping extends JavaAttributeMapping
implements IRelationshipMapping
{
- private AnnotationElementAdapter targetEntityAdapter;
+ private AnnotationElementAdapter<String> targetEntityAdapter;
// private AnnotationElementAdapter cascadeAdapter;
/**
@@ -62,7 +66,7 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
* but the 1:1 and m:1 mappings have a default of EAGER,
* while the 1:m and m:m mappings have a default of LAZY
*/
- private AnnotationElementAdapter fetchAdapter;
+ private AnnotationElementAdapter<String> fetchAdapter;
/**
* The default value of the '{@link #getTargetEntity() <em>Target Entity</em>}' attribute.
@@ -135,14 +139,14 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
this.fetchAdapter = this.buildAnnotationElementAdapter(this.fetchAdapter());
}
- protected AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) {
- return new ShortCircuitAnnotationElementAdapter(this.getAttribute(), daea);
+ protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.getAttribute(), daea);
}
/**
* return the Java adapter's 'targetEntity' element adapter config
*/
- protected abstract DeclarationAnnotationElementAdapter targetEntityAdapter();
+ protected abstract DeclarationAnnotationElementAdapter<String> targetEntityAdapter();
/**
* return the Java adapter's 'cascade' element adapter config
@@ -151,7 +155,7 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
/**
* return the Java adapter's 'fetch' element adapter config
*/
- protected abstract DeclarationAnnotationElementAdapter fetchAdapter();
+ protected abstract DeclarationAnnotationElementAdapter<String> fetchAdapter();
/**
* <!-- begin-user-doc -->
@@ -444,7 +448,7 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
public void updateFromJava(CompilationUnit astRoot) {
super.updateFromJava(astRoot);
setDefaultTargetEntity(this.javaDefaultTargetEntity());
- setSpecifiedTargetEntity((String) this.targetEntityAdapter.getValue(astRoot));
+ setSpecifiedTargetEntity(this.targetEntityAdapter.getValue(astRoot));
//setCascade(CascadeType.fromJavaAnnotationValue(this.cascadeAdapter.getValue(astRoot)));
this.updateFetchFromJava(astRoot);
}
@@ -500,38 +504,51 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
setResolvedTargetEntity(null);
}
- public Iterator<String> possibleMappedByAttributeNames() {
- IEntity targetEntity = getResolvedTargetEntity();
- if (targetEntity == null) {
- return EmptyIterator.instance();
- }
- return new TransformationIterator<IPersistentAttribute, String>(targetEntity.getPersistentType().attributes()) {
+ public Iterator<String> candidateMappedByAttributeNames() {
+ IEntity targetEntity = this.getResolvedTargetEntity();
+ return (targetEntity == null) ?
+ EmptyIterator.<String>instance()
+ :
+ this.attributeNames(targetEntity.getPersistentType().attributes());
+ }
+
+ private Iterator<String> attributeNames(Iterator<IPersistentAttribute> attributes) {
+ return new TransformationIterator<IPersistentAttribute, String>(attributes) {
+ @Override
protected String transform(IPersistentAttribute attribute) {
return attribute.getName();
}
};
}
+ protected Iterator<String> candidateMappedByAttributeNames(Filter<String> filter) {
+ return new FilteringIterator<String>(this.candidateMappedByAttributeNames(), filter);
+ }
+
+ protected Iterator<String> quotedCandidateMappedByAttributeNames(Filter<String> filter) {
+ return StringTools.quote(this.candidateMappedByAttributeNames(filter));
+ }
+
// ********** convenience methods **********
- protected AnnotationElementAdapter getFetchAdapter() {
+ protected AnnotationElementAdapter<String> getFetchAdapter() {
return this.fetchAdapter;
}
// ********** static methods **********
- protected static DeclarationAnnotationElementAdapter buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
+ protected static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
// TODO what about QualifiedType?
return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance());
}
- protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
+ protected static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
return buildAnnotationElementAdapter(annotationAdapter, elementName, StringExpressionConverter.instance());
}
- protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<?, String> converter) {
- return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter);
+ protected static <T extends Expression> DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String, T> converter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, T>(annotationAdapter, elementName, false, converter);
}
- protected static DeclarationAnnotationElementAdapter buildEnumAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
+ protected static DeclarationAnnotationElementAdapter<String> buildEnumAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
return new EnumDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java
index 6b24a37507..52e3c6595f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java
@@ -99,6 +99,7 @@ public class JavaSecondaryTable extends AbstractJavaTable
}
}
+ @SuppressWarnings("unchecked")
void specifiedPKJoinColumnsChanged(Notification notification) {
switch (notification.getEventType()) {
case Notification.ADD :
@@ -394,18 +395,18 @@ public class JavaSecondaryTable extends AbstractJavaTable
// ********** AbstractJavaTable implementation **********
@Override
- protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.SECONDARY_TABLE__NAME);
+ protected DeclarationAnnotationElementAdapter<String> nameAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.SECONDARY_TABLE__NAME);
}
@Override
- protected DeclarationAnnotationElementAdapter schemaAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.SECONDARY_TABLE__SCHEMA);
+ protected DeclarationAnnotationElementAdapter<String> schemaAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.SECONDARY_TABLE__SCHEMA);
}
@Override
- protected DeclarationAnnotationElementAdapter catalogAdapter(DeclarationAnnotationAdapter daa) {
- return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.SECONDARY_TABLE__CATALOG);
+ protected DeclarationAnnotationElementAdapter<String> catalogAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.SECONDARY_TABLE__CATALOG);
}
public IPrimaryKeyJoinColumn createPrimaryKeyJoinColumn(int index) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTable.java
index 5a53095514..6db2416d94 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTable.java
@@ -32,11 +32,11 @@ public class JavaTable extends AbstractJavaTable
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.TABLE);
- private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME);
+ private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME);
- private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA);
+ private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA);
- private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__CATALOG);
+ private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__CATALOG);
protected JavaTable() {
super();
@@ -48,19 +48,19 @@ public class JavaTable extends AbstractJavaTable
}
@Override
- protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> nameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @Table is never nested
return NAME_ADAPTER;
}
@Override
- protected DeclarationAnnotationElementAdapter schemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> schemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @Table is never nested
return SCHEMA_ADAPTER;
}
@Override
- protected DeclarationAnnotationElementAdapter catalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
+ protected DeclarationAnnotationElementAdapter<String> catalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) {
// ignore the daa passed in, @Table is never nested
return CATALOG_ADAPTER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java
index f8054edfcd..c299099d36 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java
@@ -15,18 +15,18 @@ import org.eclipse.jpt.utility.internal.StringTools;
/**
* Gather together just the tiniest bit of common behavior.
- * T1 is the expression type, while T2 is the type of object the expression
- * is convert to/from.
+ * E is the expression type.
+ * T is the type of the object to be converted to and from an expression.
*/
-public abstract class AbstractExpressionConverter<T1 extends Expression, T2>
- implements ExpressionConverter<T1, T2>
+public abstract class AbstractExpressionConverter<T, E extends Expression>
+ implements ExpressionConverter<T, E>
{
protected AbstractExpressionConverter() {
super();
}
- public T1 convert(T2 object, AST ast) {
+ public E convert(T object, AST ast) {
return (object == null) ? null : this.convert_(object, ast);
}
@@ -34,9 +34,9 @@ public abstract class AbstractExpressionConverter<T1 extends Expression, T2>
* The specified object is not null.
* @see #convert(T, AST)
*/
- protected abstract T1 convert_(T2 object, AST ast);
+ protected abstract E convert_(T object, AST ast);
- public T2 convert(T1 expression) {
+ public T convert(E expression) {
return (expression == null) ? null : this.convert_(expression);
}
@@ -44,7 +44,7 @@ public abstract class AbstractExpressionConverter<T1 extends Expression, T2>
* The specified expression is not null.
* @see #convert(Expression)
*/
- protected abstract T2 convert_(T1 expression);
+ protected abstract T convert_(E expression);
@Override
public String toString() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationElementAdapter.java
index 7b9d67a41d..5e25607ab3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationElementAdapter.java
@@ -16,7 +16,7 @@ import org.eclipse.jdt.core.dom.Expression;
/**
* Adapt a Java annotation element with a simple-to-use interface.
*/
-public interface AnnotationElementAdapter {
+public interface AnnotationElementAdapter<T> {
/**
* Return the value of the adapter's annotation element.
@@ -25,7 +25,7 @@ public interface AnnotationElementAdapter {
* might be more performant.
* @see #getValue(org.eclipse.jdt.core.dom.CompilationUnit)
*/
- Object getValue();
+ T getValue();
/**
* Given the specified compilation unit, return the value of the
@@ -33,14 +33,14 @@ public interface AnnotationElementAdapter {
* Return null if the element is not present.
* @see #getValue()
*/
- Object getValue(CompilationUnit astRoot);
+ T getValue(CompilationUnit astRoot);
/**
* Set the value of the adapter's annotation element.
* Setting the value of the element to null will cause
* the element to be removed from its annotation.
*/
- void setValue(Object value);
+ void setValue(T value);
/**
* Return the expression value of the adapter's annotation element.
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java
index 2b96c13df7..0f5854e5d6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java
@@ -18,14 +18,14 @@ import org.eclipse.jdt.core.dom.BooleanLiteral;
* (e.g. "true").
*/
public final class BooleanStringExpressionConverter
- extends AbstractExpressionConverter<BooleanLiteral, String>
+ extends AbstractExpressionConverter<String, BooleanLiteral>
{
- private static ExpressionConverter<BooleanLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, BooleanLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<BooleanLiteral, String> instance() {
+ public static ExpressionConverter<String, BooleanLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new BooleanStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java
index bdbc5fbf18..1fa055d707 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java
@@ -18,14 +18,14 @@ import org.eclipse.jdt.core.dom.CharacterLiteral;
* (e.g. "A").
*/
public final class CharacterStringExpressionConverter
- extends AbstractExpressionConverter<CharacterLiteral, String>
+ extends AbstractExpressionConverter<String, CharacterLiteral>
{
- private static ExpressionConverter<CharacterLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, CharacterLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<CharacterLiteral, String> instance() {
+ public static ExpressionConverter<String, CharacterLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new CharacterStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java
index 03e65c9097..11ead9d281 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java
@@ -11,25 +11,28 @@ package org.eclipse.jpt.core.internal.jdtutility;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jpt.utility.internal.StringTools;
/**
* Wrap a declaration annotation element adapter that deals with AST
* expressions, converting them to/from various other objects.
+ * T is the type of the object to be passed to and returned by the adapter.
+ * E is the type of the expression to be converted by the converter.
*/
-public class ConversionDeclarationAnnotationElementAdapter
- implements DeclarationAnnotationElementAdapter
+public class ConversionDeclarationAnnotationElementAdapter<T, E extends Expression>
+ implements DeclarationAnnotationElementAdapter<T>
{
/**
* The wrapped adapter that returns and takes AST expressions.
*/
- private final DeclarationAnnotationElementAdapter adapter;
+ private final DeclarationAnnotationElementAdapter<E> adapter;
/**
* The converter that converts AST expressions to other objects
* (e.g. Strings).
*/
- private final ExpressionConverter converter;
+ private final ExpressionConverter<T, E> converter;
// ********** constructors **********
@@ -39,16 +42,16 @@ public class ConversionDeclarationAnnotationElementAdapter
* remove the annotation when the last element is removed;
* the default expression converter expects string literals.
*/
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter) {
- this(annotationAdapter, StringExpressionConverter.instance());
+ public static ConversionDeclarationAnnotationElementAdapter<String, StringLiteral> forStrings(DeclarationAnnotationAdapter annotationAdapter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, StringLiteral>(annotationAdapter, StringExpressionConverter.instance());
}
/**
* The default element name is "value"; the default behavior is to
* remove the annotation when the last element is removed.
*/
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, ExpressionConverter converter) {
- this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter), converter);
+ public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, ExpressionConverter<T, E> converter) {
+ this(new ExpressionDeclarationAnnotationElementAdapter<E>(annotationAdapter), converter);
}
/**
@@ -56,30 +59,30 @@ public class ConversionDeclarationAnnotationElementAdapter
* element is removed; the default expression converter expects
* string literals.
*/
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- this(annotationAdapter, elementName, StringExpressionConverter.instance());
+ public static ConversionDeclarationAnnotationElementAdapter<String, StringLiteral> forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, StringLiteral>(annotationAdapter, elementName, StringExpressionConverter.instance());
}
/**
* The default behavior is to remove the annotation when the last
* element is removed.
*/
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) {
- this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName), converter);
+ public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<T, E> converter) {
+ this(new ExpressionDeclarationAnnotationElementAdapter<E>(annotationAdapter, elementName), converter);
}
/**
* The default expression converter expects string literals.
*/
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) {
- this(annotationAdapter, elementName, removeAnnotationWhenEmpty, StringExpressionConverter.instance());
+ public static ConversionDeclarationAnnotationElementAdapter<String, StringLiteral> forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) {
+ return new ConversionDeclarationAnnotationElementAdapter<String, StringLiteral>(annotationAdapter, elementName, removeAnnotationWhenEmpty, StringExpressionConverter.instance());
}
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, ExpressionConverter converter) {
- this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty), converter);
+ public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, ExpressionConverter<T, E> converter) {
+ this(new ExpressionDeclarationAnnotationElementAdapter<E>(annotationAdapter, elementName, removeAnnotationWhenEmpty), converter);
}
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationElementAdapter adapter, ExpressionConverter converter) {
+ public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationElementAdapter<E> adapter, ExpressionConverter<T, E> converter) {
super();
this.adapter = adapter;
this.converter = converter;
@@ -88,11 +91,11 @@ public class ConversionDeclarationAnnotationElementAdapter
// ********** DeclarationAnnotationElementAdapter implementation **********
- public Object getValue(ModifiedDeclaration declaration) {
- return this.converter.convert((Expression) this.adapter.getValue(declaration));
+ public T getValue(ModifiedDeclaration declaration) {
+ return this.converter.convert(this.adapter.getValue(declaration));
}
- public void setValue(Object value, ModifiedDeclaration declaration) {
+ public void setValue(T value, ModifiedDeclaration declaration) {
this.adapter.setValue(this.converter.convert(value, this.adapter.astNode(declaration).getAST()), declaration);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/DeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/DeclarationAnnotationElementAdapter.java
index b5b7e830d5..3d08445111 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/DeclarationAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/DeclarationAnnotationElementAdapter.java
@@ -15,14 +15,15 @@ import org.eclipse.jdt.core.dom.Expression;
/**
* Provide clients with a pluggable way to manipulate an
* annotation element modifying a "declaration".
+ * T is the type of the object to be passed to and returned by the adapter.
*/
-public interface DeclarationAnnotationElementAdapter {
+public interface DeclarationAnnotationElementAdapter<T> {
/**
* Given the specified declaration, return the value of the
* annotation element. Return null if the element is not present.
*/
- Object getValue(ModifiedDeclaration declaration);
+ T getValue(ModifiedDeclaration declaration);
/**
* Given the specified declaration, set the value of the
@@ -30,7 +31,7 @@ public interface DeclarationAnnotationElementAdapter {
* to null will cause the element to be removed from its
* annotation.
*/
- void setValue(Object value, ModifiedDeclaration declaration);
+ void setValue(T value, ModifiedDeclaration declaration);
/**
* Given the specified declaration, return the element's value expression.
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java
index 0727ee2cc5..838860f486 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java
@@ -11,18 +11,19 @@ package org.eclipse.jpt.core.internal.jdtutility;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.Name;
/**
* Wrap a declaration annotation element adapter and simply
* add an import for the enum when necessary.
*/
public class EnumDeclarationAnnotationElementAdapter
- implements DeclarationAnnotationElementAdapter
+ implements DeclarationAnnotationElementAdapter<String>
{
/**
* The wrapped adapter that returns and takes name strings (enums).
*/
- private final ConversionDeclarationAnnotationElementAdapter adapter;
+ private final ConversionDeclarationAnnotationElementAdapter<String, Name> adapter;
// ********** constructors **********
@@ -44,10 +45,10 @@ public class EnumDeclarationAnnotationElementAdapter
}
public EnumDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) {
- this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, NameStringExpressionConverter.instance()));
+ this(new ConversionDeclarationAnnotationElementAdapter<String, Name>(annotationAdapter, elementName, removeAnnotationWhenEmpty, NameStringExpressionConverter.instance()));
}
- protected EnumDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) {
+ protected EnumDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter<String, Name> adapter) {
super();
this.adapter = adapter;
}
@@ -55,11 +56,11 @@ public class EnumDeclarationAnnotationElementAdapter
// ********** DeclarationAnnotationElementAdapter implementation **********
- public Object getValue(ModifiedDeclaration declaration) {
+ public String getValue(ModifiedDeclaration declaration) {
return this.resolve(this.adapter.expression(declaration), declaration);
}
- public void setValue(Object value, ModifiedDeclaration declaration) {
+ public void setValue(String value, ModifiedDeclaration declaration) {
this.adapter.setValue(this.convertToShortName(value, declaration), declaration);
}
@@ -75,7 +76,7 @@ public class EnumDeclarationAnnotationElementAdapter
// ********** internal methods **********
/**
- * resolve the enum's short name
+ * resolve the enum
*/
protected String resolve(Expression enumExpression, ModifiedDeclaration declaration) {
return (enumExpression == null) ? null : JDTTools.resolveEnum(declaration.iCompilationUnit(), enumExpression);
@@ -84,13 +85,12 @@ public class EnumDeclarationAnnotationElementAdapter
/**
* convert the fully-qualified enum to a static import and its short name
*/
- protected String convertToShortName(Object value, ModifiedDeclaration declaration) {
- if (value == null) {
+ protected String convertToShortName(String string, ModifiedDeclaration declaration) {
+ if (string == null) {
return null;
}
- String enum_ = (String) value;
- declaration.addStaticImport(enum_); // e.g. "javax.persistence.FetchType.EAGER"
- return this.shortName(enum_); // e.g. "EAGER"
+ declaration.addStaticImport(string); // e.g. "javax.persistence.FetchType.EAGER"
+ return this.shortName(string); // e.g. "EAGER"
}
protected String shortTypeName(String name) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java
index e7a12876ce..4bce4344d9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java
@@ -14,11 +14,11 @@ import org.eclipse.jdt.core.dom.Expression;
/**
* Define the protocol for converting an AST expression back and forth
- * from an arbitrary type (e.g. Expression <=> String).
- * T1 is the expression type, while T2 is the type of object the expression
- * is convert to/from.
+ * from an arbitrary type (e.g. StringLiteral <=> String).
+ * E is the expression type.
+ * T is the type of the object to be converted to and from an expression.
*/
-public interface ExpressionConverter<T1 extends Expression, T2> {
+public interface ExpressionConverter<T, E extends Expression> {
/**
* Convert the specified object to an
@@ -26,12 +26,12 @@ public interface ExpressionConverter<T1 extends Expression, T2> {
* The type of the object is determined by the
* contract specified by the client.
*/
- T1 convert(T2 object, AST ast);
+ E convert(T object, AST ast);
/**
* Convert the specified expression to an object of some
* pre-determined type.
*/
- T2 convert(T1 expression);
+ T convert(E expression);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionDeclarationAnnotationElementAdapter.java
index 5e26ceb9e0..9f7cd03a5f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionDeclarationAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionDeclarationAnnotationElementAdapter.java
@@ -25,8 +25,8 @@ import org.eclipse.jpt.utility.internal.StringTools;
* Most obvious implementation of the interface.
* Assume the element's value is an Expression.
*/
-public class ExpressionDeclarationAnnotationElementAdapter
- implements DeclarationAnnotationElementAdapter
+public class ExpressionDeclarationAnnotationElementAdapter<E extends Expression>
+ implements DeclarationAnnotationElementAdapter<E>
{
/**
* Adapter used to manipulate the element's annotation.
@@ -81,16 +81,16 @@ public class ExpressionDeclarationAnnotationElementAdapter
// ********** DeclarationAnnotationElementAdapter implementation **********
- public Object getValue(ModifiedDeclaration declaration) {
+ public E getValue(ModifiedDeclaration declaration) {
// return the expression unmodified
return this.expression(declaration);
}
- public void setValue(Object value, ModifiedDeclaration declaration) {
- this.setValue((Expression) value, this.annotationAdapter.getAnnotation(declaration), declaration);
+ public void setValue(E value, ModifiedDeclaration declaration) {
+ this.setValue(value, this.annotationAdapter.getAnnotation(declaration), declaration);
}
- public Expression expression(ModifiedDeclaration declaration) {
+ public E expression(ModifiedDeclaration declaration) {
return this.expression(this.annotationAdapter.getAnnotation(declaration));
}
@@ -114,7 +114,7 @@ public class ExpressionDeclarationAnnotationElementAdapter
* (An element name of "value" will return the value of a single
* member annotation.)
*/
- protected Expression expression(Annotation annotation) {
+ protected E expression(Annotation annotation) {
if (annotation == null) {
return this.expressionNoAnnotation();
}
@@ -130,7 +130,7 @@ public class ExpressionDeclarationAnnotationElementAdapter
throw new IllegalArgumentException("unknown annotation type: " + annotation);
}
- protected Expression expressionNoAnnotation() {
+ protected E expressionNoAnnotation() {
return null;
}
@@ -139,7 +139,7 @@ public class ExpressionDeclarationAnnotationElementAdapter
* with the adapter's element name.
* Return null if the annotation has no such element.
*/
- protected Expression expressionMarkerAnnotation(MarkerAnnotation annotation) {
+ protected E expressionMarkerAnnotation(MarkerAnnotation annotation) {
return null;
}
@@ -148,8 +148,13 @@ public class ExpressionDeclarationAnnotationElementAdapter
* with the adapter's element name.
* Return null if the annotation has no such element.
*/
- protected Expression expressionSingleMemberAnnotation(SingleMemberAnnotation annotation) {
- return this.elementName.equals("value") ? annotation.getValue() : null;
+ protected E expressionSingleMemberAnnotation(SingleMemberAnnotation annotation) {
+ return this.downcast(this.elementName.equals("value") ? annotation.getValue() : null);
+ }
+
+ @SuppressWarnings("unchecked")
+ private E downcast(Expression e) {
+ return (E) e;
}
/**
@@ -157,9 +162,9 @@ public class ExpressionDeclarationAnnotationElementAdapter
* with the adapter's element name.
* Return null if the annotation has no such element.
*/
- protected Expression expressionNormalAnnotation(NormalAnnotation annotation) {
+ protected E expressionNormalAnnotation(NormalAnnotation annotation) {
MemberValuePair pair = this.memberValuePair(annotation);
- return (pair == null) ? null : pair.getValue();
+ return this.downcast((pair == null) ? null : pair.getValue());
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/FieldAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/FieldAttribute.java
index e0b259941a..fe343b4b73 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/FieldAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/FieldAttribute.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.core.internal.jdtutility;
import java.util.List;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
@@ -28,23 +27,21 @@ public class FieldAttribute extends Attribute {
super(field);
}
- public IField jdtField() {
- return (IField) this.getJdtMember();
- }
-
- FieldDeclaration fieldDeclaration() {
- return (FieldDeclaration) this.bodyDeclaration();
+ @Override
+ public IField getJdtMember() {
+ return (IField) super.getJdtMember();
}
- FieldDeclaration fieldDeclaration(CompilationUnit astRoot) {
- return (FieldDeclaration) this.bodyDeclaration(astRoot);
+ @Override
+ public FieldDeclaration bodyDeclaration() {
+ return (FieldDeclaration) super.bodyDeclaration();
}
// ********** Member implementation **********
@Override
- public BodyDeclaration bodyDeclaration(CompilationUnit astRoot) {
+ public FieldDeclaration bodyDeclaration(CompilationUnit astRoot) {
String fieldName = this.getName();
for (FieldDeclaration fieldDeclaration : this.declaringTypeDeclaration(astRoot).getFields()) {
// handle multiple fields declared in a single statement:
@@ -74,7 +71,7 @@ public class FieldAttribute extends Attribute {
@Override
public String typeSignature() {
try {
- return this.jdtField().getTypeSignature();
+ return this.getJdtMember().getTypeSignature();
} catch (JavaModelException ex) {
throw new RuntimeException(ex);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java
index 242b4d03a5..cb0b566ea6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java
@@ -117,7 +117,7 @@ public abstract class Member {
* this will throw a NPE for a top-level type
*/
TypeDeclaration declaringTypeDeclaration(CompilationUnit astRoot) {
- return this.declaringType.typeDeclaration(astRoot);
+ return this.declaringType.bodyDeclaration(astRoot);
}
@Override
@@ -250,27 +250,27 @@ public abstract class Member {
// ********** annotation elements **********
- public Object annotationElementValue(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) {
+ public <T> T annotationElementValue(DeclarationAnnotationElementAdapter<T> adapter, CompilationUnit astRoot) {
return adapter.getValue(this.modifiedDeclaration(astRoot));
}
- public Object annotationElementValue(DeclarationAnnotationElementAdapter adapter) {
+ public <T> T annotationElementValue(DeclarationAnnotationElementAdapter<T> adapter) {
return this.annotationElementValue(adapter, this.astRoot());
}
- public Expression annotationElementExpression(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) {
+ public Expression annotationElementExpression(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
return adapter.expression(this.modifiedDeclaration(astRoot));
}
- public Expression annotationElementExpression(DeclarationAnnotationElementAdapter adapter) {
+ public Expression annotationElementExpression(DeclarationAnnotationElementAdapter<?> adapter) {
return this.annotationElementExpression(adapter, this.astRoot());
}
- public boolean containsAnnotationElement(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) {
+ public boolean containsAnnotationElement(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
return this.annotationElementExpression(adapter, astRoot) != null;
}
- public boolean containsAnnotationElement(DeclarationAnnotationElementAdapter adapter) {
+ public boolean containsAnnotationElement(DeclarationAnnotationElementAdapter<?> adapter) {
return this.containsAnnotationElement(adapter, this.astRoot());
}
@@ -278,7 +278,7 @@ public abstract class Member {
* Return the text range corresponding to the specified element.
* If the element is missing, return null.
*/
- public ITextRange annotationElementTextRange(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) {
+ public ITextRange annotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
return this.textRange(this.annotationElementExpression(adapter, astRoot));
}
@@ -286,7 +286,7 @@ public abstract class Member {
* Return the text range corresponding to the specified element.
* If the element is missing, return null.
*/
- public ITextRange annotationElementTextRange(DeclarationAnnotationElementAdapter adapter) {
+ public ITextRange annotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter) {
return this.annotationElementTextRange(adapter, this.astRoot());
}
@@ -294,7 +294,7 @@ public abstract class Member {
* Return the AST node corresponding to the specified element.
* If the element is missing, return its parent node.
*/
- public ASTNode annotationElementASTNode(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) {
+ public ASTNode annotationElementASTNode(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
return adapter.astNode(this.modifiedDeclaration(astRoot));
}
@@ -302,14 +302,14 @@ public abstract class Member {
* Return the AST node corresponding to the specified element.
* If the element is missing, return its parent node.
*/
- public ASTNode annotationElementASTNode(DeclarationAnnotationElementAdapter adapter) {
+ public ASTNode annotationElementASTNode(DeclarationAnnotationElementAdapter<?> adapter) {
return this.annotationElementASTNode(adapter, this.astRoot());
}
/**
* Set the value of the specified element.
*/
- public void setAnnotationElementValue(final DeclarationAnnotationElementAdapter adapter, final Object value) {
+ public <T> void setAnnotationElementValue(final DeclarationAnnotationElementAdapter<T> adapter, final T value) {
this.edit(new Editor() {
public void edit(ModifiedDeclaration declaration) {
adapter.setValue(value, declaration);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MemberAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MemberAnnotationElementAdapter.java
index 10b67729d7..7c4d725480 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MemberAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MemberAnnotationElementAdapter.java
@@ -17,16 +17,16 @@ import org.eclipse.jpt.utility.internal.StringTools;
/**
* Adapt a member and a declaration annotation element adapter.
*/
-public class MemberAnnotationElementAdapter
- implements AnnotationElementAdapter
+public class MemberAnnotationElementAdapter<T>
+ implements AnnotationElementAdapter<T>
{
private final Member member;
- private final DeclarationAnnotationElementAdapter daea;
+ private final DeclarationAnnotationElementAdapter<T> daea;
// ********** constructor **********
- public MemberAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter daea) {
+ public MemberAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter<T> daea) {
super();
this.member = member;
this.daea = daea;
@@ -35,15 +35,15 @@ public class MemberAnnotationElementAdapter
// ********** AnnotationElementAdapter implementation **********
- public Object getValue() {
+ public T getValue() {
return this.daea.getValue(this.member.modifiedDeclaration());
}
- public Object getValue(CompilationUnit astRoot) {
+ public T getValue(CompilationUnit astRoot) {
return this.daea.getValue(this.member.modifiedDeclaration(astRoot));
}
- public void setValue(Object value) {
+ public void setValue(T value) {
this.edit(this.buildSetValueEditor(value));
}
@@ -75,18 +75,18 @@ public class MemberAnnotationElementAdapter
this.member.edit(editor);
}
- protected Member.Editor buildSetValueEditor(Object value) {
- return new SetValueEditor(value, this.daea);
+ protected Member.Editor buildSetValueEditor(T value) {
+ return new SetValueEditor<T>(value, this.daea);
}
// ********** member classes **********
- protected static class SetValueEditor implements Member.Editor {
- private final DeclarationAnnotationElementAdapter daea;
- private final Object value;
+ protected static class SetValueEditor<T> implements Member.Editor {
+ private final DeclarationAnnotationElementAdapter<T> daea;
+ private final T value;
- SetValueEditor(Object value, DeclarationAnnotationElementAdapter daea) {
+ SetValueEditor(T value, DeclarationAnnotationElementAdapter<T> daea) {
super();
this.value = value;
this.daea = daea;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MethodAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MethodAttribute.java
index e343550c8f..b32979892d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MethodAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/MethodAttribute.java
@@ -12,7 +12,6 @@ package org.eclipse.jpt.core.internal.jdtutility;
import java.beans.Introspector;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
@@ -35,23 +34,21 @@ public class MethodAttribute extends Attribute {
super(getMethod);
}
- public IMethod jdtMethod() {
- return (IMethod) this.getJdtMember();
- }
-
- MethodDeclaration methodDeclaration() {
- return (MethodDeclaration) this.bodyDeclaration();
+ @Override
+ public IMethod getJdtMember() {
+ return (IMethod) super.getJdtMember();
}
- MethodDeclaration methodDeclaration(CompilationUnit astRoot) {
- return (MethodDeclaration) this.bodyDeclaration(astRoot);
+ @Override
+ public MethodDeclaration bodyDeclaration() {
+ return (MethodDeclaration) super.bodyDeclaration();
}
// ********** Member implementation **********
@Override
- public BodyDeclaration bodyDeclaration(CompilationUnit astRoot) {
+ public MethodDeclaration bodyDeclaration(CompilationUnit astRoot) {
String methodName = this.getName();
for (MethodDeclaration methodDeclaration : this.declaringTypeDeclaration(astRoot).getMethods()) {
if (methodDeclaration.getName().getFullyQualifiedName().equals(methodName)
@@ -88,7 +85,7 @@ public class MethodAttribute extends Attribute {
@Override
public String typeSignature() {
try {
- return this.jdtMethod().getReturnType();
+ return this.getJdtMember().getReturnType();
} catch (JavaModelException ex) {
throw new RuntimeException(ex);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java
index 8e37284d94..078835e845 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java
@@ -18,14 +18,14 @@ import org.eclipse.jdt.core.dom.Name;
* (e.g. "com.xxx.Foo.VALUE1" or "value").
*/
public final class NameStringExpressionConverter
- extends AbstractExpressionConverter<Name, String>
+ extends AbstractExpressionConverter<String, Name>
{
- private static ExpressionConverter<Name, String> INSTANCE;
+ private static ExpressionConverter<String, Name> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<Name, String> instance() {
+ public static ExpressionConverter<String, Name> instance() {
if (INSTANCE == null) {
INSTANCE = new NameStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullDeclarationAnnotationElementAdapter.java
index 7a3c82fd20..e0853b9faa 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullDeclarationAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullDeclarationAnnotationElementAdapter.java
@@ -15,30 +15,35 @@ import org.eclipse.jdt.core.dom.Expression;
/**
* Behaviorless implementation.
*/
-public class NullDeclarationAnnotationElementAdapter implements DeclarationAnnotationElementAdapter {
+public class NullDeclarationAnnotationElementAdapter<T>
+ implements DeclarationAnnotationElementAdapter<T>
+{
// singleton
- private static final NullDeclarationAnnotationElementAdapter INSTANCE = new NullDeclarationAnnotationElementAdapter();
+ @SuppressWarnings("unchecked")
+ private static final DeclarationAnnotationElementAdapter INSTANCE
+ = new NullDeclarationAnnotationElementAdapter();
/**
* Return the singleton.
*/
- public static DeclarationAnnotationElementAdapter instance() {
+ @SuppressWarnings("unchecked")
+ public static <S> DeclarationAnnotationElementAdapter<S> instance() {
return INSTANCE;
}
/**
- * Ensure non-instantiability.
+ * Ensure single instance.
*/
private NullDeclarationAnnotationElementAdapter() {
super();
}
- public Object getValue(ModifiedDeclaration declaration) {
+ public T getValue(ModifiedDeclaration declaration) {
return null;
}
- public void setValue(Object value, ModifiedDeclaration declaration) {
+ public void setValue(T value, ModifiedDeclaration declaration) {
// do nothing
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java
index a643c17c10..0b312fb720 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java
@@ -18,14 +18,14 @@ import org.eclipse.jdt.core.dom.NumberLiteral;
* (e.g. "48").
*/
public final class NumberStringExpressionConverter
- extends AbstractExpressionConverter<NumberLiteral, String>
+ extends AbstractExpressionConverter<String, NumberLiteral>
{
- private static ExpressionConverter<NumberLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, NumberLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<NumberLiteral, String> instance() {
+ public static ExpressionConverter<String, NumberLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new NumberStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java
index 3d1dfd521a..49f6d99166 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java
@@ -19,14 +19,14 @@ import org.eclipse.jdt.core.dom.TypeLiteral;
* (e.g. "int").
*/
public final class PrimitiveTypeStringExpressionConverter
- extends AbstractExpressionConverter<TypeLiteral, String>
+ extends AbstractExpressionConverter<String, TypeLiteral>
{
- private static ExpressionConverter<TypeLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, TypeLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<TypeLiteral, String> instance() {
+ public static ExpressionConverter<String, TypeLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new PrimitiveTypeStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitAnnotationElementAdapter.java
index b9375e846f..2ffcb36d71 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitAnnotationElementAdapter.java
@@ -18,20 +18,20 @@ import org.eclipse.jpt.utility.internal.StringTools;
* Wrap another annotation element adapter and short-circuit the
* #setValue method if the value has not changed.
*/
-public class ShortCircuitAnnotationElementAdapter
- implements AnnotationElementAdapter
+public class ShortCircuitAnnotationElementAdapter<T>
+ implements AnnotationElementAdapter<T>
{
/** the wrapped adapter */
- private final AnnotationElementAdapter adapter;
+ private final AnnotationElementAdapter<T> adapter;
// ********** constructor **********
- public ShortCircuitAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter daea) {
- this(new MemberAnnotationElementAdapter(member, daea));
+ public ShortCircuitAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter<T> daea) {
+ this(new MemberAnnotationElementAdapter<T>(member, daea));
}
- public ShortCircuitAnnotationElementAdapter(AnnotationElementAdapter adapter) {
+ public ShortCircuitAnnotationElementAdapter(AnnotationElementAdapter<T> adapter) {
super();
this.adapter = adapter;
}
@@ -39,15 +39,15 @@ public class ShortCircuitAnnotationElementAdapter
// ********** AnnotationElementAdapter implementation **********
- public Object getValue() {
+ public T getValue() {
return this.adapter.getValue();
}
- public Object getValue(CompilationUnit astRoot) {
+ public T getValue(CompilationUnit astRoot) {
return this.adapter.getValue(astRoot);
}
- public void setValue(Object value) {
+ public void setValue(T value) {
this.setValue(this.adapter.getValue(), value);
}
@@ -79,7 +79,7 @@ public class ShortCircuitAnnotationElementAdapter
* set the adapter's value to the specified new value if it
* is different from the specified old value
*/
- protected void setValue(Object oldValue, Object newValue) {
+ protected void setValue(T oldValue, T newValue) {
if (oldValue == null) {
if (newValue == null) { // null => null
// do nothing
@@ -102,7 +102,7 @@ public class ShortCircuitAnnotationElementAdapter
/**
* both values are non-null when this method is called
*/
- protected boolean valuesAreEqual(Object oldValue, Object newValue) {
+ protected boolean valuesAreEqual(T oldValue, T newValue) {
return newValue.equals(oldValue);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitArrayAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitArrayAnnotationElementAdapter.java
index fa5da02bc9..9bead7a287 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitArrayAnnotationElementAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ShortCircuitArrayAnnotationElementAdapter.java
@@ -13,19 +13,19 @@ import java.util.Arrays;
/**
* Wrap another annotation element adapter and short-circuit the
- * #setValue method if the value has not changed. Overrides valuesAreEqual
+ * #setValue method if the value has not changed. Overrides #valuesAreEqual()
* to check equality on arrays
*/
-public class ShortCircuitArrayAnnotationElementAdapter
- extends ShortCircuitAnnotationElementAdapter
+public class ShortCircuitArrayAnnotationElementAdapter<T>
+ extends ShortCircuitAnnotationElementAdapter<T[]>
{
// ********** constructor **********
- public ShortCircuitArrayAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter daea) {
+ public ShortCircuitArrayAnnotationElementAdapter(Member member, DeclarationAnnotationElementAdapter<T[]> daea) {
super(member, daea);
}
- public ShortCircuitArrayAnnotationElementAdapter(AnnotationElementAdapter adapter) {
+ public ShortCircuitArrayAnnotationElementAdapter(AnnotationElementAdapter<T[]> adapter) {
super(adapter);
}
@@ -33,11 +33,8 @@ public class ShortCircuitArrayAnnotationElementAdapter
// ********** AnnotationElementAdapter implementation **********
@Override
- protected boolean valuesAreEqual(Object oldValue, Object newValue) {
- Object[] oldValueArray = (Object[]) oldValue;
- Object[] newValueArray = (Object[]) newValue;
-
- return Arrays.equals(newValueArray, oldValueArray);
+ protected boolean valuesAreEqual(T[] oldValue, T[] newValue) {
+ return Arrays.equals(newValue, oldValue);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java
index 45747d9275..43566cb864 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java
@@ -20,14 +20,14 @@ import org.eclipse.jdt.core.dom.TypeLiteral;
* (e.g. "java.lang.Object").
*/
public final class SimpleTypeStringExpressionConverter
- extends AbstractExpressionConverter<TypeLiteral, String>
+ extends AbstractExpressionConverter<String, TypeLiteral>
{
- private static ExpressionConverter<TypeLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, TypeLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<TypeLiteral, String> instance() {
+ public static ExpressionConverter<String, TypeLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new SimpleTypeStringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java
index cf653cd2e3..08f9fe1b08 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java
@@ -20,30 +20,33 @@ import org.eclipse.jdt.core.dom.StringLiteral;
* E is the type of the expressions to be found in the array initializer.
*/
public class StringArrayExpressionConverter<E extends Expression>
- extends AbstractExpressionConverter<ArrayInitializer, String[]>
+ extends AbstractExpressionConverter<String[], ArrayInitializer>
{
- private final ExpressionConverter<E, String> elementConverter;
+ private final ExpressionConverter<String, E> elementConverter;
- public StringArrayExpressionConverter(ExpressionConverter<E, String> elementConverter) {
+ public StringArrayExpressionConverter(ExpressionConverter<String, E> elementConverter) {
super();
this.elementConverter = elementConverter;
}
@Override
- @SuppressWarnings("unchecked")
protected ArrayInitializer convert_(String[] strings, AST ast) {
ArrayInitializer arrayInitializer = ast.newArrayInitializer();
- List<Expression> expressions = arrayInitializer.expressions();
+ List<Expression> expressions = this.expressions(arrayInitializer);
for (String string : strings) {
expressions.add(this.elementConverter.convert(string, ast));
}
return arrayInitializer;
}
- @Override
@SuppressWarnings("unchecked")
+ private List<Expression> expressions(ArrayInitializer arrayInitializer) {
+ return arrayInitializer.expressions();
+ }
+
+ @Override
protected String[] convert_(ArrayInitializer arrayInitializer) {
- List<E> expressions = arrayInitializer.expressions();
+ List<E> expressions = this.downcastExpressions(arrayInitializer);
int len = expressions.size();
String[] strings = new String[len];
for (int i = len; i-- > 0; ) {
@@ -52,6 +55,15 @@ public class StringArrayExpressionConverter<E extends Expression>
return strings;
}
+ @SuppressWarnings("unchecked")
+ private List<E> downcastExpressions(ArrayInitializer arrayInitializer) {
+ return arrayInitializer.expressions();
+ }
+
+ /**
+ * Build an expression converter for an annotation element of type String[].
+ * @Foo(bar={"text0", "text1"})
+ */
public static StringArrayExpressionConverter<StringLiteral> forStringLiterals() {
return new StringArrayExpressionConverter<StringLiteral>(StringExpressionConverter.instance());
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java
index b9000089ce..444650f53e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java
@@ -17,14 +17,14 @@ import org.eclipse.jdt.core.dom.StringLiteral;
* Convert a string literal to/from a string (e.g. "text").
*/
public final class StringExpressionConverter
- extends AbstractExpressionConverter<StringLiteral, String>
+ extends AbstractExpressionConverter<String, StringLiteral>
{
- private static ExpressionConverter<StringLiteral, String> INSTANCE;
+ private static ExpressionConverter<String, StringLiteral> INSTANCE;
/**
* Return the singleton.
*/
- public static ExpressionConverter<StringLiteral, String> instance() {
+ public static ExpressionConverter<String, StringLiteral> instance() {
if (INSTANCE == null) {
INSTANCE = new StringExpressionConverter();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Type.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Type.java
index 322012a311..65f018e644 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Type.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Type.java
@@ -14,7 +14,6 @@ import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.TypeDeclaration;
@@ -24,21 +23,19 @@ public class Type extends Member {
super(type);
}
- public IType jdtType() {
- return (IType) this.getJdtMember();
- }
-
- TypeDeclaration typeDeclaration() {
- return (TypeDeclaration) this.bodyDeclaration();
+ @Override
+ public IType getJdtMember() {
+ return (IType) super.getJdtMember();
}
- TypeDeclaration typeDeclaration(CompilationUnit astRoot) {
- return (TypeDeclaration) this.bodyDeclaration(astRoot);
+ @Override
+ public TypeDeclaration bodyDeclaration() {
+ return (TypeDeclaration) super.bodyDeclaration();
}
public boolean isAbstract() {
try {
- return Flags.isAbstract(this.jdtType().getFlags());
+ return Flags.isAbstract(this.getJdtMember().getFlags());
} catch (JavaModelException ex) {
throw new RuntimeException(ex);
}
@@ -50,18 +47,18 @@ public class Type extends Member {
}
public String getFullyQualifiedName() {
- return this.jdtType().getFullyQualifiedName();
+ return this.getJdtMember().getFullyQualifiedName();
}
// ********** Member implementation **********
@Override
- public BodyDeclaration bodyDeclaration(CompilationUnit astRoot) {
+ public TypeDeclaration bodyDeclaration(CompilationUnit astRoot) {
String name = this.getName();
for (AbstractTypeDeclaration typeDeclaration : this.types(astRoot)) {
if (typeDeclaration.getName().getFullyQualifiedName().equals(name)) {
- return typeDeclaration;
+ return (TypeDeclaration) typeDeclaration; // assume no enum or annotation declarations
}
}
return null;
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java
index 079f2f59f6..5176595367 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java
@@ -115,7 +115,7 @@ public class JDTToolsTests extends AnnotationTestCase {
this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "foo");
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
FieldAttribute field = this.idField();
String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea));
@@ -128,7 +128,7 @@ public class JDTToolsTests extends AnnotationTestCase {
this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "foo");
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
FieldAttribute field = this.idField();
String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea));
@@ -141,7 +141,7 @@ public class JDTToolsTests extends AnnotationTestCase {
this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "foo");
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
FieldAttribute field = this.idField();
String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea));
@@ -154,7 +154,7 @@ public class JDTToolsTests extends AnnotationTestCase {
this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "foo");
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
FieldAttribute field = this.idField();
String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea));
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java
index d420344911..a13cf24929 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java
@@ -10,7 +10,11 @@
package org.eclipse.jpt.core.tests.internal.jdtutility;
import java.util.Arrays;
-import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.ArrayInitializer;
+import org.eclipse.jdt.core.dom.BooleanLiteral;
+import org.eclipse.jdt.core.dom.CharacterLiteral;
+import org.eclipse.jdt.core.dom.NumberLiteral;
+import org.eclipse.jdt.core.dom.TypeLiteral;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.jdtutility.ASTNodeTextRange;
import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter;
@@ -19,6 +23,7 @@ import org.eclipse.jpt.core.internal.jdtutility.CharacterStringExpressionConvert
import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.jdtutility.EnumArrayDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.EnumDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.jdtutility.NestedDeclarationAnnotationAdapter;
@@ -28,7 +33,6 @@ import org.eclipse.jpt.core.internal.jdtutility.PrimitiveTypeStringExpressionCon
import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.jdtutility.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.core.internal.jdtutility.StringArrayExpressionConverter;
-import org.eclipse.jpt.core.internal.jdtutility.StringExpressionConverter;
public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
@@ -48,8 +52,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "String bar();");
this.createTestType("@annot.Foo(bar=\"xxx\")");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("xxx", aea.getValue());
}
@@ -57,8 +61,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "int bar();");
this.createTestType("@annot.Foo(bar=48)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", NumberStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, NumberLiteral>(daa, "bar", NumberStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("48", aea.getValue());
}
@@ -66,8 +70,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "char bar();");
this.createTestType("@annot.Foo(bar='c')");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", CharacterStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, CharacterLiteral>(daa, "bar", CharacterStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("c", aea.getValue());
}
@@ -75,8 +79,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "boolean bar();");
this.createTestType("@annot.Foo(bar=false)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa, "bar", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("false", aea.getValue());
}
@@ -88,8 +92,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("false", aea.getValue());
}
@@ -97,8 +101,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "boolean value();");
this.createTestType("@annot.Foo(false)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa, BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("false", aea.getValue());
}
@@ -106,8 +110,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "String bar();");
this.createTestType("@annot.Foo");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -115,8 +119,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "String bar();");
this.createTestType();
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -128,8 +132,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa3, "fred");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -140,8 +144,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
String annotation = "@annot.Foo(" + element + ")";
this.createTestType(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
ITextRange textRange = new ASTNodeTextRange(aea.astNode());
assertEquals(this.source().indexOf(value), textRange.getOffset());
@@ -160,8 +164,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("false", aea.getValue());
ITextRange textRange = new ASTNodeTextRange(aea.astNode());
assertEquals(value.length(), textRange.getLength());
@@ -173,8 +177,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
String annotation = "@annot.Foo(" + element + ")";
this.createTestType(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa);
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
ITextRange textRange = new ASTNodeTextRange(aea.astNode());
assertEquals(this.source().indexOf(element), textRange.getOffset());
@@ -186,8 +190,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
String annotation = "@annot.Foo";
this.createTestType(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa);
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
ITextRange textRange = new ASTNodeTextRange(aea.astNode());
assertEquals(this.source().indexOf(annotation), textRange.getOffset());
@@ -200,8 +204,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue(null);
this.assertSourceDoesNotContain("Foo");
@@ -213,8 +217,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", false);
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar", false);
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue(null);
this.assertSourceDoesNotContain(annotation);
@@ -231,8 +235,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue(null);
this.assertSourceDoesNotContain(annotation);
@@ -250,8 +254,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar", false);
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz", false);
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue(null);
this.assertSourceDoesNotContain(annotation);
@@ -262,8 +266,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "String bar();");
this.createTestType();
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("xxx");
this.assertSourceContains("@Foo(bar=\"xxx\")");
@@ -279,8 +283,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("true");
this.assertSourceDoesNotContain(annotation);
@@ -295,8 +299,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(daa3, "fred", BooleanStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("true");
this.assertSourceContains("@Foo(@Bar(jimmy=@Baz(fred=true)))");
@@ -308,8 +312,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("yyy");
this.assertSourceDoesNotContain(annotation);
@@ -322,8 +326,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("xxx");
this.assertSourceContains("@Foo(bar=\"xxx\")");
@@ -335,8 +339,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("xxx");
this.assertSourceDoesNotContain(annotation);
@@ -349,8 +353,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "baz");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "baz");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("yyy");
this.assertSourceDoesNotContain(annotation);
@@ -367,8 +371,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "jimmy", 2, "annot.Baz");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", NumberStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, NumberLiteral>(daa3, "fred", NumberStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("2", aea.getValue());
aea.setValue("48");
@@ -381,8 +385,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "value");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("xxx");
this.assertSourceContains("@Foo(\"xxx\")");
@@ -394,8 +398,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType(annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "value");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("xxx");
this.assertSourceDoesNotContain(annotation);
@@ -406,8 +410,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("java.lang.Object", aea.getValue());
}
@@ -415,8 +419,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType();
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("java.lang.Object");
this.assertSourceContains("@Foo(bar=java.lang.Object.class)");
}
@@ -425,8 +429,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=int.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -434,8 +438,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("java.util.Map.Entry", aea.getValue());
}
@@ -443,8 +447,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=int.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("int", aea.getValue());
}
@@ -452,8 +456,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType();
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("int");
this.assertSourceContains("@Foo(bar=int.class)");
}
@@ -462,8 +466,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -471,8 +475,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "Class bar();");
this.createTestType("@annot.Foo(bar=void.class)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("void", aea.getValue());
}
@@ -481,8 +485,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("enums.TestEnum.XXX", aea.getValue());
}
@@ -491,8 +495,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("enums.TestEnum.XXX", aea.getValue());
}
@@ -501,8 +505,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
this.createTestType("@annot.Foo");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -511,8 +515,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
assertEquals("enums.TestEnum.XXX", aea.getValue());
}
@@ -523,8 +527,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType("static enums.TestEnum.XXX", annotation);
this.assertSourceContains(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue(null);
this.assertSourceDoesNotContain("Foo");
}
@@ -536,8 +540,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType();
this.assertSourceDoesNotContain(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String> aea = new MemberAnnotationElementAdapter<String>(this.idField(), daea);
aea.setValue("enums.TestEnum.XXX");
this.assertSourceContains("import static enums.TestEnum.XXX;");
this.assertSourceContains(annotation);
@@ -547,17 +551,17 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createAnnotationAndMembers("Foo", "String[] bar();");
this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", new StringArrayExpressionConverter<StringLiteral>(StringExpressionConverter.instance()));
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
- assertTrue(Arrays.equals(new String[] {"string0", "string1"}, (String[]) aea.getValue()));
+ DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[], ArrayInitializer>(daa, "bar", StringArrayExpressionConverter.forStringLiterals());
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
+ assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue()));
}
public void testGetValueNullStringArray() throws Exception {
this.createAnnotationAndMembers("Foo", "String[] bar();");
this.createTestType("@annot.Foo()");
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", new StringArrayExpressionConverter<StringLiteral>(StringExpressionConverter.instance()));
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[], ArrayInitializer>(daa, "bar", StringArrayExpressionConverter.forStringLiterals());
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
assertNull(aea.getValue());
}
@@ -567,10 +571,45 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
this.createTestType();
this.assertSourceDoesNotContain(annotation);
DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", new StringArrayExpressionConverter<StringLiteral>(StringExpressionConverter.instance()));
- AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea);
+ DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[], ArrayInitializer>(daa, "bar", StringArrayExpressionConverter.forStringLiterals());
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
aea.setValue(new String[] {"string0", "string1"});
this.assertSourceContains(annotation);
}
+ public void testGetValueEnumArray() throws Exception {
+ this.createEnum("TestEnum", "XXX, YYY, ZZZ");
+ this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
+ this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})");
+ DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
+ DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
+ assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, aea.getValue()));
+ }
+
+ public void testGetValueNullEnumArray() throws Exception {
+ this.createEnum("TestEnum", "XXX, YYY, ZZZ");
+ this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
+ this.createTestType("@annot.Foo()");
+ DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
+ DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
+ assertNull(aea.getValue());
+ }
+
+ public void testSetValueEnumArray() throws Exception {
+ this.createEnum("TestEnum", "XXX, YYY, ZZZ");
+ this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
+ String annotation = "@Foo(bar={XXX,YYY})";
+ this.createTestType();
+ this.assertSourceDoesNotContain(annotation);
+ DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
+ DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
+ AnnotationElementAdapter<String[]> aea = new MemberAnnotationElementAdapter<String[]>(this.idField(), daea);
+ aea.setValue(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"});
+ this.assertSourceContains("import static enums.TestEnum.XXX;");
+ this.assertSourceContains("import static enums.TestEnum.YYY;");
+ this.assertSourceContains(annotation);
+ }
+
}
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java
index 360a9145dd..637115678b 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java
+++ b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java
@@ -37,8 +37,8 @@ public class TypeTests extends AnnotationTestCase {
super.tearDown();
}
- public void testJdtType() throws Exception {
- assertEquals(this.jdtType, this.testType.jdtType());
+ public void testGetJdtMember() throws Exception {
+ assertEquals(this.jdtType, this.testType.getJdtMember());
}
public void testIsAbstract() throws Exception {

Back to the top