improved TypeExtends serialization

This commit is contained in:
Timo Westkämper 2011-04-12 06:24:34 +00:00
parent 6df167a527
commit 862c0d003b
4 changed files with 13 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mysema.codegen</groupId>
<artifactId>codegen</artifactId>
<version>0.3.6-SNAPSHOT</version>
<version>0.3.7-SNAPSHOT</version>
<name>Codegen</name>
<description>Code generation and compilation for Java</description>
<parent>

View File

@ -19,7 +19,7 @@ import net.jcip.annotations.Immutable;
@Immutable
public class TypeAdapter implements Type{
private final Type type;
protected final Type type;
public TypeAdapter(Type type){
this.type = type;

View File

@ -31,7 +31,7 @@ public class TypeExtends extends TypeAdapter{
super(type);
varName = null;
}
@Override
public String getGenericName(boolean asArgType){
return getGenericName(asArgType, Collections.<String>emptySet(),Collections.<String>emptySet());
@ -40,7 +40,11 @@ public class TypeExtends extends TypeAdapter{
@Override
public String getGenericName(boolean asArgType, Set<String> packages, Set<String> classes){
if (!asArgType){
return "? extends " + super.getGenericName(true, packages, classes);
if (type.equals(Types.OBJECT)){
return "?";
}else{
return "? extends " + super.getGenericName(true, packages, classes);
}
}else{
return super.getGenericName(asArgType, packages, classes);
}

View File

@ -21,4 +21,9 @@ public class TypeExtendsTest {
assertEquals("java.util.Collection<java.lang.Object>", new TypeExtends(Types.COLLECTION).getGenericName(true));
}
@Test
public void GetGenericName_With_Object(){
assertEquals("?", new TypeExtends(Types.OBJECT).getGenericName(false));
}
}