METAGEN-28 Unrelated coding style fixes

This commit is contained in:
Hardy Ferentschik 2010-10-07 12:22:12 +00:00 committed by Strong Liu
parent 31a5497650
commit 3e0ecf66c0
9 changed files with 43 additions and 31 deletions

View File

@ -46,7 +46,7 @@ public class AnnotationEmbeddable extends AnnotationMetaEntity {
public List<MetaAttribute> getMembers() {
if ( !initialized ) {
context.logMessage( Diagnostic.Kind.OTHER, "Entity " + getQualifiedName() + " was lazily initialised." );
getContext().logMessage( Diagnostic.Kind.OTHER, "Entity " + getQualifiedName() + " was lazily initialised." );
init();
initialized = true;
}
@ -57,10 +57,10 @@ public class AnnotationEmbeddable extends AnnotationMetaEntity {
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "AnnotationEmbeddable" );
sb.append( "{element=" ).append( element );
sb.append( "{element=" ).append( getElement() );
sb.append( ", members=" );
if ( initialized ) {
sb.append( members );
sb.append( getMembers() );
}
else {
sb.append( "[un-initalized]" );

View File

@ -79,7 +79,7 @@ public abstract class AnnotationMetaAttribute implements MetaAttribute {
}
}
public MetaEntity getParent() {
public MetaEntity getHostingEntity() {
return parent;
}

View File

@ -50,10 +50,10 @@ import org.hibernate.jpamodelgen.util.TypeUtils;
*/
public class AnnotationMetaEntity implements MetaEntity {
protected final ImportContext importContext;
protected final TypeElement element;
protected final Map<String, MetaAttribute> members;
protected Context context;
private final ImportContext importContext;
private final TypeElement element;
private final Map<String, MetaAttribute> members;
private Context context;
private AccessTypeInformation entityAccessTypeInfo;
@ -75,19 +75,19 @@ public class AnnotationMetaEntity implements MetaEntity {
return entityAccessTypeInfo;
}
public Context getContext() {
public final Context getContext() {
return context;
}
public String getSimpleName() {
public final String getSimpleName() {
return element.getSimpleName().toString();
}
public String getQualifiedName() {
public final String getQualifiedName() {
return element.getQualifiedName().toString();
}
public String getPackageName() {
public final String getPackageName() {
PackageElement packageOf = context.getElementUtils().getPackageOf( element );
return context.getElementUtils().getName( packageOf.getQualifiedName() ).toString();
}
@ -117,6 +117,10 @@ public class AnnotationMetaEntity implements MetaEntity {
return sb.toString();
}
protected TypeElement getElement() {
return element;
}
private void addPersistentMembers(List<? extends Element> membersOfClass, AccessType membersKind) {
for ( Element memberOfClass : membersOfClass ) {
AccessType forcedAccessType = TypeUtils.determineAnnotationSpecifiedAccessType( memberOfClass );

View File

@ -37,7 +37,7 @@ public class AnnotationMetaMap extends AnnotationMetaCollection {
}
public String getDeclarationString() {
return "public static volatile " + getParent().importType( getMetaType() ) + "<" + getParent().importType( getParent().getQualifiedName() ) + ", " + getParent()
.importType( keyType ) + ", " + getParent().importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";";
return "public static volatile " + getHostingEntity().importType( getMetaType() ) + "<" + getHostingEntity().importType( getHostingEntity().getQualifiedName() ) + ", " + getHostingEntity()
.importType( keyType ) + ", " + getHostingEntity().importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";";
}
}

View File

@ -31,5 +31,5 @@ public interface MetaAttribute {
String getTypeDeclaration();
MetaEntity getParent();
MetaEntity getHostingEntity();
}

View File

@ -28,8 +28,7 @@ import java.util.Map;
*/
public class FileTimeStampChecker implements Serializable {
Map<String, Long> lastModifiedCache;
private Map<String, Long> lastModifiedCache;
public FileTimeStampChecker() {
lastModifiedCache = new HashMap<String, Long>();

View File

@ -28,21 +28,21 @@ import org.hibernate.jpamodelgen.model.MetaEntity;
*/
public abstract class XmlMetaAttribute implements MetaAttribute {
protected final XmlMetaEntity parentEntity;
private final XmlMetaEntity hostingEntity;
private final String propertyName;
private final String type;
XmlMetaAttribute(XmlMetaEntity parent, String propertyName, String type) {
this.parentEntity = parent;
this.hostingEntity = parent;
this.propertyName = propertyName;
this.type = type;
}
@Override
public String getDeclarationString() {
return "public static volatile " + parentEntity.importType( getMetaType() )
+ "<" + parentEntity.importType( parentEntity.getQualifiedName() )
+ ", " + parentEntity.importType( getTypeDeclaration() )
return "public static volatile " + hostingEntity.importType( getMetaType() )
+ "<" + hostingEntity.importType( hostingEntity.getQualifiedName() )
+ ", " + hostingEntity.importType( getTypeDeclaration() )
+ "> " + getPropertyName() + ";";
}
@ -54,8 +54,8 @@ public abstract class XmlMetaAttribute implements MetaAttribute {
return type;
}
public MetaEntity getParent() {
return parentEntity;
public MetaEntity getHostingEntity() {
return hostingEntity;
}
@Override

View File

@ -26,7 +26,7 @@ import org.hibernate.jpamodelgen.model.MetaCollection;
*/
public class XmlMetaCollection extends XmlMetaAttribute implements MetaCollection {
String collectionType;
private String collectionType;
public XmlMetaCollection(XmlMetaEntity parent, String propertyName, String type, String collectionType) {
super(parent, propertyName, type);

View File

@ -19,6 +19,8 @@
package org.hibernate.jpamodelgen.xml;
import org.hibernate.jpamodelgen.model.MetaEntity;
/**
* @author Hardy Ferentschik
*/
@ -32,11 +34,18 @@ public class XmlMetaMap extends XmlMetaCollection {
}
public String getDeclarationString() {
return "public static volatile "
+ parentEntity.importType( getMetaType() )
+ "<" + parentEntity.importType( parentEntity.getQualifiedName() )
+ ", " + parentEntity.importType( keyType ) + ", "
+ parentEntity.importType( getTypeDeclaration() )
+ "> " + getPropertyName() + ";";
final MetaEntity hostingEntity = getHostingEntity();
return new StringBuilder().append( "public static volatile " )
.append( hostingEntity.importType( getMetaType() ) )
.append( "<" )
.append( hostingEntity.importType( hostingEntity.getQualifiedName() ) )
.append( ", " )
.append( hostingEntity.importType( keyType ) )
.append( ", " )
.append( hostingEntity.importType( getTypeDeclaration() ) )
.append( "> " )
.append( getPropertyName() )
.append( ";" )
.toString();
}
}