Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-10-21 16:05:20 -0400
committerpfullbright2010-10-21 16:05:20 -0400
commit6d1f4fe34cd0fbb896b41f10bfcf30096445137a (patch)
treef2d50ebb1393dd309f9cc093f6864e24ef4913ac
parent2c739aa693f1a50ffbc241e7fd99464d4da6e68b (diff)
downloadwebtools.dali-6d1f4fe34cd0fbb896b41f10bfcf30096445137a.tar.gz
webtools.dali-6d1f4fe34cd0fbb896b41f10bfcf30096445137a.tar.xz
webtools.dali-6d1f4fe34cd0fbb896b41f10bfcf30096445137a.zip
XmlJavaTypeAdapter(s) annotations for packages
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java1
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java25
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java38
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java71
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java130
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java12
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java34
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java5
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java3
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterPackageAnnotationTests.java260
-rw-r--r--jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterTypeAnnotationTests.java (renamed from jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java)17
11 files changed, 449 insertions, 147 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
index 0a852c7acf..cce574a10f 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/GenericJaxbAnnotationDefinitionProvider.java
@@ -86,7 +86,6 @@ public class GenericJaxbAnnotationDefinitionProvider
definitions.add(XmlEnumAnnotationDefinition.instance());
definitions.add(XmlInlineBinaryDataAnnotationDefinition.instance());
definitions.add(XmlJavaTypeAdapterAnnotationDefinition.instance());
- definitions.add(XmlJavaTypeAdaptersAnnotationDefinition.instance());
definitions.add(XmlRegistryAnnotationDefinition.instance());
definitions.add(XmlRootElementAnnotationDefinition.instance());
definitions.add(XmlSeeAlsoAnnotationDefinition.instance());
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java
index abf01aa9f3..26f99f8b81 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/XmlJavaTypeAdaptersAnnotationDefinition.java
@@ -13,8 +13,9 @@ import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.jaxb.core.internal.resource.java.binary.BinaryXmlJavaTypeAdaptersAnnotation;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage;
import org.eclipse.jpt.jaxb.core.internal.resource.java.source.SourceXmlJavaTypeAdaptersAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
@@ -22,39 +23,39 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
* javax.xml.bind.annotation.adapters.XmlJavaTypeAdaptersAnnotation
*/
public final class XmlJavaTypeAdaptersAnnotationDefinition
- implements AnnotationDefinition
-{
+ implements AnnotationDefinition {
+
// singleton
private static final AnnotationDefinition INSTANCE = new XmlJavaTypeAdaptersAnnotationDefinition();
-
+
/**
* Return the singleton.
*/
public static AnnotationDefinition instance() {
return INSTANCE;
}
-
+
/**
* Ensure single instance.
*/
private XmlJavaTypeAdaptersAnnotationDefinition() {
super();
}
-
+
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
- return new SourceXmlJavaTypeAdaptersAnnotation(parent, annotatedElement);
+ return new SourceXmlJavaTypeAdaptersAnnotation((JavaResourcePackage) parent, (AnnotatedPackage) annotatedElement);
}
-
+
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
throw new UnsupportedOperationException();
}
-
+
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
- return new BinaryXmlJavaTypeAdaptersAnnotation(parent, jdtAnnotation);
+ // TODO
+ throw new UnsupportedOperationException();
}
-
+
public String getAnnotationName() {
return XmlJavaTypeAdaptersAnnotation.ANNOTATION_NAME;
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java
index b42e71491f..d916c401c9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdapterAnnotation.java
@@ -26,10 +26,13 @@ public final class BinaryXmlJavaTypeAdapterAnnotation
private String value;
+ private String type;
+
public BinaryXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
super(parent, jdtAnnotation);
- this.value = this.buildValue();
+ this.value = buildValue();
+ this.type = buildType();
}
public String getAnnotationName() {
@@ -39,7 +42,8 @@ public final class BinaryXmlJavaTypeAdapterAnnotation
@Override
public void update() {
super.update();
- this.setValue_(this.buildValue());
+ setValue_(buildValue());
+ setType_(buildType());
}
@Override
@@ -74,9 +78,35 @@ public final class BinaryXmlJavaTypeAdapterAnnotation
throw new UnsupportedOperationException();
}
- // ***** fully-qualified value class name
-
public String getFullyQualifiedValue() {
return this.value;
}
+
+ // ***** type
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setType_(String type) {
+ String old = this.type;
+ this.type = type;
+ this.firePropertyChanged(TYPE_PROPERTY, old, type);
+ this.firePropertyChanged(FULLY_QUALIFIED_TYPE_PROPERTY, old, type);
+ }
+
+ private String buildType() {
+ return (String) this.getJdtMemberValue(JAXB.XML_JAVA_TYPE_ADAPTER__TYPE);
+ }
+
+ public TextRange getTypeTextRange(CompilationUnit astRoot) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getFullyQualifiedType() {
+ return this.type;
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java
deleted file mode 100644
index e88c9cbbe5..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/binary/BinaryXmlJavaTypeAdaptersAnnotation.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * 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.binary;
-
-import java.util.Vector;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.core.internal.resource.java.binary.BinaryContainerAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
-import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-
-/**
- * javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
- */
-public class BinaryXmlJavaTypeAdaptersAnnotation
- extends BinaryContainerAnnotation<XmlJavaTypeAdapterAnnotation>
- implements XmlJavaTypeAdaptersAnnotation {
-
- private final Vector<XmlJavaTypeAdapterAnnotation> xmlJavaTypeAdapters;
-
-
- public BinaryXmlJavaTypeAdaptersAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
- super(parent, jdtAnnotation);
- this.xmlJavaTypeAdapters = this.buildXmlJavaTypeAdapters();
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- public Iterable<XmlJavaTypeAdapterAnnotation> getNestedAnnotations() {
- return new LiveCloneIterable<XmlJavaTypeAdapterAnnotation>(this.xmlJavaTypeAdapters);
- }
-
- public int getNestedAnnotationsSize() {
- return this.xmlJavaTypeAdapters.size();
- }
-
- private Vector<XmlJavaTypeAdapterAnnotation> buildXmlJavaTypeAdapters() {
- Object[] jdtTypeAdapters = this.getJdtMemberValues(JAXB.XML_JAVA_TYPE_ADAPTERS__VALUE);
- Vector<XmlJavaTypeAdapterAnnotation> result = new Vector<XmlJavaTypeAdapterAnnotation>(jdtTypeAdapters.length);
- for (Object jdtJavaTypeAdapter : jdtTypeAdapters) {
- result.add(this.buildXmlJavaTypeAdapterAnnotation(jdtJavaTypeAdapter));
- }
- return result;
- }
-
- protected XmlJavaTypeAdapterAnnotation buildXmlJavaTypeAdapterAnnotation(Object jdtJavaTypeAdapter) {
- return new BinaryXmlJavaTypeAdapterAnnotation(this, (IAnnotation) jdtJavaTypeAdapter);
- }
-
- @Override
- public void update() {
- super.update();
- this.updateXmlJavaTypeAdapters();
- }
-
- // TODO
- private void updateXmlJavaTypeAdapters() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java
index 3d18724557..bf6a5cf32e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdapterAnnotation.java
@@ -46,15 +46,19 @@ public final class SourceXmlJavaTypeAdapterAnnotation
private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter;
private final AnnotationElementAdapter<String> valueAdapter;
private String value;
-
private String fullyQualifiedValue;
-
-
+
+ private final DeclarationAnnotationElementAdapter<String> typeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> typeAdapter;
+ private String type;
+ private String fullyQualifiedType;
+
+
// ********** constructors **********
public SourceXmlJavaTypeAdapterAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element) {
this(parent, element, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(element, DECLARATION_ANNOTATION_ADAPTER));
}
-
+
/**
* Parent is a JavaResourceNode instead of a JavaResourceAnnotatedElement because
* the parent is sometimes the outer annotation XmlJavaTypeAdaptersAnnotation
@@ -63,96 +67,145 @@ public final class SourceXmlJavaTypeAdapterAnnotation
super(parent, element, daa, annotationAdapter);
this.valueDeclarationAdapter = buildValueAdapter(daa);
this.valueAdapter = this.buildAnnotationElementAdapter(this.valueDeclarationAdapter);
+ this.typeDeclarationAdapter = buildTypeAdapter(daa);
+ this.typeAdapter = this.buildAnnotationElementAdapter(this.typeDeclarationAdapter);
}
-
+
private DeclarationAnnotationElementAdapter<String> buildValueAdapter(DeclarationAnnotationAdapter daa) {
return buildAnnotationElementAdapter(daa, JAXB.XML_JAVA_TYPE_ADAPTER__VALUE, SimpleTypeStringExpressionConverter.instance());
}
-
+
+ private DeclarationAnnotationElementAdapter<String> buildTypeAdapter(DeclarationAnnotationAdapter daa) {
+ return buildAnnotationElementAdapter(daa, JAXB.XML_JAVA_TYPE_ADAPTER__TYPE, SimpleTypeStringExpressionConverter.instance());
+ }
+
static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) {
return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, false, converter);
}
-
+
protected AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) {
return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
}
-
+
public String getAnnotationName() {
return ANNOTATION_NAME;
}
-
+
public void initialize(CompilationUnit astRoot) {
- this.value = this.buildValue(astRoot);
- this.fullyQualifiedValue = this.buildFullyQualifiedValue(astRoot);
+ this.value = buildValue(astRoot);
+ this.fullyQualifiedValue = buildFullyQualifiedValue(astRoot);
+ this.type = buildType(astRoot);
+ this.fullyQualifiedType = buildFullyQualifiedType(astRoot);
}
-
+
public void synchronizeWith(CompilationUnit astRoot) {
- this.syncValue(this.buildValue(astRoot));
- this.syncFullyQualifiedValue(this.buildFullyQualifiedValue(astRoot));
+ syncValue(buildValue(astRoot));
+ syncFullyQualifiedValue(buildFullyQualifiedValue(astRoot));
+ syncType(buildType(astRoot));
+ syncFullyQualifiedType(buildFullyQualifiedType(astRoot));
}
-
+
@Override
public void toString(StringBuilder sb) {
sb.append(this.value);
}
-
-
+
+
// ********** XmlJavaTypeAdapterAnnotation implementation **********
-
+
// ***** value
public String getValue() {
return this.value;
}
-
+
public void setValue(String value) {
if (this.attributeValueHasChanged(this.value, value)) {
this.value = value;
this.valueAdapter.setValue(value);
}
}
-
+
private void syncValue(String astValue) {
String old = this.value;
this.value = astValue;
this.firePropertyChanged(VALUE_PROPERTY, old, astValue);
}
-
+
private String buildValue(CompilationUnit astRoot) {
return this.valueAdapter.getValue(astRoot);
}
-
+
public TextRange getValueTextRange(CompilationUnit astRoot) {
return this.getElementTextRange(this.valueDeclarationAdapter, astRoot);
}
-
- // ***** fully-qualified value class name
+
public String getFullyQualifiedValue() {
return this.fullyQualifiedValue;
}
-
+
private void syncFullyQualifiedValue(String name) {
String old = this.fullyQualifiedValue;
this.fullyQualifiedValue = name;
this.firePropertyChanged(FULLY_QUALIFIED_VALUE_PROPERTY, old, name);
}
-
+
private String buildFullyQualifiedValue(CompilationUnit astRoot) {
return (this.value == null) ? null : ASTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot));
}
-
-
+
+ // ***** type
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ if (this.attributeValueHasChanged(this.type, type)) {
+ this.type = type;
+ this.typeAdapter.setValue(type);
+ }
+ }
+
+ private void syncType(String astType) {
+ String old = this.type;
+ this.type = astType;
+ this.firePropertyChanged(TYPE_PROPERTY, old, astType);
+ }
+
+ private String buildType(CompilationUnit astRoot) {
+ return this.typeAdapter.getValue(astRoot);
+ }
+
+ public TextRange getTypeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.typeDeclarationAdapter, astRoot);
+ }
+
+ public String getFullyQualifiedType() {
+ return this.fullyQualifiedType;
+ }
+
+ private void syncFullyQualifiedType(String name) {
+ String old = this.fullyQualifiedType;
+ this.fullyQualifiedType = name;
+ this.firePropertyChanged(FULLY_QUALIFIED_TYPE_PROPERTY, old, name);
+ }
+
+ private String buildFullyQualifiedType(CompilationUnit astRoot) {
+ return (this.type == null) ? null : ASTTools.resolveFullyQualifiedName(this.typeAdapter.getExpression(astRoot));
+ }
+
+
//*********** NestableAnnotation implementation ****************
-
-
+
/**
* convenience implementation of method from NestableAnnotation interface
* for subclasses
*/
public void initializeFrom(NestableAnnotation oldAnnotation) {
XmlJavaTypeAdapterAnnotation oldJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) oldAnnotation;
- this.setValue(oldJavaTypeAdapterAnnotation.getValue());
+ setValue(oldJavaTypeAdapterAnnotation.getValue());
+ setType(oldJavaTypeAdapterAnnotation.getType());
}
-
+
/**
* convenience implementation of method from NestableAnnotation interface
* for subclasses
@@ -160,23 +213,22 @@ public final class SourceXmlJavaTypeAdapterAnnotation
public void moveAnnotation(int newIndex) {
this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
}
-
+
private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
return (IndexedAnnotationAdapter) this.annotationAdapter;
}
-
-
+
+
// ********** static methods **********
-
+
static SourceXmlJavaTypeAdapterAnnotation createNestedXmlJavaTypeAdapterAnnotation(JavaResourceNode parent, AnnotatedElement annotatedElement, int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) {
IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, javaTypeAdaptersAdapter);
IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(annotatedElement, idaa);
-
+
return new SourceXmlJavaTypeAdapterAnnotation(parent, annotatedElement, idaa, annotationAdapter);
}
-
+
private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter javaTypeAdaptersAdapter) {
return new NestedIndexedDeclarationAnnotationAdapter(javaTypeAdaptersAdapter, index, JAXB.XML_JAVA_TYPE_ADAPTER);
}
-
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java
index bf16f7713e..6f7ceb540b 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/resource/java/source/SourceXmlJavaTypeAdaptersAnnotation.java
@@ -15,8 +15,8 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.core.utility.jdt.AnnotatedElement;
+import org.eclipse.jpt.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.core.utility.jdt.AnnotatedPackage;
import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
@@ -28,7 +28,7 @@ import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
* javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters
*/
public class SourceXmlJavaTypeAdaptersAnnotation
- extends SourceAnnotation<AnnotatedElement>
+ extends SourceAnnotation<AnnotatedPackage>
implements XmlJavaTypeAdaptersAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -36,7 +36,7 @@ public class SourceXmlJavaTypeAdaptersAnnotation
private final Vector<XmlJavaTypeAdapterAnnotation> adapters = new Vector<XmlJavaTypeAdapterAnnotation>();
- public SourceXmlJavaTypeAdaptersAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) {
+ public SourceXmlJavaTypeAdaptersAnnotation(JavaResourcePackage parent, AnnotatedPackage annotatedElement) {
super(parent, annotatedElement, DECLARATION_ANNOTATION_ADAPTER);
}
@@ -76,6 +76,10 @@ public class SourceXmlJavaTypeAdaptersAnnotation
return this.adapters.size();
}
+ public XmlJavaTypeAdapterAnnotation getNestedAnnotation(int index) {
+ return this.adapters.get(index);
+ }
+
public XmlJavaTypeAdapterAnnotation addNestedAnnotation() {
return this.addNestedAnnotation(this.adapters.size());
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java
index 8caf37d22c..ab657ab8c9 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdapterAnnotation.java
@@ -64,4 +64,38 @@ public interface XmlJavaTypeAdapterAnnotation
*/
String getFullyQualifiedValue();
String FULLY_QUALIFIED_VALUE_PROPERTY = "fullyQualifiedValue"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'type' element of the XmlJavaTypeAdapter annotation.
+ * Return null if the element does not exist in Java.
+ * Return the portion of the value preceding ".class".
+ * <pre>
+ * &#64;XmlJavaTypeAdapter(type=Foo.class)
+ * </pre>
+ * will return "Foo"
+ */
+ String getType();
+ String TYPE_PROPERTY = "type"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'type' element of the XmlJavaTypeAdapter annotation.
+ * Set to null to remove the element.
+ */
+ void setType(String type);
+
+ /**
+ * Return the {@link TextRange} for the 'type' element. If the element
+ * does not exist return the {@link TextRange} for the XmlJavaTypeAdapter annotation.
+ */
+ TextRange getTypeTextRange(CompilationUnit astRoot);
+
+ /**
+ * Return the type's fully-qualified class name as resolved by the AST's bindings.
+ * <pre>
+ * &#64;XmlJavaTypeAdapter(type=Foo.class)
+ * </pre>
+ * will return "example.Foo" if there is an import for example.Foo.
+ */
+ String getFullyQualifiedType();
+ String FULLY_QUALIFIED_TYPE_PROPERTY = "fullyQualifiedType"; //$NON-NLS-1$
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java
index 1a70c8a20f..0775044510 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/resource/java/XmlJavaTypeAdaptersAnnotation.java
@@ -30,4 +30,9 @@ public interface XmlJavaTypeAdaptersAnnotation
String ANNOTATION_NAME = JAXB.XML_JAVA_TYPE_ADAPTERS;
String XML_JAVA_TYPE_ADAPTERS_LIST = "xmlJavaTypeAdapters"; //$NON-NLS-1$
+
+ /**
+ * shortcut API
+ */
+ XmlJavaTypeAdapterAnnotation getNestedAnnotation(int index);
}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
index 1c1e39b240..c02b3645c0 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/JaxbJavaResourceModelTests.java
@@ -31,7 +31,8 @@ public class JaxbJavaResourceModelTests {
suite.addTestSuite(XmlIDAnnotationTests.class);
suite.addTestSuite(XmlIDREFAnnotationTests.class);
suite.addTestSuite(XmlInlineBinaryDataAnnotationTests.class);
- suite.addTestSuite(XmlJavaTypeAdapterAnnotationTests.class);
+ suite.addTestSuite(XmlJavaTypeAdapterPackageAnnotationTests.class);
+ suite.addTestSuite(XmlJavaTypeAdapterTypeAnnotationTests.class);
suite.addTestSuite(XmlListAnnotationTests.class);
suite.addTestSuite(XmlMimeTypeAnnotationTests.class);
suite.addTestSuite(XmlMixedAnnotationTests.class);
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterPackageAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterPackageAnnotationTests.java
new file mode 100644
index 0000000000..0b315eb840
--- /dev/null
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterPackageAnnotationTests.java
@@ -0,0 +1,260 @@
+package org.eclipse.jpt.jaxb.core.tests.internal.resource.java;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
+import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdaptersAnnotation;
+
+
+public class XmlJavaTypeAdapterPackageAnnotationTests
+ extends JaxbJavaResourceModelTestCase {
+
+ private static final String TEST_CLASS = "TestClass";
+ private static final String TEST_CLASS_2 = "TestClass2";
+ private static final String FQ_TEST_CLASS = PACKAGE_NAME + "." + TEST_CLASS;
+ private static final String FQ_TEST_CLASS_2 = PACKAGE_NAME + "." + TEST_CLASS_2;
+
+
+ public XmlJavaTypeAdapterPackageAnnotationTests(String name) {
+ super(name);
+ }
+
+
+ private void createTestClass() throws CoreException {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("public class ").append(TEST_CLASS).append(" ");
+ sb.append("{}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, TEST_CLASS + ".java", sourceWriter);
+ }
+
+ private void createTestClass2() throws CoreException {
+ SourceWriter sourceWriter = new SourceWriter() {
+ public void appendSourceTo(StringBuilder sb) {
+ sb.append(CR);
+ sb.append("public class ").append(TEST_CLASS_2).append(" ");
+ sb.append("{}").append(CR);
+ }
+ };
+ this.javaProject.createCompilationUnit(PACKAGE_NAME, TEST_CLASS_2 + ".java", sourceWriter);
+ }
+
+ private ICompilationUnit createPackageInfoWithJavaTypeAdapter() throws CoreException {
+ return createTestPackageInfo(
+ "@XmlJavaTypeAdapter",
+ JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ private ICompilationUnit createPackageInfoWithJavaTypeAdapterAndValue() throws CoreException {
+ createTestClass();
+ return createTestPackageInfo(
+ "@XmlJavaTypeAdapter(" + TEST_CLASS + ".class)",
+ JAXB.XML_JAVA_TYPE_ADAPTER, FQ_TEST_CLASS);
+ }
+
+ private ICompilationUnit createPackageInfoWithJavaTypeAdapterAndType() throws CoreException {
+ createTestClass();
+ return createTestPackageInfo(
+ "@XmlJavaTypeAdapter(type = " + TEST_CLASS + ".class)",
+ JAXB.XML_JAVA_TYPE_ADAPTER, FQ_TEST_CLASS);
+ }
+
+ private ICompilationUnit createPackageInfoWithJavaTypeAdapters() throws CoreException {
+ return createTestPackageInfo(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter,@XmlJavaTypeAdapter})",
+ JAXB.XML_JAVA_TYPE_ADAPTERS, JAXB.XML_JAVA_TYPE_ADAPTER);
+ }
+
+ public void testValue()
+ throws Exception {
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapterAndValue();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass2();
+
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(annotation != null);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedValue());
+ assertSourceContains("@XmlJavaTypeAdapter(" + TEST_CLASS + ".class)", cu);
+
+ annotation.setValue(TEST_CLASS_2);
+ assertEquals(TEST_CLASS_2, annotation.getValue());
+ assertEquals(FQ_TEST_CLASS_2, annotation.getFullyQualifiedValue());
+ assertSourceContains("@XmlJavaTypeAdapter(" + TEST_CLASS_2 + ".class)", cu);
+
+ annotation.setValue(null);
+ assertEquals(null, annotation.getValue());
+ assertEquals(null, annotation.getFullyQualifiedValue());
+ assertSourceContains("@XmlJavaTypeAdapter", cu);
+
+ annotation.setValue(TEST_CLASS);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedValue());
+ assertSourceContains("@XmlJavaTypeAdapter(" + TEST_CLASS + ".class)", cu);
+ }
+
+ public void testType()
+ throws Exception {
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapterAndType();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass2();
+
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(annotation != null);
+ assertEquals(TEST_CLASS, annotation.getType());
+ assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedType());
+ assertSourceContains("@XmlJavaTypeAdapter(type = " + TEST_CLASS + ".class)", cu);
+
+ annotation.setType(TEST_CLASS_2);
+ assertEquals(TEST_CLASS_2, annotation.getType());
+ assertEquals(FQ_TEST_CLASS_2, annotation.getFullyQualifiedType());
+ assertSourceContains("@XmlJavaTypeAdapter(type = " + TEST_CLASS_2 + ".class)", cu);
+
+ annotation.setType(null);
+ assertEquals(null, annotation.getType());
+ assertEquals(null, annotation.getFullyQualifiedType());
+ assertSourceContains("@XmlJavaTypeAdapter", cu);
+
+ annotation.setType(TEST_CLASS);
+ assertEquals(TEST_CLASS, annotation.getType());
+ assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedType());
+ assertSourceContains("@XmlJavaTypeAdapter(type = " + TEST_CLASS + ".class)", cu);
+ }
+
+ public void testTypeWithValue()
+ throws Exception {
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapterAndValue();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass2();
+
+ XmlJavaTypeAdapterAnnotation annotation =
+ (XmlJavaTypeAdapterAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
+ assertTrue(annotation != null);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertSourceContains("@XmlJavaTypeAdapter(" + TEST_CLASS + ".class)", cu);
+
+ annotation.setType(TEST_CLASS_2);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertEquals(TEST_CLASS_2, annotation.getType());
+ assertSourceContains("@XmlJavaTypeAdapter(value = " + TEST_CLASS + ".class, type = " + TEST_CLASS_2 + ".class)", cu);
+
+ annotation.setValue(null);
+ assertEquals(null, annotation.getValue());
+ assertEquals(TEST_CLASS_2, annotation.getType());
+ assertSourceContains("@XmlJavaTypeAdapter(type = " + TEST_CLASS_2 + ".class)", cu);
+
+ annotation.setValue(TEST_CLASS);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertEquals(TEST_CLASS_2, annotation.getType());
+ assertSourceContains("@XmlJavaTypeAdapter(type = " + TEST_CLASS_2 + ".class, value = " + TEST_CLASS + ".class)", cu);
+
+ annotation.setType(null);
+ assertEquals(TEST_CLASS, annotation.getValue());
+ assertEquals(null, annotation.getType());
+ assertSourceContains("@XmlJavaTypeAdapter(" + TEST_CLASS + ".class)", cu);
+ }
+
+ public void testContainedWithValue()
+ throws Exception {
+ // test contained annotation value setting/updating
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapters();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass();
+
+ XmlJavaTypeAdaptersAnnotation adaptersAnnotation =
+ (XmlJavaTypeAdaptersAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTERS);
+ XmlJavaTypeAdapterAnnotation adapterAnnotation = adaptersAnnotation.getNestedAnnotation(0);
+
+ adapterAnnotation.setValue(TEST_CLASS);
+ assertEquals(TEST_CLASS, adapterAnnotation.getValue());
+ assertEquals(FQ_TEST_CLASS, adapterAnnotation.getFullyQualifiedValue());
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(" + TEST_CLASS + ".class),@XmlJavaTypeAdapter})", cu);
+
+ adapterAnnotation.setValue(null);
+ assertNull(adapterAnnotation.getValue());
+ assertNull(FQ_TEST_CLASS, adapterAnnotation.getFullyQualifiedValue());
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter,@XmlJavaTypeAdapter})", cu);
+ }
+
+ public void testContainedWithType()
+ throws Exception {
+ // test contained annotation type setting/updating
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapters();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass();
+
+ XmlJavaTypeAdaptersAnnotation adaptersAnnotation =
+ (XmlJavaTypeAdaptersAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTERS);
+ XmlJavaTypeAdapterAnnotation adapterAnnotation = adaptersAnnotation.getNestedAnnotation(1);
+
+ adapterAnnotation.setType(TEST_CLASS);
+ assertEquals(TEST_CLASS, adapterAnnotation.getType());
+ assertEquals(FQ_TEST_CLASS, adapterAnnotation.getFullyQualifiedType());
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter,@XmlJavaTypeAdapter(type = " + TEST_CLASS + ".class)})", cu);
+
+ adapterAnnotation.setType(null);
+ assertNull(adapterAnnotation.getType());
+ assertNull(FQ_TEST_CLASS, adapterAnnotation.getFullyQualifiedType());
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter,@XmlJavaTypeAdapter})", cu);
+ }
+
+ public void testContained()
+ throws Exception {
+ // test adding/removing/moving
+
+ ICompilationUnit cu = createPackageInfoWithJavaTypeAdapter();
+ JavaResourcePackage packageResource = buildJavaResourcePackage(cu);
+ createTestClass();
+ createTestClass2();
+
+ XmlJavaTypeAdaptersAnnotation adaptersAnnotation =
+ (XmlJavaTypeAdaptersAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTERS);
+ assertNull(adaptersAnnotation);
+
+ packageResource.addAnnotation(1, JAXB.XML_JAVA_TYPE_ADAPTER, JAXB.XML_JAVA_TYPE_ADAPTERS);
+ adaptersAnnotation =
+ (XmlJavaTypeAdaptersAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTERS);
+ assertEquals(2, adaptersAnnotation.getNestedAnnotationsSize());
+ assertSourceContains("@XmlJavaTypeAdapters({@XmlJavaTypeAdapter,@XmlJavaTypeAdapter})", cu);
+
+ XmlJavaTypeAdapterAnnotation adapterAnnotation1 = adaptersAnnotation.getNestedAnnotation(0);
+ adapterAnnotation1.setValue(TEST_CLASS);
+ XmlJavaTypeAdapterAnnotation adapterAnnotation2 = adaptersAnnotation.getNestedAnnotation(1);
+ adapterAnnotation2.setValue(TEST_CLASS_2);
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(" + TEST_CLASS
+ + ".class),@XmlJavaTypeAdapter(" + TEST_CLASS_2
+ + ".class)})", cu);
+
+ packageResource.moveAnnotation(0, 1, JAXB.XML_JAVA_TYPE_ADAPTERS);
+ assertSourceContains(
+ "@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(" + TEST_CLASS_2
+ + ".class),@XmlJavaTypeAdapter(" + TEST_CLASS
+ + ".class)})", cu);
+
+// TODO uncomment when bug 328400 is addressed
+// packageResource.removeAnnotation(1, JAXB.XML_JAVA_TYPE_ADAPTER, JAXB.XML_JAVA_TYPE_ADAPTERS);
+// adaptersAnnotation =
+// (XmlJavaTypeAdaptersAnnotation) packageResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTERS);
+// assertNull(adaptersAnnotation);
+// assertSourceContains(
+// "@XmlJavaTypeAdapter(" + TEST_CLASS_2 + ")", cu);
+ }
+}
diff --git a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterTypeAnnotationTests.java
index f8015d4711..53ab19c722 100644
--- a/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterAnnotationTests.java
+++ b/jaxb/tests/org.eclipse.jpt.jaxb.core.tests/src/org/eclipse/jpt/jaxb/core/tests/internal/resource/java/XmlJavaTypeAdapterTypeAnnotationTests.java
@@ -18,11 +18,11 @@ import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
@SuppressWarnings("nls")
-public class XmlJavaTypeAdapterAnnotationTests extends JaxbJavaResourceModelTestCase {
+public class XmlJavaTypeAdapterTypeAnnotationTests extends JaxbJavaResourceModelTestCase {
private static final String XML_JAVA_TYPE_ADAPTER_CLASS = "MyAdapterClass";
- public XmlJavaTypeAdapterAnnotationTests(String name) {
+ public XmlJavaTypeAdapterTypeAnnotationTests(String name) {
super(name);
}
@@ -108,17 +108,4 @@ public class XmlJavaTypeAdapterAnnotationTests extends JaxbJavaResourceModelTest
assertSourceContains("@XmlJavaTypeAdapter", cu);
assertSourceDoesNotContain("@XmlJavaTypeAdapter(" + XML_JAVA_TYPE_ADAPTER_CLASS + ".class)", cu);
}
-
- public void testAddXmlJavaTypeAdapterAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestXmlJavaTypeAdapterWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation = (XmlJavaTypeAdapterAnnotation) typeResource.getAnnotation(JAXB.XML_JAVA_TYPE_ADAPTER);
- assertTrue(xmlJavaTypeAdapterAnnotation != null);
- assertEquals(XML_JAVA_TYPE_ADAPTER_CLASS, xmlJavaTypeAdapterAnnotation.getValue());
-
- XmlJavaTypeAdapterAnnotation xmlJavaTypeAdapterAnnotation2 = (XmlJavaTypeAdapterAnnotation) typeResource.addAnnotation(1, JAXB.XML_JAVA_TYPE_ADAPTER, JAXB.XML_JAVA_TYPE_ADAPTERS);
- xmlJavaTypeAdapterAnnotation2.setValue("Foo");
- assertSourceContains("@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(" + XML_JAVA_TYPE_ADAPTER_CLASS + ".class),@XmlJavaTypeAdapter(Foo.class)})", cu);
- }
}

Back to the top