Author: hardy.ferentschik
Date: 2010-09-27 13:31:42 -0400 (Mon, 27 Sep 2010)
New Revision: 20725
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/model/MetaAttribute.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
Log:
METAGEN-30 Added getParent() to MetaEntity to improve encapsulation
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java 2010-09-27
17:30:20 UTC (rev 20724)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaAttribute.java 2010-09-27
17:31:42 UTC (rev 20725)
@@ -25,16 +25,19 @@
import javax.lang.model.util.Elements;
import org.hibernate.jpamodelgen.model.MetaAttribute;
+import org.hibernate.jpamodelgen.model.MetaEntity;
/**
+ * Captures all information about an annotated persistent attribute.
+ *
* @author Max Andersen
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
public abstract class AnnotationMetaAttribute implements MetaAttribute {
- final protected Element element;
- final protected AnnotationMetaEntity parent;
+ private final Element element;
+ private final AnnotationMetaEntity parent;
private final String type;
public AnnotationMetaAttribute(AnnotationMetaEntity parent, Element element, String
type) {
@@ -44,8 +47,16 @@
}
public String getDeclarationString() {
- return "public static volatile " + parent.importType( getMetaType() ) +
"<" + parent.importType( parent.getQualifiedName() ) + ", " +
parent
- .importType( getTypeDeclaration() ) + "> " + getPropertyName() +
";";
+ return new StringBuilder().append( "public static volatile " )
+ .append( parent.importType( getMetaType() ) )
+ .append( "<" )
+ .append( parent.importType( parent.getQualifiedName() ) )
+ .append( ", " )
+ .append( parent.importType( getTypeDeclaration() ) )
+ .append( "> " )
+ .append( getPropertyName() )
+ .append( ";" )
+ .toString();
}
public String getPropertyName() {
@@ -68,6 +79,10 @@
}
}
+ public MetaEntity getParent() {
+ return parent;
+ }
+
abstract public String getMetaType();
public String getTypeDeclaration() {
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java 2010-09-27
17:30:20 UTC (rev 20724)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaMap.java 2010-09-27
17:31:42 UTC (rev 20725)
@@ -37,7 +37,7 @@
}
public String getDeclarationString() {
- return "public static volatile " + parent.importType( getMetaType() ) +
"<" + parent.importType( parent.getQualifiedName() ) + ", " +
parent
- .importType( keyType ) + ", " + parent.importType( getTypeDeclaration() ) +
"> " + getPropertyName() + ";";
+ return "public static volatile " + getParent().importType( getMetaType() ) +
"<" + getParent().importType( getParent().getQualifiedName() ) + ",
" + getParent()
+ .importType( keyType ) + ", " + getParent().importType(
getTypeDeclaration() ) + "> " + getPropertyName() + ";";
}
}
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java 2010-09-27
17:30:20 UTC (rev 20724)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaSingleAttribute.java 2010-09-27
17:31:42 UTC (rev 20725)
@@ -35,7 +35,7 @@
}
@Override
- public String getMetaType() {
+ public final String getMetaType() {
return "javax.persistence.metamodel.SingularAttribute";
}
}
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/model/MetaAttribute.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/model/MetaAttribute.java 2010-09-27
17:30:20 UTC (rev 20724)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/model/MetaAttribute.java 2010-09-27
17:31:42 UTC (rev 20725)
@@ -30,4 +30,6 @@
String getPropertyName();
String getTypeDeclaration();
+
+ MetaEntity getParent();
}
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java
===================================================================
---
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java 2010-09-27
17:30:20 UTC (rev 20724)
+++
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/xml/XmlMetaAttribute.java 2010-09-27
17:31:42 UTC (rev 20725)
@@ -21,6 +21,7 @@
package org.hibernate.jpamodelgen.xml;
import org.hibernate.jpamodelgen.model.MetaAttribute;
+import org.hibernate.jpamodelgen.model.MetaEntity;
/**
* @author Hardy Ferentschik
@@ -53,6 +54,10 @@
return type;
}
+ public MetaEntity getParent() {
+ return parentEntity;
+ }
+
@Override
abstract public String getMetaType();
Show replies by date