synchronized hashCode, compareTo and equals implementations

This commit is contained in:
Timo Westkämper 2008-03-06 21:55:49 +00:00
parent 76af7c7bdf
commit 39129cc070
2 changed files with 32 additions and 11 deletions

View File

@ -76,19 +76,21 @@ public class TypeDecl implements Comparable<TypeDecl>{
public int compareTo(TypeDecl o) {
return simpleName.compareTo(o.simpleName);
}
public boolean equals(Object o){
return o instanceof TypeDecl && simpleName.equals(((TypeDecl)o).simpleName);
}
public Collection<FieldDecl> getBooleanFields() {
return booleanFields;
}
public Collection<FieldDecl> getCollectionFields() {
return collectionFields;
}
public Collection<ConstructorDecl> getConstructors(){
return constructors;
}
public Collection<FieldDecl> getEntityFields() {
return entityFields;
}
@ -96,7 +98,7 @@ public class TypeDecl implements Comparable<TypeDecl>{
public String getName() {
return name;
}
public Collection<FieldDecl> getSimpleFields() {
return simpleFields;
}
@ -104,15 +106,19 @@ public class TypeDecl implements Comparable<TypeDecl>{
public String getSimpleName() {
return simpleName;
}
public Collection<FieldDecl> getStringFields() {
return stringFields;
}
public String getSupertypeName(){
return superType;
}
public int hashCode(){
return name.hashCode();
}
public void include(TypeDecl decl) {
booleanFields.addAll(decl.booleanFields);
collectionFields.addAll(decl.collectionFields);
@ -164,7 +170,9 @@ public class TypeDecl implements Comparable<TypeDecl>{
public int compareTo(FieldDecl o) {
return name.compareTo(o.name);
}
public boolean equals(Object o){
return o instanceof FieldDecl && name.equals(((FieldDecl)o).name);
}
private FieldType forType(String cl){
if (cl.equals(Boolean.class.getName())) return FieldType.BOOLEAN;
else if (cl.equals(String.class.getName())) return FieldType.STRING;
@ -183,10 +191,14 @@ public class TypeDecl implements Comparable<TypeDecl>{
public String getSimpleTypeName(){
return simpleTypeName;
}
public String getTypeName(){
return typeName;
}
public int hashCode(){
return name.hashCode();
}
}
@ -209,13 +221,20 @@ public class TypeDecl implements Comparable<TypeDecl>{
public int compareTo(ParameterDecl o) {
return name.compareTo(o.name);
}
public boolean equals(Object o){
return o instanceof ParameterDecl && name.equals(((ParameterDecl)o).name);
}
public String getName(){
return name;
}
public String getTypeName(){
return typeName;
}
public int hashCode(){
return name.hashCode();
}
}

View File

@ -139,7 +139,9 @@ public class HibernateProcessor implements AnnotationProcessor {
// serialize it
String path = destClass.replace('.', '/') + ".java";
File file = new File(targetFolder, path);
file.getParentFile().mkdirs();
if (!file.getParentFile().mkdirs()){
System.err.println("Folder " + file.getParent() + " could not be created");
}
try {
Writer out = new OutputStreamWriter(new FileOutputStream(file));
new FreeMarkerSerializer("/querydsl-hibernate.ftl").serialize(