store nullability information in TypeInfo
This commit is contained in:
@@ -10,15 +10,18 @@ import java.util.Arrays;
|
||||
public class TypeInfo<T> implements JetObject {
|
||||
private TypeInfo<?> typeInfo;
|
||||
private final Class<T> theClass;
|
||||
private final boolean nullable;
|
||||
private final TypeInfo[] typeParameters;
|
||||
|
||||
public TypeInfo(Class<T> theClass) {
|
||||
public TypeInfo(Class<T> theClass, boolean nullable) {
|
||||
this.theClass = theClass;
|
||||
this.nullable = nullable;
|
||||
this.typeParameters = null;
|
||||
}
|
||||
|
||||
public TypeInfo(Class<T> theClass, TypeInfo[] typeParameters) {
|
||||
public TypeInfo(Class<T> theClass, boolean nullable, TypeInfo[] typeParameters) {
|
||||
this.theClass = theClass;
|
||||
this.nullable = nullable;
|
||||
this.typeParameters = typeParameters;
|
||||
}
|
||||
|
||||
@@ -33,6 +36,9 @@ public class TypeInfo<T> implements JetObject {
|
||||
if (!theClass.isAssignableFrom(other.theClass)) {
|
||||
return false;
|
||||
}
|
||||
if (nullable != other.nullable) {
|
||||
return false;
|
||||
}
|
||||
if (typeParameters != null) {
|
||||
if (other.typeParameters == null || other.typeParameters.length != typeParameters.length) {
|
||||
throw new IllegalArgumentException("inconsistent type infos for the same class");
|
||||
@@ -68,6 +74,7 @@ public class TypeInfo<T> implements JetObject {
|
||||
TypeInfo typeInfo = (TypeInfo) o;
|
||||
|
||||
if (!theClass.equals(typeInfo.theClass)) return false;
|
||||
if (nullable != typeInfo.nullable) return false;
|
||||
if (!Arrays.equals(typeParameters, typeInfo.typeParameters)) return false;
|
||||
|
||||
return true;
|
||||
@@ -80,12 +87,12 @@ public class TypeInfo<T> implements JetObject {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final TypeInfo<Byte> BYTE_TYPE_INFO = new TypeInfo<Byte>(Byte.class);
|
||||
public static final TypeInfo<Short> SHORT_TYPE_INFO = new TypeInfo<Short>(Short.class);
|
||||
public static final TypeInfo<Integer> INT_TYPE_INFO = new TypeInfo<Integer>(Integer.class);
|
||||
public static final TypeInfo<Long> LONG_TYPE_INFO = new TypeInfo<Long>(Long.class);
|
||||
public static final TypeInfo<Character> CHAR_TYPE_INFO = new TypeInfo<Character>(Character.class);
|
||||
public static final TypeInfo<Boolean> BOOL_TYPE_INFO = new TypeInfo<Boolean>(Boolean.class);
|
||||
public static final TypeInfo<Float> FLOAT_TYPE_INFO = new TypeInfo<Float>(Float.class);
|
||||
public static final TypeInfo<Double> DOUBLE_TYPE_INFO = new TypeInfo<Double>(Double.class);
|
||||
public static final TypeInfo<Byte> BYTE_TYPE_INFO = new TypeInfo<Byte>(Byte.class, false);
|
||||
public static final TypeInfo<Short> SHORT_TYPE_INFO = new TypeInfo<Short>(Short.class, false);
|
||||
public static final TypeInfo<Integer> INT_TYPE_INFO = new TypeInfo<Integer>(Integer.class, false);
|
||||
public static final TypeInfo<Long> LONG_TYPE_INFO = new TypeInfo<Long>(Long.class, false);
|
||||
public static final TypeInfo<Character> CHAR_TYPE_INFO = new TypeInfo<Character>(Character.class, false);
|
||||
public static final TypeInfo<Boolean> BOOL_TYPE_INFO = new TypeInfo<Boolean>(Boolean.class, false);
|
||||
public static final TypeInfo<Float> FLOAT_TYPE_INFO = new TypeInfo<Float>(Float.class, false);
|
||||
public static final TypeInfo<Double> DOUBLE_TYPE_INFO = new TypeInfo<Double>(Double.class, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user