Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java215
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java586
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java48
23 files changed, 527 insertions, 695 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java
index e61f395f62..3fc989ff90 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java
@@ -65,33 +65,23 @@ public abstract class NullAnnotation
}
/**
- * Convenience method: Set the type or attribute's mapping annotation
+ * Convenience method: Add the type or attribute's annotation
* and return it.
* Pre-condition: The annotation's parent must be a persistent member
* (type or attribute).
*/
- protected Annotation setMappingAnnotation() {
- return this.getMember().setMappingAnnotation(this.getAnnotationName());
- }
-
- /**
- * Convenience method: Add to the type or attribute's list of "supporting"
- * annotations and return the newly created annotation.
- * Pre-condition: The annotation's parent must be a persistent member
- * (type or attribute).
- */
- protected Annotation addSupportingAnnotation() {
- return this.getMember().addSupportingAnnotation(this.getAnnotationName());
+ protected Annotation addAnnotation() {
+ return this.getMember().addAnnotation(this.getAnnotationName());
}
/**
- * Convenience method: Add to the type or attribute's list of "supporting"
- * annotations and return the newly created annotation.
+ * Convenience method: Add the type or attribute's annotation
+ * and return it.
* Pre-condition: The annotation's parent must be a persistent member
* (type or attribute).
*/
- protected Annotation addSupportingAnnotation(JavaResourcePersistentMember.AnnotationInitializer initializer) {
- return this.getMember().addSupportingAnnotation(this.getAnnotationName(), initializer);
+ protected Annotation addAnnotation(
+ JavaResourcePersistentMember.AnnotationInitializer initializer) {
+ return this.getMember().addAnnotation(this.getAnnotationName(), initializer);
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java
index 7e458a36eb..85f0c6fe08 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java
@@ -30,5 +30,4 @@ public class NullAttributeOverrideColumnAnnotation
protected ColumnAnnotation addAnnotation() {
return this.getAttributeOverrideAnnotation().addColumn();
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java
index 8adf3b2eef..477b7f8da0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java
@@ -27,7 +27,9 @@ public abstract class NullBaseColumnAnnotation
}
@Override
- protected abstract BaseColumnAnnotation addAnnotation();
+ protected BaseColumnAnnotation addAnnotation() {
+ return (BaseColumnAnnotation) super.addAnnotation();
+ }
// ***** table
public String getTable() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java
index 29babc3267..93160b0452 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java
@@ -10,12 +10,9 @@
package org.eclipse.jpt.core.internal.resource.java;
import java.util.ListIterator;
-
import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.BaseTableAnnotation;
import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember.AnnotationInitializer;
import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
@@ -32,10 +29,11 @@ public abstract class NullBaseTableAnnotation
super(parent);
}
- protected abstract BaseTableAnnotation addAnnotation();
+ @Override
+ protected BaseTableAnnotation addAnnotation() {
+ return (BaseTableAnnotation) super.addAnnotation();
+ }
- protected abstract Annotation addAnnotation(AnnotationInitializer initializer);
-
public boolean isSpecified() {
return false;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java
index 4eb37a88d7..0e16de1e07 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java
@@ -25,44 +25,48 @@ public final class NullBasicAnnotation
protected NullBasicAnnotation(JavaResourcePersistentAttribute parent) {
super(parent);
}
-
+
+
public String getAnnotationName() {
return ANNOTATION_NAME;
}
-
+
@Override
- protected BasicAnnotation setMappingAnnotation() {
- return (BasicAnnotation) super.setMappingAnnotation();
+ protected BasicAnnotation addAnnotation() {
+ return (BasicAnnotation) super.addAnnotation();
}
-
+
+
// ***** fetch
+
public FetchType getFetch() {
return null;
}
-
+
public void setFetch(FetchType fetch) {
if (fetch != null) {
- this.setMappingAnnotation().setFetch(fetch);
+ this.addAnnotation().setFetch(fetch);
}
}
-
+
public TextRange getFetchTextRange(CompilationUnit astRoot) {
return null;
}
-
+
+
// ***** optional
+
public Boolean getOptional() {
return null;
}
-
+
public void setOptional(Boolean optional) {
if (optional != null) {
- this.setMappingAnnotation().setOptional(optional);
+ this.addAnnotation().setOptional(optional);
}
}
-
+
public TextRange getOptionalTextRange(CompilationUnit astRoot) {
return null;
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java
index 927be6ef1c..3bf5452a0b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java
@@ -31,7 +31,7 @@ public class NullColumnAnnotation
@Override
protected ColumnAnnotation addAnnotation() {
- return (ColumnAnnotation) this.addSupportingAnnotation();
+ return (ColumnAnnotation) super.addAnnotation();
}
// ***** length
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java
index 038dc6ecf5..126ad60814 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java
@@ -30,7 +30,7 @@ public final class NullDiscriminatorColumnAnnotation
@Override
protected DiscriminatorColumnAnnotation addAnnotation() {
- return (DiscriminatorColumnAnnotation) this.addSupportingAnnotation();
+ return (DiscriminatorColumnAnnotation) super.addAnnotation();
}
// ***** discriminator type
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java
index d8809ec50c..7a68d3d2dc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java
@@ -31,8 +31,8 @@ public final class NullDiscriminatorValueAnnotation
}
@Override
- protected DiscriminatorValueAnnotation addSupportingAnnotation() {
- return (DiscriminatorValueAnnotation) super.addSupportingAnnotation();
+ protected DiscriminatorValueAnnotation addAnnotation() {
+ return (DiscriminatorValueAnnotation) super.addAnnotation();
}
// ***** value
@@ -42,7 +42,7 @@ public final class NullDiscriminatorValueAnnotation
public void setValue(String value) {
if (value != null) {
- this.addSupportingAnnotation().setValue(value);
+ this.addAnnotation().setValue(value);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java
index 76d961ae1c..1e45dd51a9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java
@@ -31,8 +31,8 @@ public final class NullEnumeratedAnnotation
}
@Override
- protected EnumeratedAnnotation addSupportingAnnotation() {
- return (EnumeratedAnnotation) super.addSupportingAnnotation();
+ protected EnumeratedAnnotation addAnnotation() {
+ return (EnumeratedAnnotation) super.addAnnotation();
}
// ***** value
@@ -42,7 +42,7 @@ public final class NullEnumeratedAnnotation
public void setValue(EnumType value) {
if (value != null) {
- this.addSupportingAnnotation().setValue(value);
+ this.addAnnotation().setValue(value);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java
index 5946de7915..a4130b1b6e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java
@@ -31,8 +31,8 @@ public final class NullInheritanceAnnotation
}
@Override
- protected InheritanceAnnotation addSupportingAnnotation() {
- return (InheritanceAnnotation) super.addSupportingAnnotation();
+ protected InheritanceAnnotation addAnnotation() {
+ return (InheritanceAnnotation) super.addAnnotation();
}
// ***** strategy
@@ -42,7 +42,7 @@ public final class NullInheritanceAnnotation
public void setStrategy(InheritanceType strategy) {
if (strategy != null) {
- this.addSupportingAnnotation().setStrategy(strategy);
+ this.addAnnotation().setStrategy(strategy);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java
index 3a050497b0..f54c7aac97 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java
@@ -35,12 +35,12 @@ public class NullJoinTableAnnotation
@Override
protected JoinTableAnnotation addAnnotation() {
- return (JoinTableAnnotation) this.addSupportingAnnotation();
+ return (JoinTableAnnotation) super.addAnnotation();
}
@Override
protected JoinColumnAnnotation addAnnotation(AnnotationInitializer initializer) {
- return (JoinColumnAnnotation) this.addSupportingAnnotation(initializer);
+ return (JoinColumnAnnotation) super.addAnnotation(initializer);
}
// ***** join columns
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java
index ae673da038..0ae2b8cf38 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java
@@ -31,9 +31,12 @@ public abstract class NullNamedColumnAnnotation
public boolean isSpecified() {
return false;
}
-
- protected abstract NamedColumnAnnotation addAnnotation();
-
+
+ @Override
+ protected NamedColumnAnnotation addAnnotation() {
+ return (NamedColumnAnnotation) super.addAnnotation();
+ }
+
// ***** name
public String getName() {
return null;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java
index c477cd8172..ce6374c71b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java
@@ -30,8 +30,8 @@ public final class NullOneToOneAnnotation
}
@Override
- protected OneToOneAnnotation setMappingAnnotation() {
- return (OneToOneAnnotation) super.setMappingAnnotation();
+ protected OneToOneAnnotation addAnnotation() {
+ return (OneToOneAnnotation) super.addAnnotation();
}
// ***** optional
@@ -41,7 +41,7 @@ public final class NullOneToOneAnnotation
public void setOptional(Boolean optional) {
if (optional != null) {
- this.setMappingAnnotation().setOptional(optional);
+ this.addAnnotation().setOptional(optional);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java
index a14c881e54..dd29a044d7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java
@@ -26,113 +26,131 @@ public abstract class NullOwnableRelationshipMappingAnnotation
protected NullOwnableRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent) {
super(parent);
}
-
+
+
@Override
- protected OwnableRelationshipMappingAnnotation setMappingAnnotation() {
- return (OwnableRelationshipMappingAnnotation) super.setMappingAnnotation();
+ protected OwnableRelationshipMappingAnnotation addAnnotation() {
+ return (OwnableRelationshipMappingAnnotation) super.addAnnotation();
}
-
+
+
// ***** target entity
+
public String getTargetEntity() {
return null;
}
-
+
public void setTargetEntity(String targetEntity) {
if (targetEntity != null) {
- this.setMappingAnnotation().setTargetEntity(targetEntity);
+ this.addAnnotation().setTargetEntity(targetEntity);
}
}
-
+
public TextRange getTargetEntityTextRange(CompilationUnit astRoot) {
return null;
}
-
+
+
// ***** fully-qualified target entity class name
+
public String getFullyQualifiedTargetEntityClassName() {
return null;
}
-
+
+
// ***** mapped by
+
public String getMappedBy() {
return null;
}
-
+
public void setMappedBy(String mappedBy) {
if (mappedBy != null) {
- this.setMappingAnnotation().setMappedBy(mappedBy);
+ this.addAnnotation().setMappedBy(mappedBy);
}
}
-
+
public TextRange getMappedByTextRange(CompilationUnit astRoot) {
return null;
}
-
+
public boolean mappedByTouches(int pos, CompilationUnit astRoot) {
return false;
}
-
+
+
// ***** fetch
+
public FetchType getFetch() {
return null;
}
-
+
public void setFetch(FetchType fetch) {
if (fetch != null) {
- this.setMappingAnnotation().setFetch(fetch);
+ this.addAnnotation().setFetch(fetch);
}
}
-
+
public TextRange getFetchTextRange(CompilationUnit astRoot) {
return null;
}
-
+
+
// ***** cascade all
+
public boolean isCascadeAll() {
return false;
}
-
+
public void setCascadeAll(boolean all) {
- this.setMappingAnnotation().setCascadeAll(all);
+ this.addAnnotation().setCascadeAll(all);
}
-
+
+
// ***** cascade merge
+
public boolean isCascadeMerge() {
return false;
}
-
+
public void setCascadeMerge(boolean merge) {
- this.setMappingAnnotation().setCascadeMerge(merge);
+ this.addAnnotation().setCascadeMerge(merge);
}
-
+
+
// ***** cascade persist
+
public boolean isCascadePersist() {
return false;
}
-
+
public void setCascadePersist(boolean persist) {
- this.setMappingAnnotation().setCascadePersist(persist);
+ this.addAnnotation().setCascadePersist(persist);
}
-
+
+
// ***** cascade refresh
+
public boolean isCascadeRefresh() {
return false;
}
-
+
public void setCascadeRefresh(boolean refresh) {
- this.setMappingAnnotation().setCascadeRefresh(refresh);
+ this.addAnnotation().setCascadeRefresh(refresh);
}
-
+
+
// ***** cascade remove
+
public boolean isCascadeRemove() {
return false;
}
-
+
public void setCascadeRemove(boolean remove) {
- this.setMappingAnnotation().setCascadeRemove(remove);
+ this.addAnnotation().setCascadeRemove(remove);
}
-
+
public TextRange getCascadeTextRange(CompilationUnit astRoot) {
return null;
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java
index 86433bedf3..bc831e7093 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java
@@ -26,12 +26,12 @@ public final class NullTableAnnotation
@Override
protected TableAnnotation addAnnotation() {
- return (TableAnnotation) addSupportingAnnotation();
+ return (TableAnnotation) super.addAnnotation();
}
@Override
protected TableAnnotation addAnnotation(AnnotationInitializer initializer) {
- return (TableAnnotation) addSupportingAnnotation(initializer);
+ return (TableAnnotation) super.addAnnotation(initializer);
}
public String getAnnotationName() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java
index b661b3dc22..ec38b00a84 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java
@@ -31,8 +31,8 @@ public final class NullTemporalAnnotation
}
@Override
- protected TemporalAnnotation addSupportingAnnotation() {
- return (TemporalAnnotation) super.addSupportingAnnotation();
+ protected TemporalAnnotation addAnnotation() {
+ return (TemporalAnnotation) super.addAnnotation();
}
@@ -45,7 +45,7 @@ public final class NullTemporalAnnotation
public void setValue(TemporalType value) {
if (value != null) {
- this.addSupportingAnnotation().setValue(value);
+ this.addAnnotation().setValue(value);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java
index 3b60ab685e..734439b56d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java
@@ -14,7 +14,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Vector;
-
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
@@ -63,7 +62,7 @@ final class BinaryPackageFragment
IType jdtType = jdtClassFile.getType();
if (BinaryPersistentType.typeIsPersistable(jdtType)) {
JavaResourceClassFile classFile = new BinaryClassFile(this, jdtClassFile, jdtType);
- if (classFile.getPersistentType().isPersisted()) { // we only hold annotated types
+ if (classFile.getPersistentType().isAnnotated()) { // we only hold annotated types
result.add(classFile);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
index e305cebe2e..7d5c4d9725 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java
@@ -17,7 +17,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Vector;
-
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaProject;
@@ -107,51 +106,37 @@ final class BinaryPersistentAttribute
// ********** BinaryPersistentMember implementation **********
-
+
private Adapter getAdapter() {
return (Adapter) this.adapter;
}
-
- @Override
- Annotation buildMappingAnnotation(IAnnotation jdtAnnotation) {
- return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, jdtAnnotation);
- }
-
+
@Override
- Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) {
- return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, jdtAnnotation);
- }
-
- @Override
- Annotation buildNullSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, annotationName);
- }
-
- public Annotation getNullMappingAnnotation(String annotationName) {
- return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName);
+ Iterator<String> validAnnotationNames() {
+ return this.getAnnotationProvider().attributeAnnotationNames();
}
-
- private Annotation buildNullMappingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, annotationName);
- }
-
+
@Override
- ListIterator<String> validMappingAnnotationNames() {
- return this.getAnnotationProvider().attributeMappingAnnotationNames();
+ Annotation buildAnnotation(IAnnotation jdtAnnotation) {
+ return this.getAnnotationProvider().buildAttributeAnnotation(this, jdtAnnotation);
}
-
+
@Override
- ListIterator<String> validSupportingAnnotationNames() {
- return this.getAnnotationProvider().attributeSupportingAnnotationNames();
+ Annotation buildNullAnnotation(String annotationName) {
+ return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName);
}
-
-
+
+
// ********** JavaResourcePersistentAttribute implementation **********
-
+
public String getName() {
return this.getAdapter().getAttributeName();
}
-
+
+ public Annotation getNullAnnotation(String annotationName) {
+ return (annotationName == null) ? null : this.buildNullAnnotation(annotationName);
+ }
+
public boolean isField() {
return this.getAdapter().isField();
}
@@ -164,13 +149,8 @@ final class BinaryPersistentAttribute
throw new UnsupportedOperationException();
}
- public boolean hasAnyPersistenceAnnotations() {
- return (this.mappingAnnotationsSize() > 0)
- || (this.supportingAnnotationsSize() > 0);
- }
-
public AccessType getSpecifiedAccess() {
- Access2_0Annotation accessAnnotation = (Access2_0Annotation) this.getSupportingAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ Access2_0Annotation accessAnnotation = (Access2_0Annotation) this.getAnnotation(Access2_0Annotation.ANNOTATION_NAME);
return accessAnnotation == null ? null : accessAnnotation.getValue();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java
index 9d51125ed1..c8676f67c6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java
@@ -10,9 +10,7 @@
package org.eclipse.jpt.core.internal.resource.java.binary;
import java.util.Iterator;
-import java.util.ListIterator;
import java.util.Vector;
-
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.JavaModelException;
@@ -27,10 +25,9 @@ import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterables.SnapshotCloneIterable;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
/**
* binary persistent member
@@ -41,16 +38,13 @@ abstract class BinaryPersistentMember
{
/** JDT member adapter */
final Adapter adapter;
-
- /** mapping annotations */
- final Vector<Annotation> mappingAnnotations = new Vector<Annotation>();
-
- /** supporting annotations */
- final Vector<Annotation> supportingAnnotations = new Vector<Annotation>();
-
+
+ /** annotations */
+ final Vector<Annotation> annotations = new Vector<Annotation>();
+
boolean persistable;
-
-
+
+
// ********** construction/initialization **********
public BinaryPersistentMember(JavaResourceNode parent, Adapter adapter) {
@@ -67,121 +61,85 @@ abstract class BinaryPersistentMember
}
private void addAnnotation(IAnnotation jdtAnnotation) {
- if (this.annotationIsValidSupportingAnnotation(jdtAnnotation)) {
- this.supportingAnnotations.add(this.buildSupportingAnnotation(jdtAnnotation));
- } else if (this.annotationIsValidMappingAnnotation(jdtAnnotation)) {
- this.mappingAnnotations.add(this.buildMappingAnnotation(jdtAnnotation));
+ if (this.annotationIsValid(jdtAnnotation)) {
+ this.annotations.add(this.buildAnnotation(jdtAnnotation));
}
}
-
-
+
+
// ********** updating **********
-
+
@Override
public void update() {
super.update();
this.updateAnnotations();
this.setPersistable(this.buildPersistable());
}
-
+
// TODO
private void updateAnnotations() {
throw new UnsupportedOperationException();
}
-
-
- // ********** mapping annotations **********
-
- public Iterator<Annotation> mappingAnnotations() {
- return this.getMappingAnnotations().iterator();
- }
-
- private Iterable<Annotation> getMappingAnnotations() {
- return new LiveCloneIterable<Annotation>(this.mappingAnnotations);
- }
-
- public int mappingAnnotationsSize() {
- return this.mappingAnnotations.size();
- }
-
- public Annotation getMappingAnnotation() {
- Iterable<Annotation> annotations = new SnapshotCloneIterable<Annotation>(this.mappingAnnotations);
- for (ListIterator<String> stream = this.validMappingAnnotationNames(); stream.hasNext();) {
- Annotation annotation = this.selectAnnotationNamed(annotations, stream.next());
- if (annotation != null) {
- return annotation;
- }
- }
- return null;
- }
-
- public Annotation getMappingAnnotation(String annotationName) {
- return this.selectAnnotationNamed(this.getMappingAnnotations(), annotationName);
- }
-
- private boolean annotationIsValidMappingAnnotation(IAnnotation jdtAnnotation) {
- return CollectionTools.contains(this.validMappingAnnotationNames(), jdtAnnotation.getElementName());
- }
-
- abstract ListIterator<String> validMappingAnnotationNames();
-
- abstract Annotation buildMappingAnnotation(IAnnotation jdtAnnotation);
-
-
- // ********** supporting annotations **********
-
- public Iterator<Annotation> supportingAnnotations() {
- return this.getSupportingAnnotations().iterator();
- }
-
- private Iterable<Annotation> getSupportingAnnotations() {
- return new LiveCloneIterable<Annotation>(this.supportingAnnotations);
- }
-
- public int supportingAnnotationsSize() {
- return this.supportingAnnotations.size();
- }
-
- public ListIterator<NestableAnnotation> supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) {
- ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName);
+
+
+ // ********** annotations **********
+
+ public Iterator<Annotation> annotations() {
+ return this.getAnnotations().iterator();
+ }
+
+ private Iterable<Annotation> getAnnotations() {
+ return new LiveCloneIterable<Annotation>(this.annotations);
+ }
+
+ public int annotationsSize() {
+ return this.annotations.size();
+ }
+
+ public Annotation getAnnotation(String annotationName) {
+ return this.selectAnnotationNamed(this.getAnnotations(), annotationName);
+ }
+
+ public Annotation getNonNullAnnotation(String annotationName) {
+ Annotation annotation = this.getAnnotation(annotationName);
+ return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName);
+ }
+
+ public Iterator<NestableAnnotation> annotations(
+ String nestableAnnotationName, String containerAnnotationName) {
+ ContainerAnnotation<NestableAnnotation> containerAnnotation =
+ getContainerAnnotation(containerAnnotationName);
if (containerAnnotation != null) {
return containerAnnotation.nestedAnnotations();
}
- NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName);
+ NestableAnnotation nestableAnnotation =
+ getNestableAnnotation(nestableAnnotationName);
return (nestableAnnotation == null) ?
EmptyListIterator.<NestableAnnotation>instance() :
- new SingleElementListIterator<NestableAnnotation>(nestableAnnotation);
- }
-
- private NestableAnnotation getSupportingNestableAnnotation(String annotationName) {
- return (NestableAnnotation) this.getSupportingAnnotation(annotationName);
- }
-
- public Annotation getSupportingAnnotation(String annotationName) {
- return this.selectAnnotationNamed(this.getSupportingAnnotations(), annotationName);
- }
-
- public Annotation getNonNullSupportingAnnotation(String annotationName) {
- Annotation annotation = this.getSupportingAnnotation(annotationName);
- return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName);
+ new SingleElementIterator<NestableAnnotation>(nestableAnnotation);
}
-
- abstract Annotation buildNullSupportingAnnotation(String annotationName);
-
- abstract Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation);
-
- private boolean annotationIsValidSupportingAnnotation(IAnnotation jdtAnnotation) {
- return CollectionTools.contains(this.validSupportingAnnotationNames(), jdtAnnotation.getElementName());
+
+ private NestableAnnotation getNestableAnnotation(String annotationName) {
+ return (NestableAnnotation) this.getAnnotation(annotationName);
}
-
- abstract ListIterator<String> validSupportingAnnotationNames();
-
+
@SuppressWarnings("unchecked")
- private ContainerAnnotation<NestableAnnotation> getSupportingContainerAnnotation(String annotationName) {
- return (ContainerAnnotation<NestableAnnotation>) this.getSupportingAnnotation(annotationName);
- }
-
-
+ private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) {
+ return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName);
+ }
+
+ private boolean annotationIsValid(IAnnotation jdtAnnotation) {
+ return CollectionTools.contains(
+ this.validAnnotationNames(), jdtAnnotation.getElementName());
+ }
+
+ abstract Iterator<String> validAnnotationNames();
+
+ abstract Annotation buildAnnotation(IAnnotation jdtAnnotation);
+
+ abstract Annotation buildNullAnnotation(String annotationName);
+
+
// ********** simple state **********
public boolean isPersistable() {
@@ -198,8 +156,8 @@ abstract class BinaryPersistentMember
return this.adapter.isPersistable();
}
- public boolean isPersisted() {
- return this.getMappingAnnotation() != null;
+ public boolean isAnnotated() {
+ return ! this.annotations.isEmpty();
}
@@ -278,45 +236,48 @@ abstract class BinaryPersistentMember
// ********** unsupported JavaResourcePersistentMember implementation **********
-
- public Annotation setMappingAnnotation(String annotationName) {
+
+ public Annotation addAnnotation(String annotationName) {
throw new UnsupportedOperationException();
}
-
- public Annotation addSupportingAnnotation(String annotationName) {
+
+ public Annotation addAnnotation(String annotationName, AnnotationInitializer foo) {
throw new UnsupportedOperationException();
}
-
- public Annotation addSupportingAnnotation(String annotationName, AnnotationInitializer foo) {
+
+ public NestableAnnotation addAnnotation(
+ int index, String nestableAnnotationName, String containerAnnotationName) {
throw new UnsupportedOperationException();
}
-
- public Annotation addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
+
+ public void moveAnnotation(
+ int targetIndex, int sourceIndex, String containerAnnotationName) {
throw new UnsupportedOperationException();
}
-
- public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) {
+
+ public void removeAnnotation(String annotationName) {
throw new UnsupportedOperationException();
}
-
- public void removeSupportingAnnotation(String annotationName) {
+
+ public void removeAnnotation(
+ int index, String nestableAnnotationName, String containerAnnotationName) {
throw new UnsupportedOperationException();
}
-
- public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
+
+ public Annotation setPrimaryAnnotation(
+ String primaryAnnotationName, String[] supportingAnnotationNames) {
throw new UnsupportedOperationException();
}
-
+
public TextRange getNameTextRange(CompilationUnit astRoot) {
throw new UnsupportedOperationException();
}
-
+
public void resolveTypes(CompilationUnit astRoot) {
throw new UnsupportedOperationException();
}
-
+
public boolean isFor(String memberName, int occurrence) {
throw new UnsupportedOperationException();
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
index 4f14df4511..6fa97b6b8c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
@@ -11,9 +11,7 @@ package org.eclipse.jpt.core.internal.resource.java.binary;
import java.util.Collection;
import java.util.Iterator;
-import java.util.ListIterator;
import java.util.Vector;
-
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
@@ -103,31 +101,21 @@ final class BinaryPersistentType
// ********** BinaryPersistentMember implementation **********
@Override
- Annotation buildMappingAnnotation(IAnnotation jdtAnnotation) {
- return this.getAnnotationProvider().buildTypeMappingAnnotation(this, jdtAnnotation);
+ Annotation buildAnnotation(IAnnotation jdtAnnotation) {
+ return this.getAnnotationProvider().buildTypeAnnotation(this, jdtAnnotation);
}
@Override
- Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) {
- return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, jdtAnnotation);
+ Annotation buildNullAnnotation(String annotationName) {
+ return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName);
}
@Override
- Annotation buildNullSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, annotationName);
+ Iterator<String> validAnnotationNames() {
+ return this.getAnnotationProvider().typeAnnotationNames();
}
- @Override
- ListIterator<String> validMappingAnnotationNames() {
- return this.getAnnotationProvider().typeMappingAnnotationNames();
- }
- @Override
- ListIterator<String> validSupportingAnnotationNames() {
- return this.getAnnotationProvider().typeSupportingAnnotationNames();
- }
-
-
// ********** JavaResourcePersistentType implementation **********
// ***** name
@@ -218,13 +206,13 @@ final class BinaryPersistentType
private AccessType buildAccess() {
return JPTTools.buildAccess(this);
}
-
+
/**
* check only persistable attributes
*/
- public boolean hasAnyAttributePersistenceAnnotations() {
+ public boolean hasAnyAnnotatedAttributes() {
for (Iterator<JavaResourcePersistentAttribute> stream = this.persistableAttributes(); stream.hasNext(); ) {
- if (stream.next().hasAnyPersistenceAnnotations()) {
+ if (stream.next().isAnnotated()) {
return true;
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java
index 0129138e8e..32901780c1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java
@@ -17,7 +17,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
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;
@@ -150,69 +149,53 @@ final class SourcePersistentAttribute
// ******** AbstractJavaResourcePersistentMember implementation ********
-
- @Override
- Annotation buildMappingAnnotation(String mappingAnnotationName) {
- return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, this.member, mappingAnnotationName);
- }
-
- @Override
- Annotation buildSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, this.member, annotationName);
- }
-
+
@Override
- Annotation buildNullSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, annotationName);
- }
-
- public Annotation getNullMappingAnnotation(String annotationName) {
- return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName);
+ Iterator<String> validAnnotationNames() {
+ return this.getAnnotationProvider().attributeAnnotationNames();
}
-
- private Annotation buildNullMappingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, annotationName);
- }
-
+
@Override
- ListIterator<String> validMappingAnnotationNames() {
- return this.getAnnotationProvider().attributeMappingAnnotationNames();
+ Annotation buildAnnotation(String annotationName) {
+ return this.getAnnotationProvider().
+ buildAttributeAnnotation(this, this.member, annotationName);
}
-
+
@Override
- ListIterator<String> validSupportingAnnotationNames() {
- return this.getAnnotationProvider().attributeSupportingAnnotationNames();
+ Annotation buildNullAnnotation(String annotationName) {
+ return this.getAnnotationProvider().
+ buildNullAttributeAnnotation(this, annotationName);
}
-
+
public boolean isFor(MethodSignature signature, int occurrence) {
return ((MethodAttribute) this.member).matches(signature, occurrence);
}
-
-
+
+
// ******** JavaResourcePersistentAttribute implementation ********
-
+
public String getName() {
return this.member.getAttributeName();
}
-
+
+ public Annotation getNullAnnotation(String annotationName) {
+ return (annotationName == null) ? null : this.buildNullAnnotation(annotationName);
+ }
+
public boolean isField() {
return this.member.isField();
}
-
+
public boolean isProperty() {
return ! this.isField();
}
-
- public boolean hasAnyPersistenceAnnotations() {
- return (this.mappingAnnotationsSize() > 0)
- || (this.supportingAnnotationsSize() > 0);
- }
-
+
public AccessType getSpecifiedAccess() {
- Access2_0Annotation accessAnnotation = (Access2_0Annotation) this.getSupportingAnnotation(Access2_0Annotation.ANNOTATION_NAME);
+ Access2_0Annotation accessAnnotation =
+ (Access2_0Annotation) getAnnotation(Access2_0Annotation.ANNOTATION_NAME);
return (accessAnnotation == null) ? null : accessAnnotation.getValue();
}
-
+
public boolean typeIsSubTypeOf(String tn) {
if (this.typeName == null) {
return false;
@@ -221,15 +204,16 @@ final class SourcePersistentAttribute
|| this.typeInterfaceNames.contains(tn)
|| this.typeSuperclassNames.contains(tn);
}
-
+
public boolean typeIsVariablePrimitive() {
return (this.typeName != null) && ClassTools.classNamedIsVariablePrimitive(this.typeName);
}
-
+
private ITypeBinding getTypeBinding(CompilationUnit astRoot) {
return this.member.getTypeBinding(astRoot);
}
-
+
+
// ***** modifiers
public int getModifiers() {
return this.modifiers;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java
index d780239ebb..c4bee2e3ce 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java
@@ -9,15 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.resource.java.source;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.ListIterator;
import java.util.Set;
import java.util.Vector;
-
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.BodyDeclaration;
@@ -36,10 +32,9 @@ import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterables.SnapshotCloneIterable;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
/**
* Java source persistent member (annotations, "persistable")
@@ -49,38 +44,31 @@ abstract class SourcePersistentMember<E extends Member>
implements JavaResourcePersistentMember
{
final E member;
-
- /**
- * mapping annotations; no duplicates (java compiler has an error for
- * duplicates)
- */
- final Vector<Annotation> mappingAnnotations = new Vector<Annotation>();
-
+
/**
- * supporting annotations; no duplicates (java compiler has an error for
- * duplicates)
+ * annotations; no duplicates (java compiler has an error for duplicates)
*/
- final Vector<Annotation> supportingAnnotations = new Vector<Annotation>();
-
+ final Vector<Annotation> annotations = new Vector<Annotation>();
+
boolean persistable;
-
-
+
+
// ********** construction/initialization **********
-
+
SourcePersistentMember(JavaResourceNode parent, E member) {
super(parent);
this.member = member;
}
-
+
public void initialize(CompilationUnit astRoot) {
this.member.getBodyDeclaration(astRoot).accept(this.buildInitialAnnotationVisitor(astRoot));
this.persistable = this.buildPersistable(astRoot);
}
-
+
private ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot) {
return new InitialAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot));
}
-
+
/**
* called from InitialAnnotationVisitor
*/
@@ -89,207 +77,82 @@ abstract class SourcePersistentMember<E extends Member>
if (jdtAnnotationName == null) {
return;
}
- if (this.annotationIsValidSupportingAnnotation(jdtAnnotationName)) {
- if (this.selectAnnotationNamed(this.supportingAnnotations, jdtAnnotationName) == null) { // ignore duplicates
- Annotation annotation = this.buildSupportingAnnotation(jdtAnnotationName);
- annotation.initialize(astRoot);
- this.supportingAnnotations.add(annotation);
- }
- } else if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) {
- if (this.selectAnnotationNamed(this.mappingAnnotations, jdtAnnotationName) == null) { // ignore duplicates
- Annotation annotation = this.buildMappingAnnotation(jdtAnnotationName);
+ if (this.annotationIsValid(jdtAnnotationName)) {
+ if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates
+ Annotation annotation = this.buildAnnotation(jdtAnnotationName);
annotation.initialize(astRoot);
- this.mappingAnnotations.add(annotation);
+ this.annotations.add(annotation);
}
}
}
-
-
- // ********** mapping annotations **********
-
- public Iterator<Annotation> mappingAnnotations() {
- return this.getMappingAnnotations().iterator();
+
+
+ // ********** annotations **********
+
+ public Iterator<Annotation> annotations() {
+ return this.getAnnotations().iterator();
}
-
- private Iterable<Annotation> getMappingAnnotations() {
- return new LiveCloneIterable<Annotation>(this.mappingAnnotations);
+
+ private Iterable<Annotation> getAnnotations() {
+ return new LiveCloneIterable<Annotation>(this.annotations);
}
-
- public int mappingAnnotationsSize() {
- return this.mappingAnnotations.size();
+
+ public int annotationsSize() {
+ return this.annotations.size();
}
-
- // TODO need property change notification on this mappingAnnotation changing
- // from the context model we don't really care if their are multiple mapping
- // annotations, just which one we need to use
- public Annotation getMappingAnnotation() {
- Iterable<Annotation> annotations = new SnapshotCloneIterable<Annotation>(this.mappingAnnotations);
- for (ListIterator<String> stream = this.validMappingAnnotationNames(); stream.hasNext();) {
- Annotation annotation = this.selectAnnotationNamed(annotations, stream.next());
- if (annotation != null) {
- return annotation;
- }
- }
- return null;
+
+ public Annotation getAnnotation(String annotationName) {
+ return this.selectAnnotationNamed(this.getAnnotations(), annotationName);
}
-
- public Annotation getMappingAnnotation(String annotationName) {
- return this.selectAnnotationNamed(this.getMappingAnnotations(), annotationName);
+
+ public Annotation getNonNullAnnotation(String annotationName) {
+ Annotation annotation = this.getAnnotation(annotationName);
+ return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName);
}
-
- /**
- * Remove all other *mapping* annotations that exist; not just the one
- * returned by #getMappingAnnotation(). #getMappingAnnotation() returns the
- * first mapping annotation found in the source. If there were multiple
- * mapping annotations (which is a validation error) then calling this
- * method would not work because the new mapping annotation would be added
- * to the end of the list of annotations.
- */
- public Annotation setMappingAnnotation(String annotationName) {
- Collection<Annotation> removedAnnotations = null;
- Annotation newMapping = null;
- if (annotationName == null) {
- removedAnnotations = this.removeMappingAnnotations();
- } else {
- if (this.selectAnnotationNamed(this.mappingAnnotations, annotationName) != null) {
- throw new IllegalStateException("duplicate mapping annotation: " + annotationName); //$NON-NLS-1$
- }
- removedAnnotations = this.removeMappingAnnotations();
-
- newMapping = this.buildMappingAnnotation(annotationName);
- this.mappingAnnotations.add(newMapping);
- newMapping.newAnnotation();
- this.fireItemAdded(MAPPING_ANNOTATIONS_COLLECTION, newMapping);
+ public Iterator<NestableAnnotation> annotations(
+ String nestableAnnotationName, String containerAnnotationName) {
+ ContainerAnnotation<NestableAnnotation> containerAnnotation =
+ this.getContainerAnnotation(containerAnnotationName);
+ if (containerAnnotation != null) {
+ return containerAnnotation.nestedAnnotations();
}
- // hold change notifications until the end so a project update does not
- // occur before we are finished removing the old mapping(s) and/or adding
- // the new mapping
- this.fireItemsRemoved(MAPPING_ANNOTATIONS_COLLECTION, removedAnnotations);
- return newMapping;
- }
-
- /**
- * Remove all mapping annotations that already exist. No change notification
- * is fired. Return the removed annotations.
- */
- private Collection<Annotation> removeMappingAnnotations() {
- ArrayList<Annotation> removedAnnotations = null;
- for (String mappingAnnotationName : CollectionTools.iterable(this.validMappingAnnotationNames())) {
- Annotation mappingAnnotation = this.selectAnnotationNamed(this.mappingAnnotations, mappingAnnotationName);
- if (mappingAnnotation != null) {
- // only need to delete one, since we do not hold duplicates
- this.mappingAnnotations.remove(mappingAnnotation);
- mappingAnnotation.removeAnnotation();
- if (removedAnnotations == null) {
- removedAnnotations = new ArrayList<Annotation>();
- }
- removedAnnotations.add(mappingAnnotation);
- }
+ NestableAnnotation nestableAnnotation =
+ getNestableAnnotation(nestableAnnotationName);
+ if (nestableAnnotation != null) {
+ return new SingleElementIterator<NestableAnnotation>(nestableAnnotation);
}
- return (removedAnnotations != null) ? removedAnnotations : Collections.<Annotation>emptySet();
- }
-
- abstract Annotation buildMappingAnnotation(String mappingAnnotationName);
-
- private boolean annotationIsValidMappingAnnotation(String annotationName) {
- return CollectionTools.contains(this.validMappingAnnotationNames(), annotationName);
+ return EmptyIterator.instance();
}
-
- abstract ListIterator<String> validMappingAnnotationNames();
-
-
- // ********** supporting annotations **********
-
- public Iterator<Annotation> supportingAnnotations() {
- return this.getSupportingAnnotations().iterator();
- }
-
- private Iterable<Annotation> getSupportingAnnotations() {
- return new LiveCloneIterable<Annotation>(this.supportingAnnotations);
- }
-
- public int supportingAnnotationsSize() {
- return this.supportingAnnotations.size();
- }
-
- public Annotation getSupportingAnnotation(String annotationName) {
- return this.selectAnnotationNamed(this.getSupportingAnnotations(), annotationName);
+
+ // minimize scope of suppressed warnings
+ @SuppressWarnings("unchecked")
+ private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) {
+ return (ContainerAnnotation<NestableAnnotation>) getAnnotation(annotationName);
}
-
- public Annotation getNonNullSupportingAnnotation(String annotationName) {
- Annotation annotation = this.getSupportingAnnotation(annotationName);
- return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName);
+
+ private NestableAnnotation getNestableAnnotation(String annotationName) {
+ return (NestableAnnotation) this.getAnnotation(annotationName);
}
-
- abstract Annotation buildNullSupportingAnnotation(String annotationName);
-
- public Annotation addSupportingAnnotation(String annotationName) {
- Annotation annotation = this.buildSupportingAnnotation(annotationName);
- this.supportingAnnotations.add(annotation);
+
+ public Annotation addAnnotation(String annotationName) {
+ Annotation annotation = this.buildAnnotation(annotationName);
+ this.annotations.add(annotation);
annotation.newAnnotation();
- this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, annotation);
+ this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation);
return annotation;
}
-
- public Annotation addSupportingAnnotation(String annotationName, AnnotationInitializer annotationInitializer) {
- Annotation annotation = this.buildSupportingAnnotation(annotationName);
- this.supportingAnnotations.add(annotation);
+
+ public Annotation addAnnotation(String annotationName, AnnotationInitializer annotationInitializer) {
+ Annotation annotation = this.buildAnnotation(annotationName);
+ this.annotations.add(annotation);
annotation.newAnnotation();
Annotation nestedAnnotation = annotationInitializer.initializeAnnotation(annotation);
nestedAnnotation.newAnnotation();
- this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, annotation);
+ this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation);
return nestedAnnotation;
}
-
- abstract Annotation buildSupportingAnnotation(String annotationName);
-
- public void removeSupportingAnnotation(String annotationName) {
- Annotation annotation = this.getSupportingAnnotation(annotationName);
- if (annotation != null) {
- this.removeSupportingAnnotation(annotation);
- }
- }
-
- private void removeSupportingAnnotation(Annotation annotation) {
- this.supportingAnnotations.remove(annotation);
- annotation.removeAnnotation();
- this.fireItemRemoved(SUPPORTING_ANNOTATIONS_COLLECTION, annotation);
- }
-
- private boolean annotationIsValidSupportingAnnotation(String annotationName) {
- return CollectionTools.contains(this.validSupportingAnnotationNames(), annotationName);
- }
-
- abstract ListIterator<String> validSupportingAnnotationNames();
-
-
- // ********** supporting "combo" annotations **********
-
- public ListIterator<NestableAnnotation> supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) {
- ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName);
- if (containerAnnotation != null) {
- return containerAnnotation.nestedAnnotations();
- }
-
- NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName);
- if (nestableAnnotation != null) {
- return new SingleElementListIterator<NestableAnnotation>(nestableAnnotation);
- }
-
- return EmptyListIterator.instance();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private ContainerAnnotation<NestableAnnotation> getSupportingContainerAnnotation(String annotationName) {
- return (ContainerAnnotation<NestableAnnotation>) this.getSupportingAnnotation(annotationName);
- }
-
- private NestableAnnotation getSupportingNestableAnnotation(String annotationName) {
- return (NestableAnnotation) this.getSupportingAnnotation(annotationName);
- }
-
+
/**
* 1. check for a container annotation;
* if it is present, add a nested annotation to it
@@ -299,19 +162,20 @@ abstract class SourcePersistentMember<E extends Member>
* add a container annotation and move the stand-alone nested annotation to it
* and add a new nested annotation to it also
*/
- public NestableAnnotation addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
- ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName);
+ public NestableAnnotation addAnnotation(
+ int index, String nestableAnnotationName, String containerAnnotationName) {
+ ContainerAnnotation<NestableAnnotation> containerAnnotation =
+ getContainerAnnotation(containerAnnotationName);
if (containerAnnotation != null) {
// ignore any stand-alone nestable annotations and just add to the container annotation
return AnnotationContainerTools.addNestedAnnotation(index, containerAnnotation);
}
-
- NestableAnnotation standAloneAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName);
+ NestableAnnotation standAloneAnnotation =
+ getNestableAnnotation(nestableAnnotationName);
if (standAloneAnnotation == null) {
// add a stand-alone nestable annotation since neither the nestable nor the container exist
- return (NestableAnnotation) this.addSupportingAnnotation(nestableAnnotationName);
+ return (NestableAnnotation) this.addAnnotation(nestableAnnotationName);
}
-
// move the stand-alone nestable annotation to a container and add another nestable
return this.addSecondNestedAnnotation(index, containerAnnotationName, standAloneAnnotation);
}
@@ -325,21 +189,20 @@ abstract class SourcePersistentMember<E extends Member>
* place when the context model gets an "update" and looks at the resource
* model to determine what has changed
*/
- private NestableAnnotation addSecondNestedAnnotation(int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) {
- ContainerAnnotation<NestableAnnotation> containerAnnotation = this.buildSupportingContainerAnnotation(containerAnnotationName);
- this.supportingAnnotations.add(containerAnnotation);
+ private NestableAnnotation addSecondNestedAnnotation(
+ int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) {
+ ContainerAnnotation<NestableAnnotation> containerAnnotation =
+ buildContainerAnnotation(containerAnnotationName);
+ this.annotations.add(containerAnnotation);
containerAnnotation.newAnnotation();
-
+
NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotationInternal();
nestedAnnotation0.newAnnotation();
-
NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotationInternal();
nestedAnnotation1.newAnnotation();
-
- this.removeSupportingAnnotation(standAloneAnnotation);
-
- this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, containerAnnotation);
-
+ this.removeAnnotation(standAloneAnnotation);
+ this.fireItemAdded(ANNOTATIONS_COLLECTION, containerAnnotation);
+
if (index == 0) {
// adding new annotation at 0, so stand-alone is "copied" to slot 1
nestedAnnotation1.initializeFrom(standAloneAnnotation);
@@ -347,43 +210,57 @@ abstract class SourcePersistentMember<E extends Member>
// adding new annotation at 1, so stand-alone is "copied" to slot 0
nestedAnnotation0.initializeFrom(standAloneAnnotation);
}
-
+
return (index == 0) ? nestedAnnotation0 : nestedAnnotation1;
}
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private ContainerAnnotation<NestableAnnotation> buildSupportingContainerAnnotation(String annotationName) {
- return (ContainerAnnotation<NestableAnnotation>) this.buildSupportingAnnotation(annotationName);
- }
-
- public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) {
- this.moveAnnotation(targetIndex, sourceIndex, this.getSupportingContainerAnnotation(containerAnnotationName));
+
+ public void moveAnnotation(
+ int targetIndex, int sourceIndex, String containerAnnotationName) {
+ moveAnnotation(targetIndex, sourceIndex, getContainerAnnotation(containerAnnotationName));
}
-
- private void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation<NestableAnnotation> containerAnnotation) {
+
+ private void moveAnnotation(
+ int targetIndex, int sourceIndex,
+ ContainerAnnotation<NestableAnnotation> containerAnnotation) {
AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation);
}
- public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
- ContainerAnnotation<NestableAnnotation> containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName);
+ public void removeAnnotation(String annotationName) {
+ Annotation annotation = getAnnotation(annotationName);
+ if (annotation != null) {
+ this.removeAnnotation(annotation);
+ }
+ }
+
+ private void removeAnnotation(Annotation annotation) {
+ this.annotations.remove(annotation);
+ annotation.removeAnnotation();
+ this.fireItemRemoved(ANNOTATIONS_COLLECTION, annotation);
+ }
+
+ public void removeAnnotation(
+ int index, String nestableAnnotationName, String containerAnnotationName) {
+ ContainerAnnotation<NestableAnnotation> containerAnnotation =
+ getContainerAnnotation(containerAnnotationName);
if (containerAnnotation == null) { // assume the index is 0
- this.removeSupportingAnnotation(this.getSupportingAnnotation(nestableAnnotationName));
- } else {
- this.removeSupportingAnnotation(index, containerAnnotation);
+ removeAnnotation(getAnnotation(nestableAnnotationName));
+ }
+ else {
+ removeAnnotation(index, containerAnnotation);
}
}
-
+
/**
* after we remove the nested annotation, check to see whether we need to
* either remove the container (if it is empty) or convert the last nested
* annotation to a stand-alone annotation
*/
- private void removeSupportingAnnotation(int index, ContainerAnnotation<NestableAnnotation> containerAnnotation) {
+ private void removeAnnotation(
+ int index, ContainerAnnotation<NestableAnnotation> containerAnnotation) {
AnnotationContainerTools.removeNestedAnnotation(index, containerAnnotation);
switch (containerAnnotation.nestedAnnotationsSize()) {
case 0:
- this.removeSupportingAnnotation(containerAnnotation);
+ this.removeAnnotation(containerAnnotation);
break;
case 1:
this.convertLastNestedAnnotation(containerAnnotation);
@@ -402,128 +279,163 @@ abstract class SourcePersistentMember<E extends Member>
* place when the context model gets an "update" and looks at the resource
* model to determine what has changed
*/
- private void convertLastNestedAnnotation(ContainerAnnotation<NestableAnnotation> containerAnnotation) {
+ private void convertLastNestedAnnotation(
+ ContainerAnnotation<NestableAnnotation> containerAnnotation) {
NestableAnnotation lastNestedAnnotation = containerAnnotation.nestedAnnotations().next();
- this.supportingAnnotations.remove(containerAnnotation);
+ annotations.remove(containerAnnotation);
containerAnnotation.removeAnnotation();
-
- NestableAnnotation standAloneAnnotation = (NestableAnnotation) this.buildSupportingAnnotation(lastNestedAnnotation.getAnnotationName());
- this.supportingAnnotations.add(standAloneAnnotation);
+
+ NestableAnnotation standAloneAnnotation =
+ buildNestableAnnotation(lastNestedAnnotation.getAnnotationName());
+ this.annotations.add(standAloneAnnotation);
standAloneAnnotation.newAnnotation();
- this.fireItemRemoved(SUPPORTING_ANNOTATIONS_COLLECTION, containerAnnotation);
- this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, standAloneAnnotation);
+ this.fireItemRemoved(ANNOTATIONS_COLLECTION, containerAnnotation);
+ this.fireItemAdded(ANNOTATIONS_COLLECTION, standAloneAnnotation);
standAloneAnnotation.initializeFrom(lastNestedAnnotation);
}
-
-
+
+ public Annotation setPrimaryAnnotation(
+ String primaryAnnotationName, String[] supportingAnnotationNames) {
+ Annotation newPrimaryAnnotation = null;
+ String[] annotationNamesToKeep = supportingAnnotationNames;
+ if (primaryAnnotationName != null) {
+ annotationNamesToKeep = CollectionTools.add(supportingAnnotationNames, primaryAnnotationName);
+ }
+ for (Annotation existingAnnotation : getAnnotations()) {
+ if (! CollectionTools.contains(annotationNamesToKeep, existingAnnotation.getAnnotationName())) {
+ this.annotations.remove(existingAnnotation);
+ existingAnnotation.removeAnnotation();
+ }
+ }
+ if (primaryAnnotationName != null && getAnnotation(primaryAnnotationName) == null) {
+ newPrimaryAnnotation = buildAnnotation(primaryAnnotationName);
+ this.annotations.add(newPrimaryAnnotation);
+ newPrimaryAnnotation.newAnnotation();
+ }
+ // fire collection change event after all annotation changes are done
+ fireCollectionChanged(ANNOTATIONS_COLLECTION, Collections.unmodifiableCollection(this.annotations));
+ return newPrimaryAnnotation;
+ }
+
+ private boolean annotationIsValid(String annotationName) {
+ return CollectionTools.contains(this.validAnnotationNames(), annotationName);
+ }
+
+ abstract Iterator<String> validAnnotationNames();
+
+ abstract Annotation buildAnnotation(String mappingAnnotationName);
+
+ abstract Annotation buildNullAnnotation(String annotationName);
+
+ // minimize scope of suppressed warnings
+ @SuppressWarnings("unchecked")
+ private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) {
+ return (ContainerAnnotation<NestableAnnotation>) buildAnnotation(annotationName);
+ }
+
+ @SuppressWarnings("unchecked")
+ private NestableAnnotation buildNestableAnnotation(String annotationName) {
+ return (NestableAnnotation) buildAnnotation(annotationName);
+ }
+
+
// ********** simple state **********
-
+
public boolean isPersistable() {
return this.persistable;
}
-
+
private void setPersistable(boolean persistable) {
boolean old = this.persistable;
this.persistable = persistable;
this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable);
}
-
+
private boolean buildPersistable(CompilationUnit astRoot) {
return this.member.isPersistable(astRoot);
}
-
- public boolean isPersisted() {
- return this.getMappingAnnotation() != null;
+
+ public boolean isAnnotated() {
+ return ! this.annotations.isEmpty();
}
-
+
public boolean isFor(String memberName, int occurrence) {
return this.member.matches(memberName, occurrence);
}
-
+
public TextRange getTextRange(CompilationUnit astRoot) {
return this.fullTextRange(astRoot);
}
-
+
private TextRange fullTextRange(CompilationUnit astRoot) {
return this.buildTextRange(this.member.getBodyDeclaration(astRoot));
}
-
+
public TextRange getNameTextRange(CompilationUnit astRoot) {
return this.member.getNameTextRange(astRoot);
}
-
-
+
+
// ********** update **********
-
+
public void update(CompilationUnit astRoot) {
this.updateAnnotations(astRoot);
this.setPersistable(this.buildPersistable(astRoot));
}
-
+
private void updateAnnotations(CompilationUnit astRoot) {
- HashSet<Annotation> mappingAnnotationsToRemove = new HashSet<Annotation>(this.mappingAnnotations);
- HashSet<Annotation> supportingAnnotationsToRemove = new HashSet<Annotation>(this.supportingAnnotations);
-
- this.member.getBodyDeclaration(astRoot).accept(this.buildUpdateAnnotationVisitor(astRoot, mappingAnnotationsToRemove, supportingAnnotationsToRemove));
-
- for (Annotation annotation : mappingAnnotationsToRemove) {
- this.removeItemFromCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION);
- }
- for (Annotation annotation : supportingAnnotationsToRemove) {
- this.removeItemFromCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION);
+ HashSet<Annotation> annotationsToRemove =
+ new HashSet<Annotation>(this.annotations);
+
+ this.member.getBodyDeclaration(astRoot).accept(
+ this.buildUpdateAnnotationVisitor(astRoot, annotationsToRemove));
+
+ for (Annotation annotation : annotationsToRemove) {
+ this.removeItemFromCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION);
}
}
-
- private ASTVisitor buildUpdateAnnotationVisitor(CompilationUnit astRoot, Set<Annotation> mappingAnnotationsToRemove, Set<Annotation> supportingAnnotationsToRemove) {
- return new UpdateAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot), mappingAnnotationsToRemove, supportingAnnotationsToRemove);
+
+ private ASTVisitor buildUpdateAnnotationVisitor(
+ CompilationUnit astRoot, Set<Annotation> annotationsToRemove) {
+ return new UpdateAnnotationVisitor(
+ astRoot, this.member.getBodyDeclaration(astRoot), annotationsToRemove);
}
-
- void addOrUpdateAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set<Annotation> mappingAnnotationsToRemove, Set<Annotation> supportingAnnotationsToRemove) {
+
+ void addOrUpdateAnnotation(
+ org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot,
+ Set<Annotation> annotationsToRemove) {
String jdtAnnotationName = JDTTools.resolveAnnotation(node);
if (jdtAnnotationName == null) {
return;
}
- if (this.annotationIsValidSupportingAnnotation(jdtAnnotationName)) {
- this.addOrUpdateSupportingAnnotation(jdtAnnotationName, astRoot, supportingAnnotationsToRemove);
- return;
- }
- if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) {
- this.addOrUpdateMappingAnnotation(jdtAnnotationName, astRoot, mappingAnnotationsToRemove);
+ if (this.annotationIsValid(jdtAnnotationName)) {
+ this.addOrUpdateAnnotation(jdtAnnotationName, astRoot, annotationsToRemove);
return;
}
}
-
- private void addOrUpdateSupportingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> supportingAnnotationsToRemove) {
- Annotation annotation = this.selectAnnotationNamed(supportingAnnotationsToRemove, jdtAnnotationName);
+
+ private void addOrUpdateAnnotation(
+ String jdtAnnotationName, CompilationUnit astRoot,
+ Set<Annotation> annotationsToRemove) {
+ Annotation annotation = this.selectAnnotationNamed(annotationsToRemove, jdtAnnotationName);
if (annotation != null) {
annotation.update(astRoot);
- supportingAnnotationsToRemove.remove(annotation);
- } else {
- annotation = this.buildSupportingAnnotation(jdtAnnotationName);
- annotation.initialize(astRoot);
- this.addItemToCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION);
+ annotationsToRemove.remove(annotation);
}
- }
-
- private void addOrUpdateMappingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> mappingAnnotationsToRemove) {
- Annotation annotation = this.selectAnnotationNamed(mappingAnnotationsToRemove, jdtAnnotationName);
- if (annotation != null) {
- annotation.update(astRoot);
- mappingAnnotationsToRemove.remove(annotation);
- } else {
- annotation = this.buildMappingAnnotation(jdtAnnotationName);
+ else {
+ annotation = this.buildAnnotation(jdtAnnotationName);
annotation.initialize(astRoot);
- this.addItemToCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION);
+ this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION);
}
}
-
-
+
+
// ********** miscellaneous **********
-
+
public void resolveTypes(CompilationUnit astRoot) {
this.setPersistable(this.buildPersistable(astRoot));
}
-
+
private Annotation selectAnnotationNamed(Iterable<Annotation> annotations, String annotationName) {
for (Annotation annotation : annotations) {
if (annotation.getAnnotationName().equals(annotationName)) {
@@ -532,11 +444,11 @@ abstract class SourcePersistentMember<E extends Member>
}
return null;
}
-
+
private TextRange buildTextRange(ASTNode astNode) {
return (astNode == null) ? null : new ASTNodeTextRange(astNode);
}
-
+
/**
* convenience method
*/
@@ -548,38 +460,40 @@ abstract class SourcePersistentMember<E extends Member>
}
};
}
-
-
+
+
// ********** AST visitors **********
-
+
/**
* annotation visitor
*/
- protected static abstract class AnnotationVisitor extends ASTVisitor {
+ protected static abstract class AnnotationVisitor
+ extends ASTVisitor
+ {
protected final CompilationUnit astRoot;
protected final BodyDeclaration bodyDeclaration;
-
+
protected AnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) {
super();
this.astRoot = astRoot;
this.bodyDeclaration = bodyDeclaration;
}
-
+
@Override
public boolean visit(SingleMemberAnnotation node) {
return visit_(node);
}
-
+
@Override
public boolean visit(NormalAnnotation node) {
return visit_(node);
}
-
+
@Override
public boolean visit(MarkerAnnotation node) {
return visit_(node);
}
-
+
protected boolean visit_(org.eclipse.jdt.core.dom.Annotation node) {
// ignore annotations for child members, only this member
if (node.getParent() == this.bodyDeclaration) {
@@ -587,45 +501,47 @@ abstract class SourcePersistentMember<E extends Member>
}
return false;
}
-
+
protected abstract void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node);
-
}
-
+
+
/**
* initial annotation visitor
*/
- protected class InitialAnnotationVisitor extends AnnotationVisitor {
-
+ protected class InitialAnnotationVisitor
+ extends AnnotationVisitor
+ {
protected InitialAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) {
super(astRoot, bodyDeclaration);
}
-
+
@Override
protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) {
SourcePersistentMember.this.addInitialAnnotation(node, this.astRoot);
}
-
}
-
+
+
/**
* update annotation visitor
*/
- protected class UpdateAnnotationVisitor extends AnnotationVisitor {
- protected final Set<Annotation> mappingAnnotationsToRemove;
- protected final Set<Annotation> supportingAnnotationsToRemove;
-
- protected UpdateAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration, Set<Annotation> mappingAnnotationsToRemove, Set<Annotation> supportingAnnotationsToRemove) {
+ protected class UpdateAnnotationVisitor
+ extends AnnotationVisitor
+ {
+ protected final Set<Annotation> annotationsToRemove;
+
+ protected UpdateAnnotationVisitor(
+ CompilationUnit astRoot, BodyDeclaration bodyDeclaration,
+ Set<Annotation> annotationsToRemove) {
super(astRoot, bodyDeclaration);
- this.mappingAnnotationsToRemove = mappingAnnotationsToRemove;
- this.supportingAnnotationsToRemove = supportingAnnotationsToRemove;
+ this.annotationsToRemove = annotationsToRemove;
}
-
+
@Override
protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) {
- SourcePersistentMember.this.addOrUpdateAnnotation(node, this.astRoot, this.mappingAnnotationsToRemove, this.supportingAnnotationsToRemove);
- }
-
+ SourcePersistentMember.this.addOrUpdateAnnotation(
+ node, this.astRoot, this.annotationsToRemove);
+ }
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
index 0daad1e8c2..7273060c85 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
@@ -14,9 +14,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Vector;
-
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.ITypeBinding;
@@ -36,7 +34,6 @@ import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.utility.MethodSignature;
import org.eclipse.jpt.utility.internal.Counter;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.TreeIterator;
@@ -160,48 +157,40 @@ final class SourcePersistentType
// ********** AbstractJavaResourcePersistentMember implementation **********
-
- @Override
- Annotation buildMappingAnnotation(String mappingAnnotationName) {
- return this.getAnnotationProvider().buildTypeMappingAnnotation(this, this.member, mappingAnnotationName);
- }
@Override
- Annotation buildSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, this.member, annotationName);
+ Iterator<String> validAnnotationNames() {
+ return this.getAnnotationProvider().typeAnnotationNames();
}
@Override
- Annotation buildNullSupportingAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, annotationName);
+ Annotation buildAnnotation(String mappingAnnotationName) {
+ return this.getAnnotationProvider().
+ buildTypeAnnotation(this, this.member, mappingAnnotationName);
}
@Override
- ListIterator<String> validMappingAnnotationNames() {
- return this.getAnnotationProvider().typeMappingAnnotationNames();
- }
-
- @Override
- ListIterator<String> validSupportingAnnotationNames() {
- return this.getAnnotationProvider().typeSupportingAnnotationNames();
+ Annotation buildNullAnnotation(String annotationName) {
+ return this.getAnnotationProvider().
+ buildNullTypeAnnotation(this, annotationName);
}
@Override
public void resolveTypes(CompilationUnit astRoot) {
super.resolveTypes(astRoot);
-
+
this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot));
-
+
for (JavaResourcePersistentAttribute field : this.getFields()) {
field.resolveTypes(astRoot);
}
-
+
// a new type can trigger a method parameter type to be a resolved,
// fully-qualified name, so we need to rebuild our list of methods:
// "setFoo(Foo)" is not the same as "setFoo(com.bar.Foo)"
// and, vice-versa, a removed type can "unresolve" a parameter type
this.updateMethods(astRoot);
-
+
for (JavaResourcePersistentAttribute method : this.getMethods()) {
method.resolveTypes(astRoot);
}
@@ -209,13 +198,13 @@ final class SourcePersistentType
type.resolveTypes(astRoot);
}
}
-
+
@Override
public void toString(StringBuilder sb) {
sb.append(this.name);
}
-
-
+
+
// ******** JavaResourcePersistentType implementation ********
// ***** name
@@ -311,9 +300,10 @@ final class SourcePersistentType
/**
* check only persistable attributes
*/
- public boolean hasAnyAttributePersistenceAnnotations() {
- for (Iterator<JavaResourcePersistentAttribute> stream = this.persistableAttributes(); stream.hasNext(); ) {
- if (stream.next().hasAnyPersistenceAnnotations()) {
+ public boolean hasAnyAnnotatedAttributes() {
+ for (Iterator<JavaResourcePersistentAttribute> stream =
+ this.persistableAttributes(); stream.hasNext(); ) {
+ if (stream.next().isAnnotated()) {
return true;
}
}

Back to the top