mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
improved annotation serialization
updated codegen version to 0.1.7
This commit is contained in:
parent
43ad4c6714
commit
156b0cba4f
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.mysema.codegen</groupId>
|
||||
<artifactId>codegen</artifactId>
|
||||
<version>0.1.6-SNAPSHOT</version>
|
||||
<version>0.1.7</version>
|
||||
<name>Codegen</name>
|
||||
<description>Code generation and compilation for Java</description>
|
||||
<parent>
|
||||
|
||||
@ -86,16 +86,10 @@ public final class JavaWriter implements Appendable, CodeWriter{
|
||||
@Override
|
||||
public JavaWriter annotation(Annotation annotation) throws IOException {
|
||||
append(indent).append("@").appendType(annotation.annotationType()).append("(");
|
||||
boolean first = true;
|
||||
for (Method method : annotation.annotationType().getDeclaredMethods()){
|
||||
Method[] methods = annotation.annotationType().getDeclaredMethods();
|
||||
if (methods.length == 1 && methods[0].getName().equals("value")){
|
||||
try {
|
||||
Object value = method.invoke(annotation);
|
||||
if (value == null){
|
||||
continue;
|
||||
}else if (!first){
|
||||
append(COMMA);
|
||||
}
|
||||
append(method.getName()+"=");
|
||||
Object value = methods[0].invoke(annotation);
|
||||
annotationConstant(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CodegenException(e);
|
||||
@ -103,9 +97,29 @@ public final class JavaWriter implements Appendable, CodeWriter{
|
||||
throw new CodegenException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new CodegenException(e);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
boolean first = true;
|
||||
for (Method method : methods){
|
||||
try {
|
||||
Object value = method.invoke(annotation);
|
||||
if (value == null){
|
||||
continue;
|
||||
}else if (!first){
|
||||
append(COMMA);
|
||||
}
|
||||
append(method.getName()+"=");
|
||||
annotationConstant(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CodegenException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new CodegenException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new CodegenException(e);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
return append(")").nl();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user