Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-12-15 18:34:38 +0000
committerkmoore2010-12-15 18:34:38 +0000
commit494ee8bd26200bbe86994ce6150cc546acc6e136 (patch)
treefe2650c7dc391e092733468a1d73e3529e404c8d
parentbd50d875a45a3b711716bacc2cf842156db82801 (diff)
downloadwebtools.dali-494ee8bd26200bbe86994ce6150cc546acc6e136.tar.gz
webtools.dali-494ee8bd26200bbe86994ce6150cc546acc6e136.tar.xz
webtools.dali-494ee8bd26200bbe86994ce6150cc546acc6e136.zip
Refactoring and adding resource model support for Enums and EnumConstants
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAbstractType.java194
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java120
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnum.java215
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnumConstant.java90
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceField.java94
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMember.java2
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMethod.java202
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java364
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceTypeCompilationUnit.java48
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyAttributeAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttachmentRefAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttributeAnnotation.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementDeclAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementWrapperAnnotation.java6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumAnnotation.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumValueAnnotation.java11
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDREFAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlListAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMimeTypeAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMixedAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRegistryAnnotation.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRootElementAnnotation.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSeeAlsoAnnotation.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlValueAnnotation.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AbstractJavaResourceType.java93
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnum.java41
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnumConstant.java41
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceField.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAttribute.java)39
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceMember.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceNode.java8
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceType.java113
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java44
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java10
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java26
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyAttributeAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyElementAnnotationTests.java12
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttachmentRefAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttributeAnnotationTests.java16
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java30
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementDeclAnnotationTests.java54
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java18
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementWrapperAnnotationTests.java20
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumAnnotationTests.java22
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumValueAnnotationTests.java38
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDREFAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAttributeAnnotationTests.java8
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlListAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMimeTypeAnnotationTests.java10
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMixedAnnotationTests.java4
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlSchemaTypeAttributeAnnotationTests.java8
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlTransientAttributeAnnotationTests.java8
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlValueAnnotationTests.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java198
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAttribute.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnum.java132
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java125
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTType.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AbstractType.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Enum.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/EnumConstant.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/MethodAttribute.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Type.java18
73 files changed, 2089 insertions, 860 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
index fe34ec6580..2271bb04c4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
@@ -9,7 +9,7 @@
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.context;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
/**
* Represents a java class (or enum or interface) with JAXB metadata (specified or implied).
@@ -34,7 +34,7 @@ public interface JaxbType
/**
* Return the associated java resource type
*/
- JavaResourceType getJavaResourceType();
+ AbstractJavaResourceType getJavaResourceType();
/**
* Returns the fully qualified name of this type, including qualification for any
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAbstractType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAbstractType.java
new file mode 100644
index 0000000000..fb18a419a8
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAbstractType.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import java.util.HashMap;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.IntReference;
+import org.eclipse.jpt.utility.internal.StringTools;
+
+/**
+ * Java source type
+ */
+abstract class SourceAbstractType<A extends AbstractType>
+ extends SourceMember<A>
+ implements AbstractJavaResourceType
+{
+ private String name;
+
+ private String qualifiedName;
+
+ private String packageName;
+
+ private String declaringTypeName;
+
+ private boolean memberType;
+
+
+ // ********** construction/initialization **********
+
+ protected SourceAbstractType(JavaResourceCompilationUnit javaResourceCompilationUnit, A type) {
+ super(javaResourceCompilationUnit, type);
+ }
+
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ ITypeBinding binding = this.annotatedElement.getBinding(astRoot);
+ this.name = this.buildName(binding);
+ this.qualifiedName = this.buildQualifiedName(binding);
+ this.packageName = this.buildPackageName(binding);
+ this.declaringTypeName = this.buildDeclaringTypeName(binding);
+ this.memberType = this.buildMemberType(binding);
+ }
+
+
+ // ********** update **********
+
+ @Override
+ public void synchronizeWith(CompilationUnit astRoot) {
+ super.synchronizeWith(astRoot);
+ ITypeBinding binding = this.annotatedElement.getBinding(astRoot);
+ this.syncName(this.buildName(binding));
+ this.syncQualifiedName(this.buildQualifiedName(binding));
+ this.syncPackageName(this.buildPackageName(binding));
+ this.syncDeclaringTypeName(this.buildDeclaringTypeName(binding));
+ this.syncMemberType(this.buildMemberType(binding));
+ }
+
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+
+ // ******** JavaResourceAbstractType implementation ********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ private void syncName(String astName) {
+ String old = this.name;
+ this.name = astName;
+ this.firePropertyChanged(NAME_PROPERTY, old, astName);
+ }
+
+ private String buildName(ITypeBinding binding) {
+ return (binding == null) ? null : binding.getName();
+ }
+
+ // ***** qualified name
+ public String getQualifiedName() {
+ return this.qualifiedName;
+ }
+
+ private void syncQualifiedName(String astQualifiedName) {
+ String old = this.qualifiedName;
+ this.qualifiedName = astQualifiedName;
+ this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, astQualifiedName);
+ }
+
+ private String buildQualifiedName(ITypeBinding binding) {
+ return (binding == null) ? null : binding.getQualifiedName();
+ }
+
+ // ***** package name
+ public String getPackageName() {
+ return this.packageName;
+ }
+
+ private void syncPackageName(String astPackageName) {
+ String old = this.packageName;
+ this.packageName = astPackageName;
+ this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, astPackageName);
+ }
+
+ private String buildPackageName(ITypeBinding binding) {
+ return (binding == null) ? null : binding.getPackage().getName();
+ }
+
+ // ***** package
+ public boolean isIn(IPackageFragment packageFragment) {
+ return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName);
+ }
+
+ // ***** declaring type name
+ public String getDeclaringTypeName() {
+ return this.declaringTypeName;
+ }
+
+ private void syncDeclaringTypeName(String astDeclaringTypeName) {
+ String old = this.declaringTypeName;
+ this.declaringTypeName = astDeclaringTypeName;
+ this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, astDeclaringTypeName);
+ }
+
+ private String buildDeclaringTypeName(ITypeBinding binding) {
+ if (binding == null) {
+ return null;
+ }
+ ITypeBinding declaringClass = binding.getDeclaringClass();
+ return (declaringClass == null) ? null : declaringClass.getTypeDeclaration().getQualifiedName();
+ }
+
+ // ***** member type
+ public boolean isMemberType() {
+ return this.memberType;
+ }
+
+ private void syncMemberType(boolean memberType) {
+ boolean old = this.memberType;
+ this.memberType = memberType;
+ this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, memberType);
+ }
+
+ private boolean buildMemberType(ITypeBinding binding) {
+ return (binding == null) ? false : binding.isMember();
+ }
+
+ public boolean isMapped() {
+ return ! CollectionTools.isEmpty(getAnnotations());
+ }
+
+
+ // ********** CounterMap **********
+
+ protected static class CounterMap {
+ private final HashMap<Object, IntReference> counters;
+
+ protected CounterMap(int initialCapacity) {
+ super();
+ this.counters = new HashMap<Object, IntReference>(initialCapacity);
+ }
+
+ /**
+ * Return the incremented count for the specified object.
+ */
+ int increment(Object o) {
+ IntReference counter = this.counters.get(o);
+ if (counter == null) {
+ counter = new IntReference();
+ this.counters.put(o, counter);
+ }
+ counter.increment();
+ return counter.getValue();
+ }
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java
index 391821ad3c..04dc6040ea 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceAttribute.java
@@ -18,29 +18,18 @@ import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute;
import org.eclipse.jpt.core.utility.jdt.Attribute;
-import org.eclipse.jpt.core.utility.jdt.MethodAttribute;
-import org.eclipse.jpt.core.utility.jdt.Type;
-import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
-import org.eclipse.jpt.utility.MethodSignature;
import org.eclipse.jpt.utility.internal.ClassName;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
/**
- * Java source persistent attribute (field or property)
+ * Java source attribute (field or method)
*/
-final class SourceAttribute
- extends SourceMember<Attribute>
- implements JavaResourceAttribute
+abstract class SourceAttribute<A extends Attribute>
+ extends SourceMember<A>
{
private int modifiers;
@@ -57,51 +46,7 @@ final class SourceAttribute
private final Vector<String> typeTypeArgumentNames = new Vector<String>();
- /**
- * construct field attribute
- */
- static JavaResourceAttribute newInstance(
- JavaResourceType parent,
- Type declaringType,
- String name,
- int occurrence,
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- CompilationUnit astRoot) {
- Attribute attribute = new JDTFieldAttribute(
- declaringType,
- name,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceAttribute jrpa = new SourceAttribute(parent, attribute);
- jrpa.initialize(astRoot);
- return jrpa;
- }
-
- /**
- * construct property attribute
- */
- static JavaResourceAttribute newInstance(
- JavaResourceType parent,
- Type declaringType,
- MethodSignature signature,
- int occurrence,
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- CompilationUnit astRoot) {
- Attribute attribute = JDTMethodAttribute.newInstance(
- declaringType,
- signature,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceAttribute jrpa = new SourceAttribute(parent, attribute);
- jrpa.initialize(astRoot);
- return jrpa;
- }
-
- private SourceAttribute(JavaResourceType parent, Attribute attribute){
+ protected SourceAttribute(JavaResourceType parent, A attribute){
super(parent, attribute);
}
@@ -149,41 +94,12 @@ final class SourceAttribute
sb.append(this.getName());
}
-
- // ******** AbstractJavaResourcePersistentMember implementation ********
-
- public boolean isFor(MethodSignature signature, int occurrence) {
- return ((MethodAttribute) this.annotatedElement).matches(signature, occurrence);
- }
-
// ******** JavaResourcePersistentAttribute implementation ********
public String getName() {
return this.annotatedElement.getAttributeName();
}
-
- @Override
- public Annotation buildNullAnnotation(String annotationName) {
- return (annotationName == null) ? null : super.buildNullAnnotation(annotationName);
- }
-
- public boolean isField() {
- return this.annotatedElement.isField();
- }
-
- public boolean isProperty() {
- return ! this.isField();
- }
-
- public XmlAccessType getSpecifiedAccess() {
- XmlAccessorTypeAnnotation accessAnnotation = this.getAccessAnnotation();
- return (accessAnnotation == null) ? null : accessAnnotation.getValue();
- }
-
- private XmlAccessorTypeAnnotation getAccessAnnotation() {
- return (XmlAccessorTypeAnnotation) this.getAnnotation(XmlAccessorTypeAnnotation.ANNOTATION_NAME);
- }
public boolean typeIsSubTypeOf(String tn) {
if (this.typeName == null) {
@@ -211,9 +127,11 @@ final class SourceAttribute
private void syncModifiers(int astModifiers) {
int old = this.modifiers;
this.modifiers = astModifiers;
- this.firePropertyChanged(MODIFIERS_PROPERTY, old, astModifiers);
+ this.firePropertyChanged(getModifiersProperty(), old, astModifiers);
}
+ protected abstract String getModifiersProperty();
+
/**
* zero seems like a reasonable default...
*/
@@ -230,9 +148,11 @@ final class SourceAttribute
private void syncTypeName(String astTypeName) {
String old = this.typeName;
this.typeName = astTypeName;
- this.firePropertyChanged(TYPE_NAME_PROPERTY, old, astTypeName);
+ this.firePropertyChanged(getTypeNameProperty(), old, astTypeName);
}
+ protected abstract String getTypeNameProperty();
+
/**
* this can be an array (e.g. "java.lang.String[]");
* but no generic type arguments
@@ -260,9 +180,11 @@ final class SourceAttribute
private void syncTypeIsInterface(boolean astTypeIsInterface) {
boolean old = this.typeIsInterface;
this.typeIsInterface = astTypeIsInterface;
- this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, astTypeIsInterface);
+ this.firePropertyChanged(getTypeIsInterfaceProperty(), old, astTypeIsInterface);
}
+ protected abstract String getTypeIsInterfaceProperty();
+
private boolean buildTypeIsInterface(ITypeBinding typeBinding) {
return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isInterface();
}
@@ -275,9 +197,11 @@ final class SourceAttribute
private void syncTypeIsEnum(boolean astTypeIsEnum) {
boolean old = this.typeIsEnum;
this.typeIsEnum = astTypeIsEnum;
- this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, astTypeIsEnum);
+ this.firePropertyChanged(getTypeIsEnumProperty(), old, astTypeIsEnum);
}
+ protected abstract String getTypeIsEnumProperty();
+
private boolean buildTypeIsEnum(ITypeBinding typeBinding) {
return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isEnum();
}
@@ -288,9 +212,11 @@ final class SourceAttribute
}
private void syncTypeSuperclassNames(List<String> astTypeSuperclassNames) {
- this.synchronizeList(astTypeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST);
+ this.synchronizeList(astTypeSuperclassNames, this.typeSuperclassNames, getTypeSuperclassNamesProperty());
}
+ protected abstract String getTypeSuperclassNamesProperty();
+
private List<String> buildTypeSuperclassNames(ITypeBinding typeBinding) {
if (typeBinding == null) {
return Collections.emptyList();
@@ -314,9 +240,11 @@ final class SourceAttribute
// }
//
private void syncTypeInterfaceNames(Collection<String> astTypeInterfaceNames) {
- this.synchronizeCollection(astTypeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION);
+ this.synchronizeCollection(astTypeInterfaceNames, this.typeInterfaceNames, getTypeInterfaceNamesProperty());
}
+ protected abstract String getTypeInterfaceNamesProperty();
+
private Collection<String> buildTypeInterfaceNames(ITypeBinding typeBinding) {
if (typeBinding == null) {
return Collections.emptySet();
@@ -350,9 +278,11 @@ final class SourceAttribute
}
private void syncTypeTypeArgumentNames(List<String> astTypeTypeArgumentNames) {
- this.synchronizeList(astTypeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST);
+ this.synchronizeList(astTypeTypeArgumentNames, this.typeTypeArgumentNames, this.getTypeTypeArgumentNamesProperty());
}
+ protected abstract String getTypeTypeArgumentNamesProperty();
+
/**
* these types can be arrays (e.g. "java.lang.String[]");
* but they won't have any further nested generic type arguments
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnum.java
new file mode 100644
index 0000000000..7ac3d5b402
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnum.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Vector;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTEnum;
+import org.eclipse.jpt.core.utility.jdt.Enum;
+import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.utility.internal.IntReference;
+import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
+import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
+
+/**
+ * Java source type
+ */
+final class SourceEnum
+ extends SourceAbstractType<Enum>
+ implements JavaResourceEnum
+{
+
+ private final Vector<JavaResourceEnumConstant> enumConstants;
+
+
+
+ // ********** construction/initialization **********
+
+ /**
+ * build top-level type
+ */
+ static JavaResourceEnum newInstance(
+ JavaResourceCompilationUnit javaResourceCompilationUnit,
+ EnumDeclaration enumDeclaration,
+ CompilationUnit astRoot) {
+ Enum _enum = new JDTEnum(
+ enumDeclaration,
+ javaResourceCompilationUnit.getCompilationUnit(),
+ javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
+ javaResourceCompilationUnit.getAnnotationEditFormatter());
+ JavaResourceEnum jre = new SourceEnum(javaResourceCompilationUnit, _enum);
+ jre.initialize(astRoot);
+ return jre;
+ }
+
+ /**
+ * build nested type
+ */
+ protected static JavaResourceEnum newInstance(
+ JavaResourceCompilationUnit javaResourceCompilationUnit,
+ Type declaringType,
+ EnumDeclaration enumDeclaration,
+ int occurrence,
+ CompilationUnit astRoot) {
+ Enum _enum = new JDTEnum(
+ declaringType,
+ enumDeclaration,
+ occurrence,
+ javaResourceCompilationUnit.getCompilationUnit(),
+ javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
+ javaResourceCompilationUnit.getAnnotationEditFormatter());
+ JavaResourceEnum jre = new SourceEnum(javaResourceCompilationUnit, _enum);
+ jre.initialize(astRoot);
+ return jre;
+ }
+
+ private SourceEnum(JavaResourceCompilationUnit javaResourceCompilationUnit, Enum _enum) {
+ super(javaResourceCompilationUnit, _enum);
+ this.enumConstants = new Vector<JavaResourceEnumConstant>();
+ }
+
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ this.initializeEnumConstants(astRoot);
+ }
+
+
+ // ********** update **********
+
+ @Override
+ public void synchronizeWith(CompilationUnit astRoot) {
+ super.synchronizeWith(astRoot);
+ this.syncEnumConstants(astRoot);
+ }
+
+
+ // ********** SourceAnnotatedElement implementation **********
+
+ @Override
+ public void resolveTypes(CompilationUnit astRoot) {
+ super.resolveTypes(astRoot);
+
+ for (JavaResourceEnumConstant enumConstant : this.getEnumConstants()) {
+ enumConstant.resolveTypes(astRoot);
+ }
+ }
+
+
+ // ******** JavaResourceEnum implementation ********
+
+ // ********** enum constants **********
+
+ public Iterable<JavaResourceEnumConstant> getEnumConstants() {
+ return new LiveCloneIterable<JavaResourceEnumConstant>(this.enumConstants);
+ }
+
+ private void addEnumConstant(JavaResourceEnumConstant enumConstant) {
+ this.addItemToCollection(enumConstant, this.enumConstants, ENUM_CONSTANTS_COLLECTION);
+ }
+
+ private JavaResourceEnumConstant getEnumConstant(String fieldName, int occurrence) {
+ for (JavaResourceEnumConstant enumConstant : this.getEnumConstants()) {
+ if (enumConstant.isFor(fieldName, occurrence)) {
+ return enumConstant;
+ }
+ }
+ return null;
+ }
+
+ private void removeEnumConstants(Collection<JavaResourceEnumConstant> remove) {
+ this.removeItemsFromCollection(remove, this.enumConstants, ENUM_CONSTANTS_COLLECTION);
+ }
+
+ private void initializeEnumConstants(CompilationUnit astRoot) {
+ EnumConstantDeclaration[] enumConstantDeclarations = this.annotatedElement.getEnumConstants(astRoot);
+ CounterMap counters = new CounterMap(enumConstantDeclarations.length);
+ for (EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) {
+ String constantName = enumConstantDeclaration.getName().getFullyQualifiedName();
+ int occurrence = counters.increment(constantName);
+ this.enumConstants.add(this.buildEnumConstant(constantName, occurrence, astRoot));
+ }
+ }
+
+ private void syncEnumConstants(CompilationUnit astRoot) {
+ EnumConstantDeclaration[] enumConstantDeclarations = this.annotatedElement.getEnumConstants(astRoot);
+ CounterMap counters = new CounterMap(enumConstantDeclarations.length);
+ HashSet<JavaResourceEnumConstant> enumConstantsToRemove = new HashSet<JavaResourceEnumConstant>(this.enumConstants);
+ for (EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) {
+ String constantName = enumConstantDeclaration.getName().getFullyQualifiedName();
+ int occurrence = counters.increment(constantName);
+
+ JavaResourceEnumConstant enumConstant = this.getEnumConstant(constantName, occurrence);
+ if (enumConstant == null) {
+ this.addEnumConstant(this.buildEnumConstant(constantName, occurrence, astRoot));
+ } else {
+ enumConstantsToRemove.remove(enumConstant);
+ enumConstant.synchronizeWith(astRoot);
+ }
+ }
+ this.removeEnumConstants(enumConstantsToRemove);
+ }
+
+ private JavaResourceEnumConstant buildEnumConstant(String fieldName, int occurrence, CompilationUnit astRoot) {
+ return SourceEnumConstant.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
+ }
+
+
+ public Iterable<JavaResourceType> getTypes() {
+ return EmptyIterable.instance();
+ }
+
+ public Iterable<JavaResourceType> getAllTypes() {
+ return EmptyIterable.instance();
+ }
+
+ public Iterable<JavaResourceEnum> getEnums() {
+ return EmptyIterable.instance();
+ }
+
+ public Iterable<JavaResourceEnum> getAllEnums() {
+ return new SingleElementIterable<JavaResourceEnum>(this);
+ }
+
+ // ********** CounterMap **********
+
+ private static class CounterMap {
+ private final HashMap<Object, IntReference> counters;
+
+ protected CounterMap(int initialCapacity) {
+ super();
+ this.counters = new HashMap<Object, IntReference>(initialCapacity);
+ }
+
+ /**
+ * Return the incremented count for the specified object.
+ */
+ int increment(Object o) {
+ IntReference counter = this.counters.get(o);
+ if (counter == null) {
+ counter = new IntReference();
+ this.counters.put(o, counter);
+ }
+ counter.increment();
+ return counter.getValue();
+ }
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnumConstant.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnumConstant.java
new file mode 100644
index 0000000000..ae83bed265
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceEnumConstant.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTEnumConstant;
+import org.eclipse.jpt.core.utility.jdt.EnumConstant;
+import org.eclipse.jpt.core.utility.jdt.Enum;
+import org.eclipse.jpt.jaxb.core.resource.java.Annotation;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
+
+/**
+ * Java source enum constant
+ */
+final class SourceEnumConstant
+ extends SourceMember<EnumConstant>
+ implements JavaResourceEnumConstant
+{
+
+ /**
+ * construct enum constant
+ */
+ static JavaResourceEnumConstant newInstance(
+ JavaResourceEnum parent,
+ Enum declaringEnum,
+ String name,
+ int occurrence,
+ JavaResourceCompilationUnit javaResourceCompilationUnit,
+ CompilationUnit astRoot) {
+ EnumConstant enumConstant = new JDTEnumConstant(
+ declaringEnum,
+ name,
+ occurrence,
+ javaResourceCompilationUnit.getCompilationUnit(),
+ javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
+ javaResourceCompilationUnit.getAnnotationEditFormatter());
+ JavaResourceEnumConstant jrec = new SourceEnumConstant(parent, enumConstant);
+ jrec.initialize(astRoot);
+ return jrec;
+ }
+
+ private SourceEnumConstant(JavaResourceEnum parent, EnumConstant enumConstant){
+ super(parent, enumConstant);
+ }
+
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ }
+
+
+ // ******** overrides ********
+
+ @Override
+ public void resolveTypes(CompilationUnit astRoot) {
+ super.resolveTypes(astRoot);
+ }
+
+ @Override
+ public void synchronizeWith(CompilationUnit astRoot) {
+ super.synchronizeWith(astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.getName());
+ }
+
+
+ // ******** JavaResourceEnumConstant implementation ********
+
+ public String getName() {
+ return this.annotatedElement.getName();
+ }
+
+ @Override
+ public Annotation buildNullAnnotation(String annotationName) {
+ return (annotationName == null) ? null : super.buildNullAnnotation(annotationName);
+ }
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceField.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceField.java
new file mode 100644
index 0000000000..c735914213
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceField.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute;
+import org.eclipse.jpt.core.utility.jdt.FieldAttribute;
+import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+
+/**
+ * Java source field
+ */
+final class SourceField
+ extends SourceAttribute<FieldAttribute>
+ implements JavaResourceField
+{
+
+ /**
+ * construct field attribute
+ */
+ static JavaResourceField newInstance(
+ JavaResourceType parent,
+ Type declaringType,
+ String name,
+ int occurrence,
+ JavaResourceCompilationUnit javaResourceCompilationUnit,
+ CompilationUnit astRoot) {
+ FieldAttribute field = new JDTFieldAttribute(
+ declaringType,
+ name,
+ occurrence,
+ javaResourceCompilationUnit.getCompilationUnit(),
+ javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
+ javaResourceCompilationUnit.getAnnotationEditFormatter());
+ JavaResourceField jrpa = new SourceField(parent, field);
+ jrpa.initialize(astRoot);
+ return jrpa;
+ }
+
+ private SourceField(JavaResourceType parent, FieldAttribute field){
+ super(parent, field);
+ }
+
+
+ // ******** SourceAttribute implementation ********
+
+ @Override
+ protected String getModifiersProperty() {
+ return MODIFIERS_PROPERTY;
+ }
+
+ @Override
+ protected String getTypeNameProperty() {
+ return TYPE_NAME_PROPERTY;
+ }
+
+ @Override
+ protected String getTypeIsInterfaceProperty() {
+ return TYPE_IS_INTERFACE_PROPERTY;
+ }
+
+ @Override
+ protected String getTypeIsEnumProperty() {
+ return TYPE_IS_ENUM_PROPERTY;
+ }
+
+ @Override
+ protected String getTypeSuperclassNamesProperty() {
+ return TYPE_SUPERCLASS_NAMES_LIST;
+ }
+
+ @Override
+ protected String getTypeInterfaceNamesProperty() {
+ return TYPE_INTERFACE_NAMES_COLLECTION;
+ }
+
+ @Override
+ protected String getTypeTypeArgumentNamesProperty() {
+ return TYPE_TYPE_ARGUMENT_NAMES_LIST;
+ }
+
+
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMember.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMember.java
index 07a51e6316..042933f1bb 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMember.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMember.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
/**
- * Java source persistent member (annotations, "persistable")
+ * Java source member (annotations, "persistable")
*/
abstract class SourceMember<M extends Member>
extends SourceAnnotatedElement<M>
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMethod.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMethod.java
new file mode 100644
index 0000000000..7e901f2bf8
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceMethod.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.IMethodBinding;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute;
+import org.eclipse.jpt.core.utility.jdt.MethodAttribute;
+import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.utility.MethodSignature;
+import org.eclipse.jpt.utility.internal.iterables.ListIterable;
+import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
+
+/**
+ * Java source method
+ */
+final class SourceMethod
+ extends SourceAttribute<MethodAttribute>
+ implements JavaResourceMethod
+{
+
+ private final Vector<String> parameterTypeNames = new Vector<String>();
+
+ /**
+ * construct method
+ */
+ static JavaResourceMethod newInstance(
+ JavaResourceType parent,
+ Type declaringType,
+ MethodSignature signature,
+ int occurrence,
+ JavaResourceCompilationUnit javaResourceCompilationUnit,
+ CompilationUnit astRoot) {
+ MethodAttribute method = JDTMethodAttribute.newInstance(
+ declaringType,
+ signature,
+ occurrence,
+ javaResourceCompilationUnit.getCompilationUnit(),
+ javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
+ javaResourceCompilationUnit.getAnnotationEditFormatter());
+ JavaResourceMethod jrm = new SourceMethod(parent, method);
+ jrm.initialize(astRoot);
+ return jrm;
+ }
+
+ private SourceMethod(JavaResourceType parent, MethodAttribute method){
+ super(parent, method);
+ }
+
+ @Override
+ public void initialize(CompilationUnit astRoot) {
+ super.initialize(astRoot);
+ IMethodBinding binding = this.annotatedElement.getBinding(astRoot);
+ this.parameterTypeNames.addAll(this.buildParameterTypeNames(binding));
+ }
+
+
+ // ******** overrides ********
+
+ @Override
+ public void resolveTypes(CompilationUnit astRoot) {
+ super.resolveTypes(astRoot);
+ }
+
+ @Override
+ public void synchronizeWith(CompilationUnit astRoot) {
+ super.synchronizeWith(astRoot);
+ IMethodBinding binding = this.annotatedElement.getBinding(astRoot);
+
+ this.syncParameterTypeNames(this.buildParameterTypeNames(binding));
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.getName());
+ }
+
+
+ // ******** JavaResourceMethod implementation ********
+
+ public boolean isFor(MethodSignature signature, int occurrence) {
+ return this.annotatedElement.matches(signature, occurrence);
+ }
+
+ public boolean returnTypeIsSubTypeOf(String tn) {
+ return this.typeIsSubTypeOf(tn);
+ }
+
+ public boolean returnTypeIsVariablePrimitive() {
+ return this.typeIsVariablePrimitive();
+ }
+
+ public int getReturnTypeModifiers() {
+ return this.getModifiers();
+ }
+
+ @Override
+ protected String getModifiersProperty() {
+ return RETURN_TYPE_MODIFIERS_PROPERTY;
+ }
+
+ public String getReturnTypeName() {
+ return this.getTypeName();
+ }
+
+ @Override
+ protected String getTypeNameProperty() {
+ return RETURN_TYPE_NAME_PROPERTY;
+ }
+
+ public boolean returnTypeIsInterface() {
+ return this.typeIsInterface();
+ }
+
+ @Override
+ protected String getTypeIsInterfaceProperty() {
+ return RETURN_TYPE_IS_INTERFACE_PROPERTY;
+ }
+
+ public boolean returnTypeIsEnum() {
+ return this.typeIsEnum();
+ }
+
+ @Override
+ protected String getTypeIsEnumProperty() {
+ return RETURN_TYPE_IS_ENUM_PROPERTY;
+ }
+
+ public ListIterable<String> getReturnTypeSuperclassNames() {
+ return this.getTypeSuperclassNames();
+ }
+
+ @Override
+ protected String getTypeSuperclassNamesProperty() {
+ return RETURN_TYPE_SUPERCLASS_NAMES_LIST;
+ }
+
+ public Iterable<String> getReturnTypeInterfaceNames() {
+ return this.getTypeInterfaceNames();
+ }
+
+ @Override
+ protected String getTypeInterfaceNamesProperty() {
+ return RETURN_TYPE_INTERFACE_NAMES_COLLECTION;
+ }
+
+ public ListIterable<String> getReturnTypeTypeArgumentNames() {
+ return this.getTypeTypeArgumentNames();
+ }
+
+ @Override
+ protected String getTypeTypeArgumentNamesProperty() {
+ return RETURN_TYPE_TYPE_ARGUMENT_NAMES_LIST;
+ }
+
+ public int getReturnTypeTypeArgumentNamesSize() {
+ return this.getTypeTypeArgumentNamesSize();
+ }
+
+ public String getReturnTypeTypeArgumentName(int index) {
+ return this.getTypeTypeArgumentName(index);
+ }
+
+ // ***** parameter type names
+ public ListIterable<String> getParameterTypeNames() {
+ return new LiveCloneListIterable<String>(this.parameterTypeNames);
+ }
+
+ public int getParametersSize() {
+ return this.parameterTypeNames.size();
+ }
+
+ private void syncParameterTypeNames(List<String> astParameterTypeNames) {
+ this.synchronizeList(astParameterTypeNames, this.parameterTypeNames, getTypeSuperclassNamesProperty());
+ }
+
+ private List<String> buildParameterTypeNames(IMethodBinding methodBinding) {
+ if (methodBinding == null) {
+ return Collections.emptyList();
+ }
+ ArrayList<String> names = new ArrayList<String>();
+ for (ITypeBinding parameterType : methodBinding.getParameterTypes()) {
+ names.add(parameterType.getQualifiedName());
+ }
+ return names;
+ }
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
index a520a24a21..7e5f4be5de 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.core.JpaResourceType;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.jaxb.core.AnnotationProvider;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackageInfoCompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
@@ -58,6 +59,9 @@ public final class SourcePackageInfoCompilationUnit
return EmptyIterable.instance();
}
+ public Iterable<JavaResourceEnum> getEnums() {
+ return EmptyIterable.instance();
+ }
// ********** JpaResourceModel implementation **********
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java
index 13716cd311..b4efa8088e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceType.java
@@ -10,13 +10,12 @@
package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
@@ -27,15 +26,12 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jpt.core.internal.utility.jdt.ASTTools;
import org.eclipse.jpt.core.internal.utility.jdt.JDTType;
import org.eclipse.jpt.core.utility.jdt.Type;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessType;
import org.eclipse.jpt.utility.MethodSignature;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.IntReference;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.utility.internal.iterables.TreeIterable;
@@ -43,34 +39,25 @@ import org.eclipse.jpt.utility.internal.iterables.TreeIterable;
* Java source type
*/
final class SourceType
- extends SourceMember<Type>
+ extends SourceAbstractType<Type>
implements JavaResourceType
{
- private String name;
-
- private String qualifiedName;
-
- private String packageName;
private String superclassQualifiedName;
- private String declaringTypeName;
-
private boolean abstract_; // 'abstract' is a reserved word
private boolean static_; // 'static' is a reserved word
- private boolean memberType;
-
- private boolean hasPrivateNoArgConstructor;
-
private boolean hasNoArgConstructor;
private final Vector<JavaResourceType> types;
- private final Vector<JavaResourceAttribute> fields;
+ private final Vector<JavaResourceEnum> enums;
+
+ private final Vector<JavaResourceField> fields;
- private final Vector<JavaResourceAttribute> methods;
+ private final Vector<JavaResourceMethod> methods;
// ********** construction/initialization **********
@@ -116,25 +103,21 @@ final class SourceType
private SourceType(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) {
super(javaResourceCompilationUnit, type);
this.types = new Vector<JavaResourceType>();
- this.fields = new Vector<JavaResourceAttribute>();
- this.methods = new Vector<JavaResourceAttribute>();
+ this.enums = new Vector<JavaResourceEnum>();
+ this.fields = new Vector<JavaResourceField>();
+ this.methods = new Vector<JavaResourceMethod>();
}
@Override
public void initialize(CompilationUnit astRoot) {
super.initialize(astRoot);
ITypeBinding binding = this.annotatedElement.getBinding(astRoot);
- this.name = this.buildName(binding);
- this.qualifiedName = this.buildQualifiedName(binding);
- this.packageName = this.buildPackageName(binding);
this.superclassQualifiedName = this.buildSuperclassQualifiedName(binding);
- this.declaringTypeName = this.buildDeclaringTypeName(binding);
this.abstract_ = this.buildAbstract(binding);
this.static_ = this.buildStatic(binding);
- this.memberType = this.buildMemberType(binding);
this.hasNoArgConstructor = this.buildHasNoArgConstructor(binding);
- this.hasPrivateNoArgConstructor = this.buildHasPrivateNoArgConstructor(binding);
this.initializeTypes(astRoot);
+ this.initializeEnums(astRoot);
this.initializeFields(astRoot);
this.initializeMethods(astRoot);
}
@@ -146,17 +129,12 @@ final class SourceType
public void synchronizeWith(CompilationUnit astRoot) {
super.synchronizeWith(astRoot);
ITypeBinding binding = this.annotatedElement.getBinding(astRoot);
- this.syncName(this.buildName(binding));
- this.syncQualifiedName(this.buildQualifiedName(binding));
- this.syncPackageName(this.buildPackageName(binding));
this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(binding));
- this.syncDeclaringTypeName(this.buildDeclaringTypeName(binding));
this.syncAbstract(this.buildAbstract(binding));
this.syncStatic(this.buildStatic(binding));
- this.syncMemberType(this.buildMemberType(binding));
this.syncHasNoArgConstructor(this.buildHasNoArgConstructor(binding));
- this.syncHasPrivateNoArgConstructor(this.buildHasPrivateNoArgConstructor(binding));
this.syncTypes(astRoot);
+ this.syncEnums(astRoot);
this.syncFields(astRoot);
this.syncMethods(astRoot);
}
@@ -170,7 +148,7 @@ final class SourceType
this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(this.annotatedElement.getBinding(astRoot)));
- for (JavaResourceAttribute field : this.getFields()) {
+ for (JavaResourceField field : this.getFields()) {
field.resolveTypes(astRoot);
}
@@ -180,67 +158,20 @@ final class SourceType
// and, vice-versa, a removed type can "unresolve" a parameter type
this.syncMethods(astRoot);
- for (JavaResourceAttribute method : this.getMethods()) {
+ for (JavaResourceMethod method : this.getMethods()) {
method.resolveTypes(astRoot);
}
for (JavaResourceType type : this.getTypes()) {
type.resolveTypes(astRoot);
}
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
+ for (JavaResourceEnum enum_ : this.getEnums()) {
+ enum_.resolveTypes(astRoot);
+ }
}
// ******** JavaResourceType implementation ********
- // ***** name
- public String getName() {
- return this.name;
- }
-
- private void syncName(String astName) {
- String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
- }
-
- private String buildName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getName();
- }
-
- // ***** qualified name
- public String getQualifiedName() {
- return this.qualifiedName;
- }
-
- private void syncQualifiedName(String astQualifiedName) {
- String old = this.qualifiedName;
- this.qualifiedName = astQualifiedName;
- this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, astQualifiedName);
- }
-
- private String buildQualifiedName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getQualifiedName();
- }
-
- // ***** package name
- public String getPackageName() {
- return this.packageName;
- }
-
- private void syncPackageName(String astPackageName) {
- String old = this.packageName;
- this.packageName = astPackageName;
- this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, astPackageName);
- }
-
- private String buildPackageName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getPackage().getName();
- }
-
// ***** superclass qualified name
public String getSuperclassQualifiedName() {
return this.superclassQualifiedName;
@@ -260,30 +191,6 @@ final class SourceType
return (superclass == null) ? null : superclass.getTypeDeclaration().getQualifiedName();
}
- // ***** package
- public boolean isIn(IPackageFragment packageFragment) {
- return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName);
- }
-
- // ***** declaring type name
- public String getDeclaringTypeName() {
- return this.declaringTypeName;
- }
-
- private void syncDeclaringTypeName(String astDeclaringTypeName) {
- String old = this.declaringTypeName;
- this.declaringTypeName = astDeclaringTypeName;
- this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, astDeclaringTypeName);
- }
-
- private String buildDeclaringTypeName(ITypeBinding binding) {
- if (binding == null) {
- return null;
- }
- ITypeBinding declaringClass = binding.getDeclaringClass();
- return (declaringClass == null) ? null : declaringClass.getTypeDeclaration().getQualifiedName();
- }
-
// ***** abstract
public boolean isAbstract() {
return this.abstract_;
@@ -314,21 +221,6 @@ final class SourceType
return (binding == null) ? false : Modifier.isStatic(binding.getModifiers());
}
- // ***** member type
- public boolean isMemberType() {
- return this.memberType;
- }
-
- private void syncMemberType(boolean memberType) {
- boolean old = this.memberType;
- this.memberType = memberType;
- this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, memberType);
- }
-
- private boolean buildMemberType(ITypeBinding binding) {
- return (binding == null) ? false : binding.isMember();
- }
-
// ***** no-arg constructor
public boolean hasNoArgConstructor() {
return this.hasNoArgConstructor;
@@ -359,43 +251,6 @@ final class SourceType
return null;
}
- // ***** private no-arg constructor
- public boolean hasPrivateNoArgConstructor() {
- return this.hasPrivateNoArgConstructor;
- }
-
- private void syncHasPrivateNoArgConstructor(boolean hasPrivateNoArgConstructor) {
- boolean old = this.hasPrivateNoArgConstructor;
- this.hasPrivateNoArgConstructor = hasPrivateNoArgConstructor;
- this.firePropertyChanged(PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY, old, hasPrivateNoArgConstructor);
- }
-
- private boolean buildHasPrivateNoArgConstructor(ITypeBinding binding) {
- return (binding == null) ? false : typeHasPrivateNoArgConstructor(binding);
- }
-
- protected static boolean typeHasPrivateNoArgConstructor(ITypeBinding binding) {
- IMethodBinding method = findNoArgConstructor(binding);
- return method != null && Modifier.isPrivate(method.getModifiers());
- }
-
- public boolean isMapped() {
- return ! CollectionTools.isEmpty(getAnnotations());
- }
-
- /**
- * check only persistable attributes
- */
- public boolean hasAnyAnnotatedAttributes() {
- for (JavaResourceAttribute attribute: this.getPersistableAttributes()) {
- if (attribute.isAnnotated()) {
- return true;
- }
- }
- return false;
- }
-
-
// ********** types **********
public Iterable<JavaResourceType> getTypes() {
@@ -466,22 +321,83 @@ final class SourceType
}
+ // ********** enums **********
+
+ public Iterable<JavaResourceEnum> getEnums() {
+ return new LiveCloneIterable<JavaResourceEnum>(this.enums); // read-only
+ }
+
+ public Iterable<JavaResourceEnum> getAllEnums() {
+ return this.getEnums();
+ }
+
+ private JavaResourceEnum getEnum(String enumName, int occurrence) {
+ for (JavaResourceEnum enum_ : this.getEnums()) {
+ if (enum_.isFor(enumName, occurrence)) {
+ return enum_;
+ }
+ }
+ return null;
+ }
+
+ private void addEnum(JavaResourceEnum enum_) {
+ this.addItemToCollection(enum_, this.enums, ENUMS_COLLECTION);
+ }
+
+ private void removeEnums(Collection<JavaResourceEnum> remove) {
+ this.removeItemsFromCollection(remove, this.enums, ENUMS_COLLECTION);
+ }
+
+ private void initializeEnums(CompilationUnit astRoot) {
+ EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(astRoot);
+ CounterMap counters = new CounterMap(enumDeclarations.length);
+ for (EnumDeclaration ed : enumDeclarations) {
+ String tdName = ed.getName().getFullyQualifiedName();
+ int occurrence = counters.increment(tdName);
+ this.enums.add(this.buildEnum(ed, occurrence, astRoot));
+ }
+ }
+
+ private void syncEnums(CompilationUnit astRoot) {
+ EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(astRoot);
+ CounterMap counters = new CounterMap(enumDeclarations.length);
+ HashSet<JavaResourceEnum> enumsToRemove = new HashSet<JavaResourceEnum>(this.enums);
+ for (EnumDeclaration enumDeclaration : enumDeclarations) {
+ String tdName = enumDeclaration.getName().getFullyQualifiedName();
+ int occurrence = counters.increment(tdName);
+
+ JavaResourceEnum enum_ = this.getEnum(tdName, occurrence);
+ if (enum_ == null) {
+ this.addEnum(this.buildEnum(enumDeclaration, occurrence, astRoot));
+ } else {
+ enumsToRemove.remove(enum_);
+ enum_.synchronizeWith(astRoot);
+ }
+ }
+ this.removeEnums(enumsToRemove);
+ }
+
+ private JavaResourceEnum buildEnum(EnumDeclaration nestedEnumDeclaration, int occurrence, CompilationUnit astRoot) {
+ return SourceEnum.newInstance(this.getJavaResourceCompilationUnit(), this.annotatedElement, nestedEnumDeclaration, occurrence, astRoot);
+ }
+
+
// ********** fields **********
- public Iterable<JavaResourceAttribute> getFields() {
- return new LiveCloneIterable<JavaResourceAttribute>(this.fields);
+ public Iterable<JavaResourceField> getFields() {
+ return new LiveCloneIterable<JavaResourceField>(this.fields);
}
- public Iterable<JavaResourceAttribute> getPersistableFields() {
+ public Iterable<JavaResourceField> getPersistableFields() {
return this.getPersistableMembers(this.getFields());
}
- private void addField(JavaResourceAttribute field) {
+ private void addField(JavaResourceField field) {
this.addItemToCollection(field, this.fields, FIELDS_COLLECTION);
}
- private JavaResourceAttribute getField(String fieldName, int occurrence) {
- for (JavaResourceAttribute field : this.getFields()) {
+ private JavaResourceField getField(String fieldName, int occurrence) {
+ for (JavaResourceField field : this.getFields()) {
if (field.isFor(fieldName, occurrence)) {
return field;
}
@@ -489,7 +405,7 @@ final class SourceType
return null;
}
- private void removeFields(Collection<JavaResourceAttribute> remove) {
+ private void removeFields(Collection<JavaResourceField> remove) {
this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION);
}
@@ -508,13 +424,13 @@ final class SourceType
private void syncFields(CompilationUnit astRoot) {
FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(astRoot);
CounterMap counters = new CounterMap(fieldDeclarations.length);
- HashSet<JavaResourceAttribute> fieldsToRemove = new HashSet<JavaResourceAttribute>(this.fields);
+ HashSet<JavaResourceField> fieldsToRemove = new HashSet<JavaResourceField>(this.fields);
for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) {
String fieldName = fragment.getName().getFullyQualifiedName();
int occurrence = counters.increment(fieldName);
- JavaResourceAttribute field = this.getField(fieldName, occurrence);
+ JavaResourceField field = this.getField(fieldName, occurrence);
if (field == null) {
this.addField(this.buildField(fieldName, occurrence, astRoot));
} else {
@@ -526,8 +442,8 @@ final class SourceType
this.removeFields(fieldsToRemove);
}
- private JavaResourceAttribute buildField(String fieldName, int occurrence, CompilationUnit astRoot) {
- return SourceAttribute.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
+ private JavaResourceField buildField(String fieldName, int occurrence, CompilationUnit astRoot) {
+ return SourceField.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
}
// minimize scope of suppressed warnings
@@ -539,16 +455,16 @@ final class SourceType
// ********** methods **********
- public Iterable<JavaResourceAttribute> getMethods() {
- return new LiveCloneIterable<JavaResourceAttribute>(this.methods);
+ public Iterable<JavaResourceMethod> getMethods() {
+ return new LiveCloneIterable<JavaResourceMethod>(this.methods);
}
- public Iterable<JavaResourceAttribute> getPersistableProperties() {
+ public Iterable<JavaResourceMethod> getPersistableProperties() {
return this.getPersistableMembers(this.getMethods());
}
- private JavaResourceAttribute getMethod(MethodSignature signature, int occurrence) {
- for (JavaResourceAttribute method : this.getMethods()) {
+ private JavaResourceMethod getMethod(MethodSignature signature, int occurrence) {
+ for (JavaResourceMethod method : this.getMethods()) {
if (method.isFor(signature, occurrence)) {
return method;
}
@@ -556,11 +472,11 @@ final class SourceType
return null;
}
- private void addMethod(JavaResourceAttribute method) {
+ private void addMethod(JavaResourceMethod method) {
this.addItemToCollection(method, this.methods, METHODS_COLLECTION);
}
- private void removeMethods(Collection<JavaResourceAttribute> remove) {
+ private void removeMethods(Collection<JavaResourceMethod> remove) {
this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION);
}
@@ -577,12 +493,12 @@ final class SourceType
private void syncMethods(CompilationUnit astRoot) {
MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(astRoot);
CounterMap counters = new CounterMap(methodDeclarations.length);
- HashSet<JavaResourceAttribute> methodsToRemove = new HashSet<JavaResourceAttribute>(this.methods);
+ HashSet<JavaResourceMethod> methodsToRemove = new HashSet<JavaResourceMethod>(this.methods);
for (MethodDeclaration methodDeclaration : methodDeclarations) {
MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration);
int occurrence = counters.increment(signature);
- JavaResourceAttribute method = this.getMethod(signature, occurrence);
+ JavaResourceMethod method = this.getMethod(signature, occurrence);
if (method == null) {
this.addMethod(this.buildMethod(signature, occurrence, astRoot));
} else {
@@ -593,62 +509,36 @@ final class SourceType
this.removeMethods(methodsToRemove);
}
- private JavaResourceAttribute buildMethod(MethodSignature signature, int occurrence, CompilationUnit astRoot) {
- return SourceAttribute.newInstance(this, this.annotatedElement, signature, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
+ private JavaResourceMethod buildMethod(MethodSignature signature, int occurrence, CompilationUnit astRoot) {
+ return SourceMethod.newInstance(this, this.annotatedElement, signature, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
}
// ********** attributes **********
- @SuppressWarnings("unchecked")
- public Iterable<JavaResourceAttribute> getPersistableAttributes() {
- return new CompositeIterable<JavaResourceAttribute>(
- this.getPersistableFields(),
- this.getPersistableProperties()
- );
- }
-
- //TODO XmlAccessType.PUBLIC_MEMBER and XmlAccessType.NONE
- public Iterable<JavaResourceAttribute> getPersistableAttributes(XmlAccessType specifiedAccess) {
- if (specifiedAccess == null) {
- throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$
- }
- return (specifiedAccess == XmlAccessType.FIELD) ?
- this.getPersistableAttributesForFieldAccessType() :
- this.getPersistableAttributesForPropertyAccessType();
- }
-
- private Iterable<JavaResourceAttribute> getPersistableAttributesForFieldAccessType() {
- return this.getPersistableFields();
- }
-
- private Iterable<JavaResourceAttribute> getPersistableAttributesForPropertyAccessType() {
- return this.getPersistableProperties();
- }
-
-
- // ********** CounterMap **********
-
- private static class CounterMap {
- private final HashMap<Object, IntReference> counters;
-
- protected CounterMap(int initialCapacity) {
- super();
- this.counters = new HashMap<Object, IntReference>(initialCapacity);
- }
-
- /**
- * Return the incremented count for the specified object.
- */
- int increment(Object o) {
- IntReference counter = this.counters.get(o);
- if (counter == null) {
- counter = new IntReference();
- this.counters.put(o, counter);
- }
- counter.increment();
- return counter.getValue();
- }
- }
-
+// @SuppressWarnings("unchecked")
+// public Iterable<JavaResourceAttribute> getPersistableAttributes() {
+// return new CompositeIterable<JavaResourceAttribute>(
+// this.getPersistableFields(),
+// this.getPersistableProperties()
+// );
+// }
+//
+// //TODO XmlAccessType.PUBLIC_MEMBER and XmlAccessType.NONE
+// public Iterable<JavaResourceAttribute> getPersistableAttributes(XmlAccessType specifiedAccess) {
+// if (specifiedAccess == null) {
+// throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$
+// }
+// return (specifiedAccess == XmlAccessType.FIELD) ?
+// this.getPersistableAttributesForFieldAccessType() :
+// this.getPersistableAttributesForPropertyAccessType();
+// }
+//
+// private Iterable<JavaResourceAttribute> getPersistableAttributesForFieldAccessType() {
+// return this.getPersistableFields();
+// }
+//
+// private Iterable<JavaResourceMethod> getPersistableAttributesForPropertyAccessType() {
+// return this.getPersistableProperties();
+// }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceTypeCompilationUnit.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceTypeCompilationUnit.java
index 1ca345d79f..b95b9e7ee1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceTypeCompilationUnit.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceTypeCompilationUnit.java
@@ -14,11 +14,14 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jpt.core.JpaResourceType;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.jaxb.core.AnnotationProvider;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.utility.CommandExecutor;
import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
@@ -38,7 +41,7 @@ public final class SourceTypeCompilationUnit
* the constructor in a package class (which is what all top-level,
* non-primary classes must be).
*/
- private JavaResourceType type;
+ private AbstractJavaResourceType type;
// ********** construction **********
@@ -48,11 +51,11 @@ public final class SourceTypeCompilationUnit
AnnotationProvider annotationProvider,
AnnotationEditFormatter annotationEditFormatter,
CommandExecutor modifySharedDocumentCommandExecutor) {
- super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the JPA compilation unit is the root of its sub-tree
+ super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the compilation unit is the root of its sub-tree
this.type = this.buildType();
}
- private JavaResourceType buildType() {
+ private AbstractJavaResourceType buildType() {
this.openCompilationUnit();
CompilationUnit astRoot = this.buildASTRoot();
this.closeCompilationUnit();
@@ -70,7 +73,7 @@ public final class SourceTypeCompilationUnit
// ********** JavaResourceNode.Root implementation **********
/**
- * NB: return *all* the persistent types since we build them all
+ * NB: return *all* the types since we build them all
*/
public Iterable<JavaResourceType> getTypes() {
return (this.type == null) ?
@@ -78,6 +81,15 @@ public final class SourceTypeCompilationUnit
this.type.getAllTypes();
}
+ /**
+ * NB: return *all* the enums since we build them all
+ */
+ public Iterable<JavaResourceEnum> getEnums() {
+ return (this.type == null) ?
+ EmptyIterable.<JavaResourceEnum>instance() :
+ this.type.getAllEnums();
+ }
+
// ********** JpaResourceModel implementation **********
@@ -97,14 +109,14 @@ public final class SourceTypeCompilationUnit
// ********** persistent type **********
- private JavaResourceType buildPersistentType(CompilationUnit astRoot) {
- TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot);
+ private AbstractJavaResourceType buildPersistentType(CompilationUnit astRoot) {
+ AbstractTypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot);
return (td == null) ? null : this.buildType(astRoot, td);
}
private void syncType(CompilationUnit astRoot) {
- TypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot);
+ AbstractTypeDeclaration td = this.getPrimaryTypeDeclaration(astRoot);
if (td == null) {
this.syncType_(null);
} else {
@@ -116,8 +128,8 @@ public final class SourceTypeCompilationUnit
}
}
- private void syncType_(JavaResourceType astType) {
- JavaResourceType old = this.type;
+ private void syncType_(AbstractJavaResourceType astType) {
+ AbstractJavaResourceType old = this.type;
this.type = astType;
this.firePropertyChanged(TYPES_COLLECTION, old, astType);
}
@@ -125,8 +137,14 @@ public final class SourceTypeCompilationUnit
// ********** internal **********
- private JavaResourceType buildType(CompilationUnit astRoot, TypeDeclaration typeDeclaration) {
- return SourceType.newInstance(this, typeDeclaration, astRoot);
+ private AbstractJavaResourceType buildType(CompilationUnit astRoot, AbstractTypeDeclaration typeDeclaration) {
+ if (typeDeclaration.getNodeType() == ASTNode.TYPE_DECLARATION) {
+ return SourceType.newInstance(this, (TypeDeclaration) typeDeclaration, astRoot);
+ }
+ else if (typeDeclaration.getNodeType() == ASTNode.ENUM_DECLARATION) {
+ return SourceEnum.newInstance(this, (EnumDeclaration) typeDeclaration, astRoot);
+ }
+ throw new IllegalArgumentException();
}
/**
@@ -139,19 +157,19 @@ public final class SourceTypeCompilationUnit
* Return null if the parser did not resolve the type declaration's binding.
* This can occur if the project JRE is removed (bug 225332).
*/
- private TypeDeclaration getPrimaryTypeDeclaration(CompilationUnit astRoot) {
+ private AbstractTypeDeclaration getPrimaryTypeDeclaration(CompilationUnit astRoot) {
String primaryTypeName = this.getPrimaryTypeName();
for (AbstractTypeDeclaration atd : this.types(astRoot)) {
if (this.nodeIsPrimaryTypeDeclaration(atd, primaryTypeName)) {
- return (atd.resolveBinding() == null) ? null : (TypeDeclaration) atd;
+ return (atd.resolveBinding() == null) ? null : atd;
}
}
return null;
}
private boolean nodeIsPrimaryTypeDeclaration(AbstractTypeDeclaration atd, String primaryTypeName) {
- return (atd.getNodeType() == ASTNode.TYPE_DECLARATION) &&
- atd.getName().getFullyQualifiedName().equals(primaryTypeName);
+ return (atd.getNodeType() == ASTNode.TYPE_DECLARATION || atd.getNodeType() == ASTNode.ENUM_DECLARATION) &&
+ (atd.getName().getFullyQualifiedName().equals(primaryTypeName));
}
private String getPrimaryTypeName() {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyAttributeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyAttributeAnnotation.java
index 23af94d083..d28d73b928 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyAttributeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyAttributeAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyAttributeAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlAnyAttributeAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlAnyAttributeAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlAnyAttributeAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
index 1a71eeb07a..040182514c 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAnyElementAnnotation.java
@@ -24,7 +24,7 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyElementAnnotation;
/**
@@ -47,11 +47,11 @@ public final class SourceXmlAnyElementAnnotation
// ********** constructors **********
- public SourceXmlAnyElementAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlAnyElementAnnotation(JavaResourceField parent, Attribute attribute) {
this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER));
}
- public SourceXmlAnyElementAnnotation(JavaResourceAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ public SourceXmlAnyElementAnnotation(JavaResourceField parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, attribute, daa, annotationAdapter);
this.laxDeclarationAdapter = this.buildLaxAdapter(daa);
this.laxAdapter = this.buildShortCircuitBooleanElementAdapter(this.laxDeclarationAdapter);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttachmentRefAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttachmentRefAnnotation.java
index 701a09b33e..8e022cc56d 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttachmentRefAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttachmentRefAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAttachmentRefAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlAttachmentRefAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlAttachmentRefAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlAttachmentRefAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttributeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttributeAnnotation.java
index cc19c54143..2cd414c8f1 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttributeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlAttributeAnnotation.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAttributeAnnotation;
/**
@@ -47,11 +47,11 @@ public final class SourceXmlAttributeAnnotation
// ********** constructors **********
- public SourceXmlAttributeAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlAttributeAnnotation(JavaResourceField parent, Attribute attribute) {
this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER));
}
- public SourceXmlAttributeAnnotation(JavaResourceAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ public SourceXmlAttributeAnnotation(JavaResourceField parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, attribute, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
index 601c892014..b7f8492664 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementAnnotation.java
@@ -27,7 +27,7 @@ import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
/**
@@ -67,7 +67,7 @@ public final class SourceXmlElementAnnotation
// ********** constructors **********
- public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceAttribute parent, Attribute attribute, int index) {
+ public static SourceXmlElementAnnotation buildSourceXmlElementAnnotation(JavaResourceField parent, Attribute attribute, int index) {
IndexedDeclarationAnnotationAdapter idaa = buildXmlElementDeclarationAnnotationAdapter(index);
IndexedAnnotationAdapter iaa = buildXmlElementAnnotationAdapter(attribute, idaa);
return new SourceXmlElementAnnotation(
@@ -78,7 +78,7 @@ public final class SourceXmlElementAnnotation
}
private SourceXmlElementAnnotation(
- JavaResourceAttribute parent,
+ JavaResourceField parent,
Attribute attribute,
IndexedDeclarationAnnotationAdapter daa,
IndexedAnnotationAdapter annotationAdapter) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementDeclAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementDeclAnnotation.java
index f7f5176314..6dc2a6b72b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementDeclAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementDeclAnnotation.java
@@ -23,7 +23,7 @@ import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.core.utility.jdt.MethodAttribute;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementDeclAnnotation;
/**
@@ -63,7 +63,7 @@ public final class SourceXmlElementDeclAnnotation
// ********** constructors **********
- public SourceXmlElementDeclAnnotation(JavaResourceAttribute parent, MethodAttribute method) {
+ public SourceXmlElementDeclAnnotation(JavaResourceMethod parent, MethodAttribute method) {
super(parent, method, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(method, DECLARATION_ANNOTATION_ADAPTER));
this.nameAdapter = this.buildAnnotationElementAdapter(NAME_ADAPTER);
this.namespaceAdapter = this.buildAnnotationElementAdapter(NAMESPACE_ADAPTER);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
index 57203f6f41..9e988da798 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementRefAnnotation.java
@@ -27,7 +27,7 @@ import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
/**
@@ -55,7 +55,7 @@ public final class SourceXmlElementRefAnnotation
private String type;
// ********** constructors **********
- public static SourceXmlElementRefAnnotation buildSourceXmlElementRefAnnotation(JavaResourceAttribute parent, Attribute attribute, int index) {
+ public static SourceXmlElementRefAnnotation buildSourceXmlElementRefAnnotation(JavaResourceField parent, Attribute attribute, int index) {
IndexedDeclarationAnnotationAdapter idaa = buildXmlElementRefDeclarationAnnotationAdapter(index);
IndexedAnnotationAdapter iaa = buildXmlElementRefAnnotationAdapter(attribute, idaa);
return new SourceXmlElementRefAnnotation(
@@ -66,7 +66,7 @@ public final class SourceXmlElementRefAnnotation
}
private SourceXmlElementRefAnnotation(
- JavaResourceAttribute parent,
+ JavaResourceField parent,
Attribute attribute,
IndexedDeclarationAnnotationAdapter daa,
IndexedAnnotationAdapter annotationAdapter) {
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementWrapperAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementWrapperAnnotation.java
index fe1af2899d..a6534e300a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementWrapperAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlElementWrapperAnnotation.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
/**
@@ -51,11 +51,11 @@ public final class SourceXmlElementWrapperAnnotation
// ********** constructors **********
- public SourceXmlElementWrapperAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlElementWrapperAnnotation(JavaResourceField parent, Attribute attribute) {
this(parent, attribute, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(attribute, DECLARATION_ANNOTATION_ADAPTER));
}
- public SourceXmlElementWrapperAnnotation(JavaResourceAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ public SourceXmlElementWrapperAnnotation(JavaResourceField parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, attribute, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumAnnotation.java
index 7ebfffa48c..4c764f8105 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumAnnotation.java
@@ -16,20 +16,20 @@ import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotation
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
/**
* javax.xml.bind.annotation.XmlEnum
*/
public final class SourceXmlEnumAnnotation
- extends SourceAnnotation<Type>
+ extends SourceAnnotation<AbstractType>
implements XmlEnumAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -40,7 +40,7 @@ public final class SourceXmlEnumAnnotation
private String fullyQualifiedValueClassName;
- public SourceXmlEnumAnnotation(JavaResourceType parent, Type type) {
+ public SourceXmlEnumAnnotation(AbstractJavaResourceType parent, AbstractType type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
this.valueAdapter = this.buildAnnotationElementAdapter(VALUE_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumValueAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumValueAnnotation.java
index b51dd4f339..8af8c494b5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumValueAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlEnumValueAnnotation.java
@@ -15,19 +15,18 @@ import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotation
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.FieldAttribute;
+import org.eclipse.jpt.core.utility.jdt.EnumConstant;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
/**
* javax.xml.bind.annotation.XmlEnumValue
*/
public final class SourceXmlEnumValueAnnotation
- extends SourceAnnotation<Attribute>
+ extends SourceAnnotation<EnumConstant>
implements XmlEnumValueAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -36,8 +35,8 @@ public final class SourceXmlEnumValueAnnotation
private final AnnotationElementAdapter<String> valueAdapter;
private String value;
- public SourceXmlEnumValueAnnotation(JavaResourceAttribute parent, FieldAttribute attribute) {
- super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
+ public SourceXmlEnumValueAnnotation(JavaResourceEnumConstant parent, EnumConstant enumConstant) {
+ super(parent, enumConstant, DECLARATION_ANNOTATION_ADAPTER);
this.valueAdapter = this.buildAnnotationElementAdapter(VALUE_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDAnnotation.java
index 3a011aef29..206eaf9e2a 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlIDAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlIDAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlIDAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlIDAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDREFAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDREFAnnotation.java
index 8cb53ab75d..2fe9079b27 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDREFAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlIDREFAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlIDREFAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlIDREFAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlIDREFAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlIDREFAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlListAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlListAnnotation.java
index 7ce894f74a..2fa7ebbed0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlListAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlListAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlListAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlListAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlListAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlListAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMimeTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMimeTypeAnnotation.java
index 744d6e7ccc..07a3fc6da0 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMimeTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMimeTypeAnnotation.java
@@ -19,7 +19,7 @@ import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlMimeTypeAnnotation;
/**
@@ -35,7 +35,7 @@ public final class SourceXmlMimeTypeAnnotation
private final AnnotationElementAdapter<String> valueAdapter;
private String value;
- public SourceXmlMimeTypeAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlMimeTypeAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
this.valueAdapter = this.buildAnnotationElementAdapter(VALUE_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMixedAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMixedAnnotation.java
index 3fd3ee1a82..95b4a7d4a5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMixedAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlMixedAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlMixedAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlMixedAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlMixedAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRegistryAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRegistryAnnotation.java
index ab56b35e80..cbbdd4bb57 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRegistryAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRegistryAnnotation.java
@@ -11,21 +11,21 @@ package org.eclipse.jpt.jaxb.core.internal.resource.java.source;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Type;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRegistryAnnotation;
/**
* javax.xml.bind.annotation.XmlRegistry
*/
public final class SourceXmlRegistryAnnotation
- extends SourceAnnotation<Type>
+ extends SourceAnnotation<AbstractType>
implements XmlRegistryAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlRegistryAnnotation(JavaResourceType parent, Type type) {
+ public SourceXmlRegistryAnnotation(AbstractJavaResourceType parent, AbstractType type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRootElementAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRootElementAnnotation.java
index e2e807962e..6de6da2598 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRootElementAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlRootElementAnnotation.java
@@ -14,19 +14,19 @@ import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationEleme
import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
/**
* javax.xml.bind.annotation.XmlRootElement
*/
public final class SourceXmlRootElementAnnotation
- extends SourceAnnotation<Type>
+ extends SourceAnnotation<AbstractType>
implements XmlRootElementAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -39,7 +39,7 @@ public final class SourceXmlRootElementAnnotation
private final AnnotationElementAdapter<String> namespaceAdapter;
private String namespace;
- public SourceXmlRootElementAnnotation(JavaResourceType parent, Type type) {
+ public SourceXmlRootElementAnnotation(AbstractJavaResourceType parent, AbstractType type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
this.nameAdapter = this.buildAnnotationElementAdapter(NAME_ADAPTER);
this.namespaceAdapter = this.buildAnnotationElementAdapter(NAMESPACE_ADAPTER);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSeeAlsoAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSeeAlsoAnnotation.java
index 9e60e6cb9d..fe24b2c88b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSeeAlsoAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlSeeAlsoAnnotation.java
@@ -16,13 +16,13 @@ import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationEleme
import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter;
import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSeeAlsoAnnotation;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
@@ -32,7 +32,7 @@ import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
* javax.xml.bind.annotation.XmlSeeAlso
*/
public final class SourceXmlSeeAlsoAnnotation
- extends SourceAnnotation<Type>
+ extends SourceAnnotation<AbstractType>
implements XmlSeeAlsoAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -41,7 +41,7 @@ public final class SourceXmlSeeAlsoAnnotation
private final AnnotationElementAdapter<String[]> valueAdapter;
private final Vector<String> classes = new Vector<String>();
- public SourceXmlSeeAlsoAnnotation(JavaResourceType parent, Type type) {
+ public SourceXmlSeeAlsoAnnotation(AbstractJavaResourceType parent, AbstractType type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
this.valueDeclarationAdapter = buildArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JAXB.XML_SEE_ALSO__VALUE);
this.valueAdapter = this.buildArrayAnnotationElementAdapter(this.valueDeclarationAdapter);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
index aa63e59983..54b8e8c933 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlTypeAnnotation.java
@@ -19,13 +19,13 @@ import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotation
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlTypeAnnotation;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
@@ -35,7 +35,7 @@ import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
* javax.xml.bind.annotation.XmlType
*/
public final class SourceXmlTypeAnnotation
- extends SourceAnnotation<Type>
+ extends SourceAnnotation<AbstractType>
implements XmlTypeAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -62,7 +62,7 @@ public final class SourceXmlTypeAnnotation
private final AnnotationElementAdapter<String[]> propOrderAdapter;
private final Vector<String> propOrder = new Vector<String>();
- public SourceXmlTypeAnnotation(JavaResourceType parent, Type type) {
+ public SourceXmlTypeAnnotation(AbstractJavaResourceType parent, AbstractType type) {
super(parent, type, DECLARATION_ANNOTATION_ADAPTER);
this.factoryClassAdapter = this.buildAnnotationElementAdapter(FACTORY_CLASS_ADAPTER);
this.factoryMethodAdapter = this.buildAnnotationElementAdapter(FACTORY_METHOD_ADAPTER);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlValueAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlValueAnnotation.java
index 4328906b2e..7825d7e9da 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlValueAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlValueAnnotation.java
@@ -13,7 +13,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
import org.eclipse.jpt.core.utility.jdt.Attribute;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.XmlValueAnnotation;
/**
@@ -25,7 +25,7 @@ public final class SourceXmlValueAnnotation
{
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
- public SourceXmlValueAnnotation(JavaResourceAttribute parent, Attribute attribute) {
+ public SourceXmlValueAnnotation(JavaResourceField parent, Attribute attribute) {
super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AbstractJavaResourceType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AbstractJavaResourceType.java
new file mode 100644
index 0000000000..93021d1446
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/AbstractJavaResourceType.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.resource.java;
+
+import org.eclipse.jdt.core.IPackageFragment;
+
+/**
+ * Java source code or binary type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.0
+ * @since 3.0
+ */
+public interface AbstractJavaResourceType
+ extends JavaResourceMember
+{
+ /**
+ * Return the unqualified (short) type name.
+ */
+ String getName();
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ /**
+ * Return the fully qualified type name.
+ */
+ String getQualifiedName();
+ String QUALIFIED_NAME_PROPERTY = "qualifiedName"; //$NON-NLS-1$
+
+ /**
+ * Return the package name.
+ */
+ String getPackageName();
+ String PACKAGE_NAME_PROPERTY = "packageName"; //$NON-NLS-1$
+
+ /**
+ * Return the name of the type's "declaring type".
+ * Return <code>null</code> if the type is a top-level type.
+ */
+ String getDeclaringTypeName();
+ String DECLARING_TYPE_NAME_PROPERTY = "declaringTypeName"; //$NON-NLS-1$
+
+ /**
+ * Return whether the type is a member type.
+ */
+ boolean isMemberType();
+ String MEMBER_TYPE_PROPERTY = "memberType"; //$NON-NLS-1$
+
+ /**
+ * Return whether the type is annotated with any annotations that determine whether and
+ * how the type is persisted
+ */
+ boolean isMapped();
+
+ boolean isIn(IPackageFragment packageFragment);
+
+
+ /**
+ * Return the immediately nested types (children).
+ */
+ Iterable<JavaResourceType> getTypes();
+ String TYPES_COLLECTION = "types"; //$NON-NLS-1$
+
+ /**
+ * Return all the types; the type itself, its children, its grandchildren,
+ * etc.
+ */
+ Iterable<JavaResourceType> getAllTypes();
+
+ /**
+ * Return the immediately nested enums (children).
+ */
+ Iterable<JavaResourceEnum> getEnums();
+ String ENUMS_COLLECTION = "enums"; //$NON-NLS-1$
+
+ /**
+ * Return all the enums; the enum itself, its children, its grandchildren,
+ * etc.
+ */
+ Iterable<JavaResourceEnum> getAllEnums();
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnum.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnum.java
new file mode 100644
index 0000000000..7409d862bd
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnum.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.resource.java;
+
+/**
+ * Java source code or binary type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.0
+ * @since 3.0
+ */
+public interface JavaResourceEnum
+ extends AbstractJavaResourceType
+{
+
+
+ // ********** enum constants **********
+
+ /**
+ * Return the enum's enum constants.
+ */
+ Iterable<JavaResourceEnumConstant> getEnumConstants();
+ String ENUM_CONSTANTS_COLLECTION = "enumConstants"; //$NON-NLS-1$
+//
+// /**
+// * Return the type's persistable fields.
+// */
+// Iterable<JavaResourceAttribute> getPersistableFields();
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnumConstant.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnumConstant.java
new file mode 100644
index 0000000000..551dfb3e7b
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceEnumConstant.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jaxb.core.resource.java;
+
+/**
+ * Java source code or binary enum constant
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.0
+ * @since 3.0
+ */
+public interface JavaResourceEnumConstant
+ extends JavaResourceMember
+{
+ /**
+ * The Java resource enum constant's name does not change.
+ */
+ String getName();
+
+ /**
+ * Return a null annotation for the specified annotation name.
+ * Return null if the specified annotation name is null.
+ * The corresponding AnnotationDefinition must implement #buildNullAnnotation()
+ * {@link AnnotationDefinition#buildNullAnnotation(JavaResourceMember,
+ * org.eclipse.jpt.core.utility.jdt.Member)}
+ */
+ Annotation buildNullAnnotation(String annotationName);
+
+}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAttribute.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceField.java
index 7f074507a9..e7ff74c1fc 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceAttribute.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceField.java
@@ -9,11 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.resource.java;
-import org.eclipse.jpt.utility.MethodSignature;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
/**
- * Java source code or binary attribute (field or method)
+ * Java source code or binary field
*
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -24,39 +23,13 @@ import org.eclipse.jpt.utility.internal.iterables.ListIterable;
* @version 3.0
* @since 3.0
*/
-public interface JavaResourceAttribute
+public interface JavaResourceField
extends JavaResourceMember
{
/**
- * The Java resource attribute's name does not change.
+ * The Java resource field's name does not change.
*/
String getName();
-
- /**
- * Return a null annotation for the specified annotation name.
- * Return null if the specified annotation name is null.
- * The corresponding AnnotationDefinition must implement #buildNullAnnotation()
- * {@link AnnotationDefinition#buildNullAnnotation(JavaResourceMember,
- * org.eclipse.jpt.core.utility.jdt.Member)}
- */
- Annotation buildNullAnnotation(String annotationName);
-
- /**
- * Whether the Java resource persistent attribute is a field does not change.
- */
- boolean isField();
-
- /**
- * Whether the Java resource persistent attribute is a property does not change.
- */
- boolean isProperty();
-
- /**
- * Return the access type explicitly specified by the javax.persistence.Access annotation.
- * Return null if the Access annotation is not present.
- * For JPA 1.0 this is always going to return null; Access annotation is not supported in 1.0.
- */
- XmlAccessType getSpecifiedAccess();
/**
* Return whether the attribute's type implements or extends the specified
@@ -71,12 +44,6 @@ public interface JavaResourceAttribute
boolean typeIsVariablePrimitive();
/**
- * Return whether the Java resource persistent attribute is for the specified
- * method.
- */
- boolean isFor(MethodSignature methodSignature, int occurrence);
-
- /**
* @see java.lang.reflect.Modifier
*/
int getModifiers();
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceMember.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceMember.java
index f02b804d4c..f55c554258 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceMember.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceMember.java
@@ -47,13 +47,13 @@ public interface JavaResourceMember
String PERSISTABLE_PROPERTY = "persistable"; //$NON-NLS-1$
/**
- * Return whether the type is final.
+ * Return whether the member is final.
*/
boolean isFinal();
String FINAL_PROPERTY = "final"; //$NON-NLS-1$
/**
- * Return whether the Java resource persistent member is for the specified
+ * Return whether the Java resource member is for the specified
* member.
*/
boolean isFor(String memberName, int occurrence);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceNode.java
index 6f7df4c208..63c75df6bd 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceNode.java
@@ -75,7 +75,13 @@ public interface JavaResourceNode
* Return the root's Java resource types.
*/
Iterable<JavaResourceType> getTypes();
- String TYPES_COLLECTION = "type"; //$NON-NLS-1$
+ String TYPES_COLLECTION = "types"; //$NON-NLS-1$
+
+ /**
+ * Return the root's Java resource enums.
+ */
+ Iterable<JavaResourceEnum> getEnums();
+ String ENUMS_COLLECTION = "enums"; //$NON-NLS-1$
/**
* Called (via a hook in change notification) whenever anything in the
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceType.java
index e9ac3df638..ee1199ac9f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/JavaResourceType.java
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.resource.java;
-import org.eclipse.jdt.core.IPackageFragment;
-
/**
* Java source code or binary type.
* <p>
@@ -24,25 +22,8 @@ import org.eclipse.jdt.core.IPackageFragment;
* @since 2.0
*/
public interface JavaResourceType
- extends JavaResourceMember
+ extends AbstractJavaResourceType
{
- /**
- * Return the unqualified (short) type name.
- */
- String getName();
- String NAME_PROPERTY = "name"; //$NON-NLS-1$
-
- /**
- * Return the fully qualified type name.
- */
- String getQualifiedName();
- String QUALIFIED_NAME_PROPERTY = "qualifiedName"; //$NON-NLS-1$
-
- /**
- * Return the package name.
- */
- String getPackageName();
- String PACKAGE_NAME_PROPERTY = "packageName"; //$NON-NLS-1$
/**
* Return the fully qualified name of the type's superclass.
@@ -51,23 +32,11 @@ public interface JavaResourceType
String SUPERCLASS_QUALIFIED_NAME_PROPERTY = "superclassQualifiedName"; //$NON-NLS-1$
/**
- * Return the name of the type's "declaring type".
- * Return <code>null</code> if the type is a top-level type.
- */
- String getDeclaringTypeName();
- String DECLARING_TYPE_NAME_PROPERTY = "declaringTypeName"; //$NON-NLS-1$
-
- /**
* Return whether the type is abstract.
*/
boolean isAbstract();
String ABSTRACT_PROPERTY = "abstract"; //$NON-NLS-1$
- /**
- * Return whether the type is a member type.
- */
- boolean isMemberType();
- String MEMBER_TYPE_PROPERTY = "memberType"; //$NON-NLS-1$
/**
* Return whether the type is static.
@@ -81,42 +50,10 @@ public interface JavaResourceType
boolean hasNoArgConstructor();
String NO_ARG_CONSTRUCTOR_PROPERTY = "noArgConstructor"; //$NON-NLS-1$
- /**
- * Return whether the type has a private no-arg constructor
- */
- boolean hasPrivateNoArgConstructor();
- String PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY = "privateNoArgConstructor"; //$NON-NLS-1$
-
- /**
- * Return whether the type is annotated with any annotations that determine whether and
- * how the type is persisted
- */
- boolean isMapped();
-
- /**
- * Return whether the type has any attributes that have JAXB annotations
- * on them (which can be used to infer the type's access type).
- */
- boolean hasAnyAnnotatedAttributes();
-
- boolean isIn(IPackageFragment packageFragment);
-
// ********** types **********
/**
- * Return the immediately nested types (children).
- */
- Iterable<JavaResourceType> getTypes();
- String TYPES_COLLECTION = "types"; //$NON-NLS-1$
-
- /**
- * Return all the types; the type itself, its children, its grandchildren,
- * etc.
- */
- Iterable<JavaResourceType> getAllTypes();
-
- /**
* Return the immediately nested persistable types.
*/
Iterable<JavaResourceType> getPersistableTypes();
@@ -127,13 +64,13 @@ public interface JavaResourceType
/**
* Return the type's fields.
*/
- Iterable<JavaResourceAttribute> getFields();
+ Iterable<JavaResourceField> getFields();
String FIELDS_COLLECTION = "fields"; //$NON-NLS-1$
/**
* Return the type's persistable fields.
*/
- Iterable<JavaResourceAttribute> getPersistableFields();
+ Iterable<JavaResourceField> getPersistableFields();
// ********** methods **********
@@ -141,28 +78,28 @@ public interface JavaResourceType
/**
* Return the type's methods. This returns *all* methods from the JDT Type
*/
- Iterable<JavaResourceAttribute> getMethods();
+ Iterable<JavaResourceMethod> getMethods();
String METHODS_COLLECTION = "methods"; //$NON-NLS-1$
-
- /**
- * Return the type's persistable properties. This returns only the getter methods
- * that match the JavaBeans criteria for JPA, hence the name properties instead of methods
- */
- Iterable<JavaResourceAttribute> getPersistableProperties();
-
-
- // ********** attributes **********
-
- /**
- * Return the type's persistable fields and properties.
- * {@link JavaResourceMember#isPersistable()}
- */
- Iterable<JavaResourceAttribute> getPersistableAttributes();
-
- /**
- * Return the persistable properties and/or fields given the non-null specified access type
- * {@link JavaResourceMember#isPersistable()}
- */
- Iterable<JavaResourceAttribute> getPersistableAttributes(XmlAccessType specifiedAccess);
+//
+// /**
+// * Return the type's persistable properties. This returns only the getter methods
+// * that match the JavaBeans criteria for JPA, hence the name properties instead of methods
+// */
+// Iterable<JavaResourceMethod> getPersistableProperties();
+//
+//
+// // ********** attributes **********
+//
+// /**
+// * Return the type's persistable fields and properties.
+// * {@link JavaResourceMember#isPersistable()}
+// */
+// Iterable<JavaResourceAttribute> getPersistableAttributes();
+//
+// /**
+// * Return the persistable properties and/or fields given the non-null specified access type
+// * {@link JavaResourceMember#isPersistable()}
+// */
+// Iterable<JavaResourceAttribute> getPersistableAttributes(XmlAccessType specifiedAccess);
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java
index 8b150d798b..1d37830624 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaPersistentClassTests.java
@@ -25,7 +25,7 @@ import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlAccessOrder;
import org.eclipse.jpt.jaxb.core.context.XmlAccessType;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorOrderAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAccessorTypeAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
@@ -112,7 +112,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getFactoryClass());
@@ -141,7 +141,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getFactoryClass());
@@ -169,7 +169,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getFactoryMethod());
@@ -198,7 +198,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getFactoryMethod());
@@ -226,7 +226,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getSchemaTypeName());
@@ -255,7 +255,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getSchemaTypeName());
@@ -283,7 +283,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getNamespace());
@@ -312,7 +312,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getNamespace());
@@ -340,7 +340,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createXmlTypeWithAccessorType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertEquals(XmlAccessType.PROPERTY, persistentClass.getSpecifiedAccessType());
assertEquals(XmlAccessType.PROPERTY, persistentClass.getAccessType());
@@ -371,7 +371,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createXmlTypeWithAccessorType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertEquals(XmlAccessType.PROPERTY, persistentClass.getSpecifiedAccessType());
assertEquals(XmlAccessType.PROPERTY, persistentClass.getAccessType());
@@ -465,7 +465,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testModifyAccessOrder() throws Exception {
createXmlTypeWithAccessorOrder();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getSpecifiedAccessOrder());
assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getAccessOrder());
@@ -487,7 +487,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testUpdateAccessOrder() throws Exception {
createXmlTypeWithAccessorOrder();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getSpecifiedAccessOrder());
assertEquals(XmlAccessOrder.ALPHABETICAL, persistentClass.getAccessOrder());
@@ -515,7 +515,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testGetPropOrder() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
ListIterator<String> props = persistentClass.getPropOrder().iterator();
assertFalse(props.hasNext());
@@ -542,7 +542,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testGetPropOrderSize() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertEquals(0, persistentClass.getPropOrderSize());
@@ -560,7 +560,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testAddProp() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
persistentClass.addProp(0, "bar");
persistentClass.addProp(0, "foo");
@@ -578,7 +578,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testAddProp2() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
persistentClass.addProp(0, "bar");
persistentClass.addProp(1, "foo");
@@ -596,7 +596,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testRemoveProp() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
persistentClass.addProp(0, "bar");
persistentClass.addProp(1, "foo");
@@ -624,7 +624,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testMoveProp() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
persistentClass.addProp(0, "bar");
persistentClass.addProp(1, "foo");
@@ -663,7 +663,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
public void testSyncXmlNsPrefixes() throws Exception {
this.createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
ListIterator<String> props = persistentClass.getPropOrder().iterator();
assertFalse(props.hasNext());
@@ -776,7 +776,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getRootElement());
assertFalse(persistentClass.isRootElement());
@@ -798,7 +798,7 @@ public class GenericJavaPersistentClassTests extends JaxbContextModelTestCase
createTypeWithXmlType();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(persistentClass.getRootElement());
assertFalse(persistentClass.isRootElement());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
index dedca9aef0..6e21ab2044 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/context/java/GenericJavaXmlRootElementTests.java
@@ -19,7 +19,7 @@ import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.XmlRootElement;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlRootElementAnnotation;
import org.eclipse.jpt.jaxb.core.tests.internal.context.JaxbContextModelTestCase;
import org.eclipse.jpt.utility.internal.CollectionTools;
@@ -53,7 +53,7 @@ public class GenericJavaXmlRootElementTests extends JaxbContextModelTestCase
createTypeWithXmlTypeWithXmlRootElement();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(contextRootElement.getNamespace());
@@ -72,7 +72,7 @@ public class GenericJavaXmlRootElementTests extends JaxbContextModelTestCase
createTypeWithXmlTypeWithXmlRootElement();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(contextRootElement.getNamespace());
@@ -98,7 +98,7 @@ public class GenericJavaXmlRootElementTests extends JaxbContextModelTestCase
createTypeWithXmlTypeWithXmlRootElement();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(contextRootElement.getName());
@@ -117,7 +117,7 @@ public class GenericJavaXmlRootElementTests extends JaxbContextModelTestCase
createTypeWithXmlTypeWithXmlRootElement();
JaxbPersistentClass persistentClass = CollectionTools.get(getContextRoot().getPersistentClasses(), 0);
XmlRootElement contextRootElement = persistentClass.getRootElement();
- JavaResourceType resourceType = persistentClass.getJavaResourceType();
+ AbstractJavaResourceType resourceType = persistentClass.getJavaResourceType();
assertNull(contextRootElement.getName());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java
index 0bbec6a60a..20026d4f7f 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JavaResourceModelTestCase.java
@@ -21,9 +21,13 @@ import org.eclipse.jpt.jaxb.core.AnnotationProvider;
import org.eclipse.jpt.jaxb.core.internal.GenericAnnotationProvider;
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourcePackageInfoCompilationUnit;
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceTypeCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.AbstractJavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackageInfoCompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
@@ -143,21 +147,33 @@ public abstract class JavaResourceModelTestCase
}
protected JavaResourceType buildJavaResourceType(ICompilationUnit cu) {
+ return (JavaResourceType) this.buildJavaResourceType_(cu);
+ }
+
+ protected JavaResourceEnum buildJavaResourceEnum(ICompilationUnit cu) {
+ return (JavaResourceEnum) this.buildJavaResourceType_(cu);
+ }
+
+ private AbstractJavaResourceType buildJavaResourceType_(ICompilationUnit cu) {
this.javaResourceCompilationUnit = this.buildJavaResourceCompilationUnit(cu);
this.javaResourceCompilationUnit.resolveTypes();
return this.hackJavaResourceType();
}
- protected JavaResourceAttribute getField(JavaResourceType type, int index) {
+ protected JavaResourceField getField(JavaResourceType type, int index) {
return CollectionTools.get(type.getFields(), index);
}
- protected JavaResourceAttribute getMethod(JavaResourceType type, int index) {
+ protected JavaResourceMethod getMethod(JavaResourceType type, int index) {
return CollectionTools.get(type.getMethods(), index);
}
- protected JavaResourceType hackJavaResourceType() {
- return (JavaResourceType) ReflectionTools.getFieldValue(this.javaResourceCompilationUnit, "type");
+ protected JavaResourceEnumConstant getEnumConstant(JavaResourceEnum resourceEnum, int index) {
+ return CollectionTools.get(resourceEnum.getEnumConstants(), index);
+ }
+
+ protected AbstractJavaResourceType hackJavaResourceType() {
+ return (AbstractJavaResourceType) ReflectionTools.getFieldValue(this.javaResourceCompilationUnit, "type");
}
protected JavaResourceCompilationUnit buildJavaResourceCompilationUnit(ICompilationUnit cu) {
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyAttributeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyAttributeAnnotationTests.java
index c4d72e2b2f..b3dcc09b9f 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyAttributeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyAttributeAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyAttributeAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlAnyAttributeAnnotationTests extends JaxbJavaResourceModelTestCas
public void testGetXmlAnyAttribute() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyAttribute();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyAttributeAnnotation xmlAnyAttributeAnnotation = (XmlAnyAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ATTRIBUTE);
assertTrue(xmlAnyAttributeAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyElementAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyElementAnnotationTests.java
index 2cbd003b11..770e443f9c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyElementAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAnyElementAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAnyElementAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -68,7 +68,7 @@ public class XmlAnyElementAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertTrue(xmlAnyElementAnnotation != null);
@@ -79,7 +79,7 @@ public class XmlAnyElementAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetLax() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyElementWithBooleanElement("lax");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertEquals(Boolean.TRUE, xmlAnyElementAnnotation.getLax());
@@ -88,7 +88,7 @@ public class XmlAnyElementAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetLax() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertNotNull(xmlAnyElementAnnotation);
@@ -107,7 +107,7 @@ public class XmlAnyElementAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyElementWithValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertTrue(xmlAnyElementAnnotation != null);
@@ -118,7 +118,7 @@ public class XmlAnyElementAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlAnyElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAnyElementAnnotation xmlAnyElementAnnotation = (XmlAnyElementAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ANY_ELEMENT);
assertNull(xmlAnyElementAnnotation.getValue());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttachmentRefAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttachmentRefAnnotationTests.java
index 51a4533042..fbdb853078 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttachmentRefAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttachmentRefAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAttachmentRefAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlAttachmentRefAnnotationTests extends JaxbJavaResourceModelTestCa
public void testGetXmlAttachmentRef() throws Exception {
ICompilationUnit cu = this.createTestXmlAttachmentRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttachmentRefAnnotation xmlAttachmentRefAnnotation = (XmlAttachmentRefAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTACHMENT_REF);
assertTrue(xmlAttachmentRefAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttributeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttributeAnnotationTests.java
index 642ee5750d..2b893dc537 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttributeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlAttributeAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlAttributeAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -77,7 +77,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetName() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertTrue(xmlAttributeAnnotation != null);
@@ -87,7 +87,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlAttribute();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertTrue(xmlAttributeAnnotation != null);
@@ -99,7 +99,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlAttribute();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertNull(xmlAttributeAnnotation.getName());
@@ -118,7 +118,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertTrue(xmlAttributeAnnotation != null);
@@ -128,7 +128,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlAttribute();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertNull(xmlAttributeAnnotation.getNamespace());
@@ -147,7 +147,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithBooleanElement("required");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertEquals(Boolean.TRUE, xmlAttributeAnnotation.getRequired());
@@ -156,7 +156,7 @@ public class XmlAttributeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlAttribute();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlAttributeAnnotation xmlAttributeAnnotation = (XmlAttributeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ATTRIBUTE);
assertNotNull(xmlAttributeAnnotation);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
index d728b256bb..661eb1fe9c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -96,7 +96,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
@@ -106,7 +106,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
@@ -121,7 +121,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getName());
@@ -140,7 +140,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
@@ -150,7 +150,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getNamespace());
@@ -169,7 +169,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithDefaultValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
@@ -179,7 +179,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getDefaultValue());
@@ -198,7 +198,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("nillable");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertEquals(Boolean.TRUE, xmlElementAnnotation.getNillable());
@@ -207,7 +207,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNotNull(xmlElementAnnotation);
@@ -226,7 +226,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithBooleanElement("required");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertEquals(Boolean.TRUE, xmlElementAnnotation.getRequired());
@@ -235,7 +235,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNotNull(xmlElementAnnotation);
@@ -254,7 +254,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithType();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
@@ -265,7 +265,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElement();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertNull(xmlElementAnnotation.getType());
@@ -284,7 +284,7 @@ public class XmlElementAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testAddXmlElementAnnotation() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementAnnotation xmlElementAnnotation = (XmlElementAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT);
assertTrue(xmlElementAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementDeclAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementDeclAnnotationTests.java
index fecc1e428d..db83da1bd4 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementDeclAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementDeclAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementDeclAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -91,9 +91,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getName());
}
@@ -101,9 +101,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertNull(xmlElementDeclAnnotation.getName());
assertNull(xmlElementDeclAnnotation.getNamespace());
@@ -116,9 +116,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getName());
xmlElementDeclAnnotation.setName(XML_ELEMENT_DECL_NAME);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getName());
@@ -135,9 +135,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_NAMESPACE, xmlElementDeclAnnotation.getNamespace());
}
@@ -145,9 +145,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getNamespace());
xmlElementDeclAnnotation.setNamespace(XML_ELEMENT_DECL_NAMESPACE);
assertEquals(XML_ELEMENT_DECL_NAMESPACE, xmlElementDeclAnnotation.getNamespace());
@@ -164,9 +164,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithDefaultValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_DEFAULT_VALUE, xmlElementDeclAnnotation.getDefaultValue());
}
@@ -174,9 +174,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetDefaultValue() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getDefaultValue());
xmlElementDeclAnnotation.setDefaultValue(XML_ELEMENT_DECL_DEFAULT_VALUE);
assertEquals(XML_ELEMENT_DECL_DEFAULT_VALUE, xmlElementDeclAnnotation.getDefaultValue());
@@ -193,9 +193,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetScope() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithScope();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_SCOPE, xmlElementDeclAnnotation.getScope());
assertEquals("javax.xml.bind.annotation." + XML_ELEMENT_DECL_SCOPE, xmlElementDeclAnnotation.getFullyQualifiedScopeClassName());
@@ -204,9 +204,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetScope() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getScope());
xmlElementDeclAnnotation.setScope(XML_ELEMENT_DECL_SCOPE);
assertEquals(XML_ELEMENT_DECL_SCOPE, xmlElementDeclAnnotation.getScope());
@@ -223,9 +223,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetSubstitutionHeadName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithSubstitutionHeadName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getSubstitutionHeadName());
}
@@ -233,9 +233,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetSubstitutionHeadName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getSubstitutionHeadName());
xmlElementDeclAnnotation.setSubstitutionHeadName(XML_ELEMENT_DECL_NAME);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getSubstitutionHeadName());
@@ -252,9 +252,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetSubstitutionHeadNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDeclWithSubstitutionHeadNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertTrue(xmlElementDeclAnnotation != null);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getSubstitutionHeadNamespace());
}
@@ -262,9 +262,9 @@ public class XmlElementDeclAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetSubstitutionHeadNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementDecl();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = getMethod(resourceType, 0);
- XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_DECL);
+ XmlElementDeclAnnotation xmlElementDeclAnnotation = (XmlElementDeclAnnotation) resourceMethod.getAnnotation(JAXB.XML_ELEMENT_DECL);
assertNull(xmlElementDeclAnnotation.getSubstitutionHeadNamespace());
xmlElementDeclAnnotation.setSubstitutionHeadNamespace(XML_ELEMENT_DECL_NAME);
assertEquals(XML_ELEMENT_DECL_NAME, xmlElementDeclAnnotation.getSubstitutionHeadNamespace());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
index 4d94efa066..50270200cf 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementRefAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementRefAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -78,7 +78,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertTrue(xmlElementRefAnnotation != null);
@@ -88,7 +88,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertTrue(xmlElementRefAnnotation != null);
@@ -100,7 +100,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertNull(xmlElementRefAnnotation.getName());
@@ -119,7 +119,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertTrue(xmlElementRefAnnotation != null);
@@ -129,7 +129,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertNull(xmlElementRefAnnotation.getNamespace());
@@ -148,7 +148,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testGetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithType();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertTrue(xmlElementRefAnnotation != null);
@@ -159,7 +159,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testSetType() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRef();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertNull(xmlElementRefAnnotation.getType());
@@ -178,7 +178,7 @@ public class XmlElementRefAnnotationTests extends JaxbJavaResourceModelTestCase
public void testAddXmlElementRefAnnotation() throws Exception {
ICompilationUnit cu = this.createTestXmlElementRefWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementRefAnnotation xmlElementRefAnnotation = (XmlElementRefAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_ELEMENT_REF);
assertTrue(xmlElementRefAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementWrapperAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementWrapperAnnotationTests.java
index c7ecab5e9b..e40761e9ed 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementWrapperAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlElementWrapperAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlElementWrapperAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -77,7 +77,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testGetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapperWithName();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertTrue(xmlElementWrapperAnnotation != null);
@@ -87,7 +87,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapper();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertTrue(xmlElementWrapperAnnotation != null);
@@ -100,7 +100,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testSetName() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapper();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertNull(xmlElementWrapperAnnotation.getName());
@@ -119,7 +119,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testGetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapperWithNamespace();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertTrue(xmlElementWrapperAnnotation != null);
@@ -129,7 +129,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testSetNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapper();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertNull(xmlElementWrapperAnnotation.getNamespace());
@@ -148,7 +148,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testGetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapperWithBooleanElement("nillable");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertEquals(Boolean.TRUE, xmlElementWrapperAnnotation.getNillable());
@@ -157,7 +157,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testSetNillable() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapper();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertNotNull(xmlElementWrapperAnnotation);
@@ -176,7 +176,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testGetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapperWithBooleanElement("required");
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertEquals(Boolean.TRUE, xmlElementWrapperAnnotation.getRequired());
@@ -185,7 +185,7 @@ public class XmlElementWrapperAnnotationTests extends JaxbJavaResourceModelTestC
public void testSetRequired() throws Exception {
ICompilationUnit cu = this.createTestXmlElementWrapper();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlElementWrapperAnnotation xmlElementWrapperAnnotation = (XmlElementWrapperAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ELEMENT_WRAPPER);
assertNotNull(xmlElementWrapperAnnotation);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumAnnotationTests.java
index ab4376356c..330403617c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -26,26 +26,26 @@ public class XmlEnumAnnotationTests extends JaxbJavaResourceModelTestCase {
}
private ICompilationUnit createTestXmlEnum() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
+ return this.createTestEnum(new DefaultEnumAnnotationWriter() {
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ENUM);
}
@Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
+ public void appendEnumAnnotationTo(StringBuilder sb) {
sb.append("@XmlEnum");
}
});
}
private ICompilationUnit createTestXmlEnumWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
+ return this.createTestEnum(new DefaultEnumAnnotationWriter() {
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ENUM);
}
@Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
+ public void appendEnumAnnotationTo(StringBuilder sb) {
sb.append("@XmlEnum(value = " + XML_ENUM_JAVA_TYPE + ".class)");
}
});
@@ -53,18 +53,18 @@ public class XmlEnumAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlEnum();
- JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceEnum resourceEnum = this.buildJavaResourceEnum(cu);
- XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceType.getAnnotation(JAXB.XML_ENUM);
+ XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
assertTrue(xmlEnumAnnotation != null);
assertNull(xmlEnumAnnotation.getValue());
}
public void testGetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlEnumWithValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceEnum resourceEnum = this.buildJavaResourceEnum(cu);
- XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceType.getAnnotation(JAXB.XML_ENUM);
+ XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
assertTrue(xmlEnumAnnotation != null);
assertEquals(XML_ENUM_JAVA_TYPE, xmlEnumAnnotation.getValue());
assertEquals("java.lang." + XML_ENUM_JAVA_TYPE, xmlEnumAnnotation.getFullyQualifiedValueClassName());
@@ -72,9 +72,9 @@ public class XmlEnumAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlEnum();
- JavaResourceType resourceType = buildJavaResourceType(cu);
+ JavaResourceEnum resourceEnum = this.buildJavaResourceEnum(cu);
- XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceType.getAnnotation(JAXB.XML_ENUM);
+ XmlEnumAnnotation xmlEnumAnnotation = (XmlEnumAnnotation) resourceEnum.getAnnotation(JAXB.XML_ENUM);
assertNull(xmlEnumAnnotation.getValue());
xmlEnumAnnotation.setValue(XML_ENUM_JAVA_TYPE);
assertEquals(XML_ENUM_JAVA_TYPE, xmlEnumAnnotation.getValue());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumValueAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumValueAnnotationTests.java
index f82a4bd648..e376592a8c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumValueAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlEnumValueAnnotationTests.java
@@ -12,8 +12,8 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnum;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceEnumConstant;
import org.eclipse.jpt.jaxb.core.resource.java.XmlEnumValueAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -27,13 +27,13 @@ public class XmlEnumValueAnnotationTests extends JaxbJavaResourceModelTestCase {
}
private ICompilationUnit createTestXmlEnumValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
+ return this.createTestEnum(new DefaultEnumAnnotationWriter() {
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ENUM_VALUE);
}
@Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ public void appendSundayEnumConstantAnnotationTo(StringBuilder sb) {
sb.append("@XmlEnumValue");
}
});
@@ -44,13 +44,13 @@ public class XmlEnumValueAnnotationTests extends JaxbJavaResourceModelTestCase {
}
private ICompilationUnit createTestXmlEnumValueWithStringElement(final String element, final String value) throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
+ return this.createTestEnum(new DefaultEnumAnnotationWriter() {
@Override
public Iterator<String> imports() {
return new ArrayIterator<String>(JAXB.XML_ENUM_VALUE);
}
@Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
+ public void appendSundayEnumConstantAnnotationTo(StringBuilder sb) {
sb.append("@XmlEnumValue(" + element + " = \"" + value + "\")");
}
});
@@ -58,43 +58,43 @@ public class XmlEnumValueAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlEnumValue() throws Exception {
ICompilationUnit cu = this.createTestXmlEnumValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceEnum resourceEnum = buildJavaResourceEnum(cu);
+ JavaResourceEnumConstant enumConstant = getEnumConstant(resourceEnum, 0);
- XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ENUM_VALUE);
+ XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) enumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
assertTrue(xmlEnumValueAnnotation != null);
- resourceAttribute.removeAnnotation(JAXB.XML_ENUM_VALUE);
+ enumConstant.removeAnnotation(JAXB.XML_ENUM_VALUE);
assertSourceDoesNotContain("@XmlEnumValue", cu);
}
public void testGetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlEnumValueWithValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceEnum resourceEnum = buildJavaResourceEnum(cu);
+ JavaResourceEnumConstant enumConstant = getEnumConstant(resourceEnum, 0);
- XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ENUM_VALUE);
+ XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) enumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
assertTrue(xmlEnumValueAnnotation != null);
assertEquals(XML_ENUM_VALUE_VALUE, xmlEnumValueAnnotation.getValue());
}
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlEnumValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceEnum resourceEnum = buildJavaResourceEnum(cu);
+ JavaResourceEnumConstant enumConstant = getEnumConstant(resourceEnum, 0);
- XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ENUM_VALUE);
+ XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) enumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
assertTrue(xmlEnumValueAnnotation != null);
assertNull(xmlEnumValueAnnotation.getValue());
}
public void testSetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlEnumValue();
- JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceEnum resourceEnum = buildJavaResourceEnum(cu);
+ JavaResourceEnumConstant enumConstant = getEnumConstant(resourceEnum, 0);
- XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ENUM_VALUE);
+ XmlEnumValueAnnotation xmlEnumValueAnnotation = (XmlEnumValueAnnotation) enumConstant.getAnnotation(JAXB.XML_ENUM_VALUE);
assertNull(xmlEnumValueAnnotation.getValue());
xmlEnumValueAnnotation.setValue(XML_ENUM_VALUE_VALUE);
assertEquals(XML_ENUM_VALUE_VALUE, xmlEnumValueAnnotation.getValue());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDAnnotationTests.java
index 727b5c0417..b5493ff81e 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlIDAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlIDAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlID() throws Exception {
ICompilationUnit cu = this.createTestXmlID();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlIDAnnotation xmlIDAnnotation = (XmlIDAnnotation) resourceAttribute.getAnnotation(JAXB.XML_ID);
assertTrue(xmlIDAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDREFAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDREFAnnotationTests.java
index a4b0576a6e..f60ee7df24 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDREFAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlIDREFAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlIDREFAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlIDREFAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlIDREF() throws Exception {
ICompilationUnit cu = this.createTestXmlIDREF();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlIDREFAnnotation xmlIDREFAnnotation = (XmlIDREFAnnotation) resourceAttribute.getAnnotation(JAXB.XML_IDREF);
assertTrue(xmlIDREFAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAttributeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAttributeAnnotationTests.java
index a62542a57a..68f2f7cc4f 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAttributeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlInlineBinaryDataAttributeAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlInlineBinaryDataAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,12 +40,12 @@ public class XmlInlineBinaryDataAttributeAnnotationTests extends JaxbJavaResourc
public void testGetXmlInlineBinaryData() throws Exception {
ICompilationUnit cu = this.createTestXmlInlineBinaryData();
JavaResourceType resourceType = this.buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = this.getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = this.getMethod(resourceType, 0);
- XmlInlineBinaryDataAnnotation xmlInlineBinaryDataAnnotation = (XmlInlineBinaryDataAnnotation) resourceAttribute.getAnnotation(JAXB.XML_INLINE_BINARY_DATA);
+ XmlInlineBinaryDataAnnotation xmlInlineBinaryDataAnnotation = (XmlInlineBinaryDataAnnotation) resourceMethod.getAnnotation(JAXB.XML_INLINE_BINARY_DATA);
assertTrue(xmlInlineBinaryDataAnnotation != null);
- resourceAttribute.removeAnnotation(JAXB.XML_INLINE_BINARY_DATA);
+ resourceMethod.removeAnnotation(JAXB.XML_INLINE_BINARY_DATA);
assertSourceDoesNotContain("@XmlInlineBinaryData", cu);
}
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlListAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlListAnnotationTests.java
index add1da747c..2b55ba5314 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlListAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlListAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlListAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlListAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlList() throws Exception {
ICompilationUnit cu = this.createTestXmlList();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlListAnnotation xmlListAnnotation = (XmlListAnnotation) resourceAttribute.getAnnotation(JAXB.XML_LIST);
assertTrue(xmlListAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMimeTypeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMimeTypeAnnotationTests.java
index f50c4feb9a..b597eacc13 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMimeTypeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMimeTypeAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlMimeTypeAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -59,7 +59,7 @@ public class XmlMimeTypeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlMimeType() throws Exception {
ICompilationUnit cu = this.createTestXmlMimeType();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlMimeTypeAnnotation xmlMimeTypeAnnotation = (XmlMimeTypeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIME_TYPE);
assertTrue(xmlMimeTypeAnnotation != null);
@@ -71,7 +71,7 @@ public class XmlMimeTypeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlMimeTypeWithValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlMimeTypeAnnotation xmlMimeTypeAnnotation = (XmlMimeTypeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIME_TYPE);
assertTrue(xmlMimeTypeAnnotation != null);
@@ -81,7 +81,7 @@ public class XmlMimeTypeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetNull() throws Exception {
ICompilationUnit cu = this.createTestXmlMimeType();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlMimeTypeAnnotation xmlMimeTypeAnnotation = (XmlMimeTypeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIME_TYPE);
assertTrue(xmlMimeTypeAnnotation != null);
@@ -91,7 +91,7 @@ public class XmlMimeTypeAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testSetValue() throws Exception {
ICompilationUnit cu = this.createTestXmlMimeType();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlMimeTypeAnnotation xmlMimeTypeAnnotation = (XmlMimeTypeAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIME_TYPE);
assertNull(xmlMimeTypeAnnotation.getValue());
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMixedAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMixedAnnotationTests.java
index e6b8d4c848..f7f1ffc22d 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMixedAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlMixedAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlMixedAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlMixedAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlMixed() throws Exception {
ICompilationUnit cu = this.createTestXmlMixed();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlMixedAnnotation xmlMixedAnnotation = (XmlMixedAnnotation) resourceAttribute.getAnnotation(JAXB.XML_MIXED);
assertTrue(xmlMixedAnnotation != null);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlSchemaTypeAttributeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlSchemaTypeAttributeAnnotationTests.java
index 7ba9fa0ba2..1be1012a43 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlSchemaTypeAttributeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlSchemaTypeAttributeAnnotationTests.java
@@ -14,7 +14,7 @@ import java.util.GregorianCalendar;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -81,7 +81,7 @@ public class XmlSchemaTypeAttributeAnnotationTests
public void testName() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithSchemaTypeAndName();
JavaResourceType resourceType = this.buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = this.getField(resourceType, 0);
+ JavaResourceField resourceAttribute = this.getField(resourceType, 0);
XmlSchemaTypeAnnotation annotation =
(XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
@@ -105,7 +105,7 @@ public class XmlSchemaTypeAttributeAnnotationTests
public void testNamespace() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithSchemaTypeAndNamespace();
JavaResourceType resourceType = this.buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = this.getField(resourceType, 0);
+ JavaResourceField resourceAttribute = this.getField(resourceType, 0);
XmlSchemaTypeAnnotation annotation =
(XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
@@ -129,7 +129,7 @@ public class XmlSchemaTypeAttributeAnnotationTests
public void testType() throws Exception {
ICompilationUnit cu = this.createTestXmlAttributeWithSchemaTypeAndType();
JavaResourceType resourceType = this.buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = this.getField(resourceType, 0);
+ JavaResourceField resourceAttribute = this.getField(resourceType, 0);
XmlSchemaTypeAnnotation annotation =
(XmlSchemaTypeAnnotation) resourceAttribute.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlTransientAttributeAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlTransientAttributeAnnotationTests.java
index 5a8b6a2d66..cc4774e79c 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlTransientAttributeAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlTransientAttributeAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceMethod;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlTransientAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,12 +40,12 @@ public class XmlTransientAttributeAnnotationTests extends JaxbJavaResourceModelT
public void testGetXmlTransient() throws Exception {
ICompilationUnit cu = this.createTestXmlTransient();
JavaResourceType resourceType = this.buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = this.getMethod(resourceType, 0);
+ JavaResourceMethod resourceMethod = this.getMethod(resourceType, 0);
- XmlTransientAnnotation xmlTransientAnnotation = (XmlTransientAnnotation) resourceAttribute.getAnnotation(JAXB.XML_TRANSIENT);
+ XmlTransientAnnotation xmlTransientAnnotation = (XmlTransientAnnotation) resourceMethod.getAnnotation(JAXB.XML_TRANSIENT);
assertTrue(xmlTransientAnnotation != null);
- resourceAttribute.removeAnnotation(JAXB.XML_TRANSIENT);
+ resourceMethod.removeAnnotation(JAXB.XML_TRANSIENT);
assertSourceDoesNotContain("@XmlTransient", cu);
}
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlValueAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlValueAnnotationTests.java
index 114f4c3a48..f8986cd0b7 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlValueAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlValueAnnotationTests.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceField;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlValueAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@@ -40,7 +40,7 @@ public class XmlValueAnnotationTests extends JaxbJavaResourceModelTestCase {
public void testGetXmlValue() throws Exception {
ICompilationUnit cu = this.createTestXmlValue();
JavaResourceType resourceType = buildJavaResourceType(cu);
- JavaResourceAttribute resourceAttribute = getField(resourceType, 0);
+ JavaResourceField resourceAttribute = getField(resourceType, 0);
XmlValueAnnotation xmlValueAnnotation = (XmlValueAnnotation) resourceAttribute.getAnnotation(JAXB.XML_VALUE);
assertTrue(xmlValueAnnotation != null);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java
new file mode 100644
index 0000000000..11339f3957
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/AbstractJDTType.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.utility.jdt;
+
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.ASTNode;
+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.EnumDeclaration;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
+import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
+import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.utility.CommandExecutor;
+
+/**
+ * Adapt and extend a JDT abstract type.
+ */
+public abstract class AbstractJDTType
+ extends JDTMember
+ implements AbstractType
+{
+
+ /**
+ * constructor for the compilation unit's primary type
+ */
+ protected AbstractJDTType(
+ AbstractTypeDeclaration typeDeclaration,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor) {
+ this(typeDeclaration, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
+ }
+
+ /**
+ * constructor for the compilation unit's primary type
+ */
+ protected AbstractJDTType(
+ AbstractTypeDeclaration typeDeclaration,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor,
+ AnnotationEditFormatter annotationEditFormatter) {
+ this(null, typeDeclaration, 1, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ }
+
+ /**
+ * constructor for nested types
+ */
+ protected AbstractJDTType(
+ Type declaringType,
+ AbstractTypeDeclaration typeDeclaration,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor) {
+ this(declaringType, typeDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
+ }
+
+ /**
+ * constructor for nested types
+ */
+ protected AbstractJDTType(
+ Type declaringType,
+ AbstractTypeDeclaration typeDeclaration,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor,
+ AnnotationEditFormatter annotationEditFormatter) {
+ super(declaringType, typeDeclaration.getName().getFullyQualifiedName(), occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ }
+
+ /**
+ * constructor for testing
+ */
+ protected AbstractJDTType(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
+ super(declaringType, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
+ }
+
+ @Override
+ protected Type getDeclaringType() {
+ return (Type) super.getDeclaringType();
+ }
+
+ // ********** Member/Type implementation **********
+
+ public ITypeBinding getBinding(CompilationUnit astRoot) {
+ AbstractTypeDeclaration td = this.getBodyDeclaration(astRoot);
+ return (td == null) ? null : td.resolveBinding();
+ }
+
+ /**
+ * find the type's body declaration in the specified AST
+ */
+ @Override
+ public AbstractTypeDeclaration getBodyDeclaration(CompilationUnit astRoot) {
+ Type declaringType = this.getDeclaringType();
+ if (declaringType == null) {
+ return this.getTopLevelTypeDeclaration(astRoot);
+ }
+ TypeDeclaration typeDeclaration = declaringType.getBodyDeclaration(astRoot);
+ // the type declaration can be null when the source is completely hosed
+ return (typeDeclaration == null) ? null : this.getNestedTypeDeclaration(typeDeclaration);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return new ASTNodeTextRange(this.getBodyDeclaration(astRoot).getName());
+ }
+
+
+ // ********** internal **********
+
+ /**
+ * return the first top-level type in the specified AST with a matching name
+ */
+ protected AbstractTypeDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
+ return this.getTypeDeclaration(types(astRoot));
+ }
+
+ protected AbstractTypeDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
+ return this.getTypeDeclaration(typeDeclarations.toArray(new AbstractTypeDeclaration[typeDeclarations.size()]));
+ }
+
+ /**
+ * Return the nested type declaration with matching name and occurrence within the declaring type
+ */
+ protected abstract AbstractTypeDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration);
+
+ /**
+ * return the type declaration corresponding to the type from the specified
+ * set of type declarations (match name and occurrence).
+ * Only return type or enum declarations
+ */
+ protected AbstractTypeDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
+ String name = this.getName_();
+ int occurrence = this.getOccurrence();
+ int count = 0;
+ for (AbstractTypeDeclaration typeDeclaration : typeDeclarations) {
+ if (typeDeclaration.getName().getFullyQualifiedName().equals(name)) {
+ count++;
+ if (count == occurrence) {
+ return (typeDeclaration.getNodeType() == this.getASTNodeType()) ? typeDeclaration : null;
+ }
+ }
+ }
+ // return null if the type is no longer in the source code;
+ // this can happen when the context model has not yet
+ // been synchronized with the resource model but is still
+ // asking for an ASTNode (e.g. during a selection event)
+ return null;
+ }
+
+ protected abstract int getASTNodeType();
+
+ /**
+ * we only instantiate a single top-level, non-annotation
+ * type per compilation unit (i.e. a class, enum, or interface)
+ */
+ // minimize scope of suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected static List<AbstractTypeDeclaration> types(CompilationUnit astRoot) {
+ return astRoot.types();
+ }
+
+ protected static EnumDeclaration[] getEnums(TypeDeclaration declaringTypeDeclaration) {
+ List<BodyDeclaration> bd = bodyDeclarations(declaringTypeDeclaration);
+ int typeCount = 0;
+ for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) {
+ if (it.next().getNodeType() == ASTNode.ENUM_DECLARATION) {
+ typeCount++;
+ }
+ }
+ EnumDeclaration[] memberEnums = new EnumDeclaration[typeCount];
+ int next = 0;
+ for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) {
+ BodyDeclaration decl = it.next();
+ if (decl.getNodeType() == ASTNode.ENUM_DECLARATION) {
+ memberEnums[next++] = (EnumDeclaration) decl;
+ }
+ }
+ return memberEnums;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static List<BodyDeclaration> bodyDeclarations(TypeDeclaration typeDeclaration) {
+ return typeDeclaration.bodyDeclarations();
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAttribute.java
deleted file mode 100644
index 342aebf7e0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTAttribute.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.core.utility.jdt.Attribute;
-import org.eclipse.jpt.core.utility.jdt.Type;
-import org.eclipse.jpt.utility.CommandExecutor;
-
-/**
- * Combine behavior common to JDTFieldAttribute and JDTMethodAttribute.
- * Not so sure this is useful....
- */
-public abstract class JDTAttribute
- extends JDTMember
- implements Attribute
-{
-
- // ********** constructors **********
-
- protected JDTAttribute(
- Type declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- super(declaringType, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor);
- }
-
- protected JDTAttribute(
- Type declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
-
- // ********** Member/Attribute implementation **********
-
- public boolean isField() {
- return false;
- }
-
-
- // ********** internal **********
-
- protected TypeDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
- // assume the declaring type is not an enum or annotation
- // since they do not have field or method declarations
- return this.getDeclaringType().getBodyDeclaration(astRoot);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnum.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnum.java
new file mode 100644
index 0000000000..186c5e0e03
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnum.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.utility.jdt;
+
+import java.util.List;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
+import org.eclipse.jpt.core.utility.jdt.Enum;
+import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.utility.CommandExecutor;
+
+/**
+ * Adapt and extend a JDT enum.
+ */
+public class JDTEnum
+ extends AbstractJDTType
+ implements Enum
+{
+
+ /**
+ * constructor for the compilation unit's primary type, an enum
+ */
+ public JDTEnum(
+ EnumDeclaration enumDeclaration,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor) {
+ this(enumDeclaration, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
+ }
+
+ /**
+ * constructor for the compilation unit's primary type, an enum
+ */
+ public JDTEnum(
+ EnumDeclaration enumDeclaration,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor,
+ AnnotationEditFormatter annotationEditFormatter) {
+ super(null, enumDeclaration, 1, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ }
+
+ /**
+ * constructor for nested enums
+ */
+ public JDTEnum(
+ Type declaringType,
+ EnumDeclaration enumDeclaration,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor) {
+ this(declaringType, enumDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
+ }
+
+ /**
+ * constructor for nested enums
+ */
+ public JDTEnum(
+ Type declaringType,
+ EnumDeclaration enumDeclaration,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor,
+ AnnotationEditFormatter annotationEditFormatter) {
+ super(declaringType, enumDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ }
+
+ /**
+ * constructor for testing
+ */
+ public JDTEnum(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
+ super(declaringType, name, occurrence, compilationUnit);
+ }
+
+ @Override
+ public EnumDeclaration getBodyDeclaration(CompilationUnit astRoot) {
+ return (EnumDeclaration) super.getBodyDeclaration(astRoot);
+ }
+
+ public boolean isPersistable(CompilationUnit astRoot) {
+ return true;
+ }
+
+ public EnumConstantDeclaration[] getEnumConstants(CompilationUnit astRoot) {
+ List<EnumConstantDeclaration> enumConstants = enumConstants(getBodyDeclaration(astRoot));
+ return enumConstants.toArray(new EnumConstantDeclaration[enumConstants.size()]);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static List<EnumConstantDeclaration> enumConstants(EnumDeclaration ed) {
+ return ed.enumConstants();
+ }
+
+
+ // ********** internal **********
+
+ @Override
+ protected EnumDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
+ return (EnumDeclaration) super.getTopLevelTypeDeclaration(astRoot);
+ }
+
+ @Override
+ protected EnumDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
+ return (EnumDeclaration) super.getTypeDeclaration(typeDeclarations);
+ }
+
+ @Override
+ protected EnumDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration) {
+ return this.getTypeDeclaration(getEnums(declaringTypeDeclaration));
+ }
+
+ @Override
+ protected EnumDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
+ return (EnumDeclaration) super.getTypeDeclaration(typeDeclarations);
+ }
+
+ @Override
+ protected int getASTNodeType() {
+ return ASTNode.ENUM_DECLARATION;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java
new file mode 100644
index 0000000000..acb35711ff
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTEnumConstant.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.utility.jdt;
+
+import java.util.List;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
+import org.eclipse.jpt.core.utility.jdt.EnumConstant;
+import org.eclipse.jpt.core.utility.jdt.Enum;
+import org.eclipse.jpt.utility.CommandExecutor;
+
+/**
+ * Adapt and extend a JDT enum constant.
+ */
+public class JDTEnumConstant
+ extends JDTMember
+ implements EnumConstant
+{
+
+ // ********** constructors **********
+
+ public JDTEnumConstant(
+ Enum declaringEnum,
+ String name,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor) {
+ this(declaringEnum, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
+ }
+
+ public JDTEnumConstant(
+ Enum declaringEnum,
+ String name,
+ int occurrence,
+ ICompilationUnit compilationUnit,
+ CommandExecutor modifySharedDocumentCommandExecutor,
+ AnnotationEditFormatter annotationEditFormatter) {
+ super(declaringEnum, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ }
+
+ /**
+ * constructor for testing
+ */
+ public JDTEnumConstant(Enum declaringEnum, String name, int occurrence, ICompilationUnit compilationUnit) {
+ this(declaringEnum, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
+ }
+
+ @Override
+ protected Enum getDeclaringType() {
+ return (Enum) super.getDeclaringType();
+ }
+
+ // ********** AnnotatedElement/EnumConstant implementation **********
+
+ public IVariableBinding getBinding(CompilationUnit astRoot) {
+ return this.getBodyDeclaration(astRoot).resolveVariable();
+ }
+
+ @Override
+ public EnumConstantDeclaration getBodyDeclaration(CompilationUnit astRoot) {
+ return this.getSelectedDeclaration(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return new ASTNodeTextRange(this.getBodyDeclaration(astRoot).getName());
+ }
+
+ public String getName() {
+ return this.getName_();
+ }
+
+ //As far as I can tell, enum constants are always "persistable",
+ //there are no modifiers you can add to an enum constant
+ public boolean isPersistable(CompilationUnit astRoot) {
+ return true;
+ }
+
+
+ // ********** internal **********
+
+ protected EnumConstantDeclaration getSelectedDeclaration(CompilationUnit astRoot) {
+ String name = this.getName_();
+ int occurrence = this.getOccurrence();
+ int count = 0;
+ for (EnumConstantDeclaration enumConstantDeclaration : this.getDeclaringTypeEnumConstantDeclarations(astRoot)) {
+ if (enumConstantDeclaration.getName().getFullyQualifiedName().equals(name)) {
+ count++;
+ if (count == occurrence) {
+ return enumConstantDeclaration;
+ }
+ }
+ }
+ // return null if the field is no longer in the source code;
+ // this can happen when the context model has not yet
+ // been synchronized with the resource model but is still
+ // asking for an ASTNode (e.g. during a selection event)
+ return null;
+ }
+
+ protected EnumConstantDeclaration[] getDeclaringTypeEnumConstantDeclarations(CompilationUnit astRoot) {
+ List<EnumConstantDeclaration> enumConstants = enumConstants(this.getDeclaringTypeDeclaration(astRoot));
+ return enumConstants.toArray(new EnumConstantDeclaration[enumConstants.size()]);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static List<EnumConstantDeclaration> enumConstants(EnumDeclaration ed) {
+ return ed.enumConstants();
+ }
+
+ protected EnumDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
+ return this.getDeclaringType().getBodyDeclaration(astRoot);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
index a349ef2666..4fc583d7e1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTFieldAttribute.java
@@ -16,11 +16,11 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.core.utility.jdt.FieldAttribute;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.utility.CommandExecutor;
@@ -30,7 +30,7 @@ import org.eclipse.jpt.utility.CommandExecutor;
* private int foo;
*/
public class JDTFieldAttribute
- extends JDTAttribute
+ extends JDTMember
implements FieldAttribute
{
@@ -64,15 +64,17 @@ public class JDTFieldAttribute
// ********** Member/Attribute/FieldAttribute implementation **********
+
@Override
- public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
- return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
+ protected Type getDeclaringType() {
+ return (Type) super.getDeclaringType();
}
public IVariableBinding getBinding(CompilationUnit astRoot) {
return this.getFragment(astRoot).resolveBinding();
}
+ @Override
public FieldDeclaration getBodyDeclaration(CompilationUnit astRoot) {
return this.getSelectedDeclaration(astRoot, FIELD_DECLARATION_SELECTOR);
}
@@ -89,7 +91,6 @@ public class JDTFieldAttribute
return this.getBodyDeclaration(astRoot).getType().resolveBinding();
}
- @Override
public boolean isField() {
return true;
}
@@ -102,6 +103,12 @@ public class JDTFieldAttribute
// ********** internal **********
+ protected TypeDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
+ // assume the declaring type is not an enum or annotation
+ // since they do not have field or method declarations
+ return this.getDeclaringType().getBodyDeclaration(astRoot);
+ }
+
protected VariableDeclarationFragment getFragment(CompilationUnit astRoot) {
return this.getSelectedDeclaration(astRoot, VARIABLE_DECLARATION_FRAGMENT_SELECTOR);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
index a250509ee6..6a8bc80f23 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMember.java
@@ -10,9 +10,12 @@
package org.eclipse.jpt.core.internal.utility.jdt;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.BodyDeclaration;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.jdt.AbstractType;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.core.utility.jdt.Type;
+import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.utility.CommandExecutor;
/**
@@ -23,7 +26,7 @@ public abstract class JDTMember extends JDTAnnotatedElement
{
/** this will be null for the primary type */
- private final Type declaringType;
+ private final AbstractType declaringType;
/**
* members can occur more than once in non-compiling source;
@@ -35,7 +38,7 @@ public abstract class JDTMember extends JDTAnnotatedElement
// ********** constructors **********
protected JDTMember(
- Type declaringType,
+ AbstractType declaringType,
String name,
int occurrence,
ICompilationUnit compilationUnit,
@@ -44,7 +47,7 @@ public abstract class JDTMember extends JDTAnnotatedElement
}
protected JDTMember(
- Type declaringType,
+ AbstractType declaringType,
String name,
int occurrence,
ICompilationUnit compilationUnit,
@@ -55,9 +58,17 @@ public abstract class JDTMember extends JDTAnnotatedElement
this.occurrence = occurrence;
}
+ //covariant override
+ public abstract BodyDeclaration getBodyDeclaration(CompilationUnit astRoot);
+
// ********** Member implementation **********
+ @Override
+ public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
+ return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
+ }
+
public boolean matches(String memberName, int occur) {
return memberName.equals(this.getName_()) && (occur == this.occurrence);
}
@@ -72,7 +83,7 @@ public abstract class JDTMember extends JDTAnnotatedElement
/**
* this will return null for a top-level type
*/
- protected Type getDeclaringType() {
+ protected AbstractType getDeclaringType() {
return this.declaringType;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
index 7319389aa0..b653783c85 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTMethodAttribute.java
@@ -17,10 +17,10 @@ import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.core.utility.jdt.MethodAttribute;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.utility.CommandExecutor;
import org.eclipse.jpt.utility.JavaType;
@@ -39,7 +39,7 @@ import org.eclipse.jpt.utility.internal.SimpleMethodSignature;
* }
*/
public class JDTMethodAttribute
- extends JDTAttribute
+ extends JDTMember
implements MethodAttribute
{
/** we need the parameter types to build the method signature */
@@ -67,16 +67,7 @@ public class JDTMethodAttribute
return new JDTMethodAttribute(declaringType, signature, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
}
- public JDTMethodAttribute(
- Type declaringType,
- MethodSignature methodSignature,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, methodSignature, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- public JDTMethodAttribute(
+ private JDTMethodAttribute(
Type declaringType,
MethodSignature methodSignature,
int occurrence,
@@ -96,15 +87,21 @@ public class JDTMethodAttribute
// ********** Member/Attribute/MethodAttribute implementation **********
+
@Override
- public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
- return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
+ protected Type getDeclaringType() {
+ return (Type) super.getDeclaringType();
+ }
+
+ public boolean isField() {
+ return false;
}
public IMethodBinding getBinding(CompilationUnit astRoot) {
return this.getBodyDeclaration(astRoot).resolveBinding();
}
+ @Override
public MethodDeclaration getBodyDeclaration(CompilationUnit astRoot) {
int count = 0;
for (MethodDeclaration methodDeclaration : this.getDeclaringTypeMethodDeclarations(astRoot)) {
@@ -170,6 +167,12 @@ public class JDTMethodAttribute
// ********** internal **********
+ protected TypeDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
+ // assume the declaring type is not an enum or annotation
+ // since they do not have field or method declarations
+ return this.getDeclaringType().getBodyDeclaration(astRoot);
+ }
+
protected MethodDeclaration[] getDeclaringTypeMethodDeclarations(CompilationUnit astRoot) {
return this.getDeclaringTypeDeclaration(astRoot).getMethods();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTType.java
index 95b6a82210..baeb2a95bf 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/jdt/JDTType.java
@@ -14,13 +14,12 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.core.utility.jdt.ModifiedDeclaration;
import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.utility.CommandExecutor;
@@ -28,7 +27,7 @@ import org.eclipse.jpt.utility.CommandExecutor;
* Adapt and extend a JDT type.
*/
public class JDTType
- extends JDTMember
+ extends AbstractJDTType
implements Type
{
@@ -75,39 +74,25 @@ public class JDTType
ICompilationUnit compilationUnit,
CommandExecutor modifySharedDocumentCommandExecutor,
AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, typeDeclaration.getName().getFullyQualifiedName(), occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
+ super(declaringType, typeDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
}
/**
* constructor for testing
*/
public JDTType(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
- super(declaringType, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
+ super(declaringType, name, occurrence, compilationUnit);
}
// ********** Member/Type implementation **********
- @Override
- public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
- return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
- }
-
- public ITypeBinding getBinding(CompilationUnit astRoot) {
- TypeDeclaration td = this.getBodyDeclaration(astRoot);
- return (td == null) ? null : td.resolveBinding();
- }
/**
* find the type's body declaration in the specified AST
*/
+ @Override
public TypeDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- Type declaringType = this.getDeclaringType();
- if (declaringType == null) {
- return this.getTopLevelTypeDeclaration(astRoot);
- }
- TypeDeclaration typeDeclaration = declaringType.getBodyDeclaration(astRoot);
- // the type declaration can be null when the source is completely hosed
- return (typeDeclaration == null) ? null : this.getNestedTypeDeclaration(typeDeclaration);
+ return (TypeDeclaration) super.getBodyDeclaration(astRoot);
}
public boolean isPersistable(CompilationUnit astRoot) {
@@ -115,14 +100,14 @@ public class JDTType
return (binding == null) ? false : JPTTools.typeIsPersistable(new JPTToolsAdapter(binding));
}
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return new ASTNodeTextRange(this.getBodyDeclaration(astRoot).getName());
- }
-
public TypeDeclaration[] getTypes(CompilationUnit astRoot) {
return this.getBodyDeclaration(astRoot).getTypes();
}
+ public EnumDeclaration[] getEnums(CompilationUnit astRoot) {
+ return getEnums(this.getBodyDeclaration(astRoot));
+ }
+
public FieldDeclaration[] getFields(CompilationUnit astRoot) {
return this.getBodyDeclaration(astRoot).getFields();
}
@@ -137,17 +122,20 @@ public class JDTType
/**
* return the first top-level type in the specified AST with a matching name
*/
+ @Override
protected TypeDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
- return this.getTypeDeclaration(types(astRoot));
+ return (TypeDeclaration) super.getTopLevelTypeDeclaration(astRoot);
}
+ @Override
protected TypeDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
- return this.getTypeDeclaration(typeDeclarations.toArray(new AbstractTypeDeclaration[typeDeclarations.size()]));
+ return (TypeDeclaration) super.getTypeDeclaration(typeDeclarations);
}
/**
* return the nested type with a matching name and occurrence
*/
+ @Override
protected TypeDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration) {
return this.getTypeDeclaration(declaringTypeDeclaration.getTypes());
}
@@ -156,36 +144,14 @@ public class JDTType
* return the type declaration corresponding to the type from the specified
* set of type declarations (match name and occurrence)
*/
+ @Override
protected TypeDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
- String name = this.getName_();
- int occurrence = this.getOccurrence();
- int count = 0;
- for (AbstractTypeDeclaration typeDeclaration : typeDeclarations) {
- if (typeDeclaration.getName().getFullyQualifiedName().equals(name)) {
- count++;
- if (count == occurrence) {
- return (typeDeclaration.getNodeType() == ASTNode.TYPE_DECLARATION) ? (TypeDeclaration) typeDeclaration : null;
- }
- }
- }
- // return null if the type is no longer in the source code;
- // this can happen when the context model has not yet
- // been synchronized with the resource model but is still
- // asking for an ASTNode (e.g. during a selection event)
- return null;
+ return (TypeDeclaration) super.getTypeDeclaration(typeDeclarations);
}
- /**
- * we only instantiate a single top-level, non-enum, non-annotation
- * type per compilation unit (i.e. a class or interface); and, since
- * enums and annotations can only be top-level types (i.e. they cannot
- * be nested within another type) we will always have TypeDeclarations
- * in the CompilationUnit
- */
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected static List<AbstractTypeDeclaration> types(CompilationUnit astRoot) {
- return astRoot.types();
+ @Override
+ protected int getASTNodeType() {
+ return ASTNode.TYPE_DECLARATION;
}
@@ -236,7 +202,6 @@ public class JDTType
public boolean isPrimitive() {
return this.typeBinding.isPrimitive();
}
-
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AbstractType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AbstractType.java
new file mode 100644
index 0000000000..3668ada262
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/AbstractType.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.utility.jdt;
+
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+
+/**
+ * AbstractType: just some covariant overrides.
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * This interface is not intended to be implemented by clients.
+ */
+public interface AbstractType extends Member {
+
+ /**
+ * Covariant override.
+ */
+ ITypeBinding getBinding(CompilationUnit astRoot);
+
+ /**
+ * Covariant override.
+ */
+ AbstractTypeDeclaration getBodyDeclaration(CompilationUnit astRoot);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Enum.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Enum.java
new file mode 100644
index 0000000000..e0b6f37184
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Enum.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.utility.jdt;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
+
+/**
+ * Enum: some covariant overrides plus enumConstants
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * This interface is not intended to be implemented by clients.
+ */
+public interface Enum extends AbstractType {
+
+ /**
+ * Covariant override.
+ */
+ EnumDeclaration getBodyDeclaration(CompilationUnit astRoot);
+
+ /**
+ * Return the enum's constants
+ */
+ EnumConstantDeclaration[] getEnumConstants(CompilationUnit astRoot);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/EnumConstant.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/EnumConstant.java
new file mode 100644
index 0000000000..e420609c95
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/EnumConstant.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.utility.jdt;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
+import org.eclipse.jdt.core.dom.IVariableBinding;
+
+/**
+ * Enum constants are part of Enums
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * This interface is not intended to be implemented by clients.
+ */
+public interface EnumConstant extends Member {
+
+ String getName();
+
+ /**
+ * Covariant override.
+ */
+ IVariableBinding getBinding(CompilationUnit astRoot);
+
+ /**
+ * Covariant override.
+ */
+ EnumConstantDeclaration getBodyDeclaration(CompilationUnit astRoot);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/MethodAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/MethodAttribute.java
index 4637ab76cf..45679113e7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/MethodAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/MethodAttribute.java
@@ -15,7 +15,7 @@ import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jpt.utility.MethodSignature;
/**
- * Property attribute: just some covariant overrides.
+ * Method attribute: just some covariant overrides.
*
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -25,7 +25,6 @@ import org.eclipse.jpt.utility.MethodSignature;
*
* This interface is not intended to be implemented by clients.
*/
-// TODO rename PropertyAttribute?
public interface MethodAttribute extends Attribute {
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Type.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Type.java
index 26726d98a7..b44ba4d714 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Type.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/utility/jdt/Type.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,13 +10,13 @@
package org.eclipse.jpt.core.utility.jdt;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.EnumDeclaration;
import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
/**
- * Type: just some covariant overrides.
+ * Type: nestedTypes, nestedEnums, fields, and methods.
*
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -26,12 +26,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
*
* This interface is not intended to be implemented by clients.
*/
-public interface Type extends Member {
-
- /**
- * Covariant override.
- */
- ITypeBinding getBinding(CompilationUnit astRoot);
+public interface Type extends AbstractType {
/**
* Covariant override.
@@ -44,6 +39,11 @@ public interface Type extends Member {
TypeDeclaration[] getTypes(CompilationUnit astRoot);
/**
+ * Return the type's nested enums.
+ */
+ EnumDeclaration[] getEnums(CompilationUnit astRoot);
+
+ /**
* Return the type's fields.
*/
FieldDeclaration[] getFields(CompilationUnit astRoot);

Back to the top