mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
added support for serializing array types properly
This commit is contained in:
parent
ceeacd9541
commit
08d6422de3
@ -106,7 +106,7 @@ public class ClassType implements Type {
|
||||
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return javaClass.getName();
|
||||
return ClassUtils.getFullName(javaClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -21,6 +21,15 @@ public final class ClassUtils {
|
||||
return getName(cl, Collections.singleton("java.lang"), Collections.<String>emptySet());
|
||||
}
|
||||
|
||||
|
||||
public static String getFullName(Class<?> cl) {
|
||||
if (cl.isArray()){
|
||||
return getFullName(cl.getComponentType()) + "[]";
|
||||
}else{
|
||||
return cl.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(Class<?> cl, Set<String> packages, Set<String> classes) {
|
||||
if (cl.isArray()) {
|
||||
return getName(cl.getComponentType(), packages, classes) + "[]";
|
||||
@ -53,4 +62,5 @@ public final class ClassUtils {
|
||||
}
|
||||
|
||||
private ClassUtils(){}
|
||||
|
||||
}
|
||||
|
||||
@ -42,6 +42,15 @@ public class ClassTypeTest {
|
||||
public void Primitive_Arrays(){
|
||||
ClassType byteArray = new ClassType(byte[].class);
|
||||
assertEquals("byte[]", byteArray.getRawName(Collections.singleton("java.lang"), Collections.<String>emptySet()));
|
||||
assertEquals("byte[]", byteArray.getSimpleName());
|
||||
assertEquals("byte[]", byteArray.getFullName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Array(){
|
||||
ClassType byteArray = new ClassType(Byte[].class);
|
||||
assertEquals("Byte[]", byteArray.getRawName(Collections.singleton("java.lang"), Collections.<String>emptySet()));
|
||||
assertEquals("Byte[]", byteArray.getSimpleName());
|
||||
assertEquals("java.lang.Byte[]", byteArray.getFullName());
|
||||
}
|
||||
}
|
||||
|
||||
19
src/test/java/com/mysema/codegen/model/SimpleTypeTest.java
Normal file
19
src/test/java/com/mysema/codegen/model/SimpleTypeTest.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.mysema.codegen.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class SimpleTypeTest {
|
||||
|
||||
@Test
|
||||
public void PrimitiveArray(){
|
||||
Type byteArray = new ClassType(byte[].class);
|
||||
Type byteArray2 = new SimpleType(byteArray, byteArray.getParameters());
|
||||
assertEquals("byte[]", byteArray.getRawName(Collections.singleton("java.lang"), Collections.<String>emptySet()));
|
||||
assertEquals("byte[]", byteArray2.getRawName(Collections.singleton("java.lang"), Collections.<String>emptySet()));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user