convertToPrimitiveType(byte.class, Byte.class);
convertToPrimitiveType(short.class, Short.class);
convertToPrimitiveType(float.class, Float.class);
convertToPrimitiveType(double.class, Double.class);
convertToClass(Character.class, new TypeConverter() {
public Object convert(String value, TypeLiteral<?> toType) {
value = value.trim();
if (value.length() != 1) {
throw new RuntimeException("Length != 1.");
}
return value.charAt(0);
}
@Override public String toString() {
return "TypeConverter<Character>";
}
});
convertToClasses(Matchers.subclassesOf(Enum.class), new TypeConverter() {
@SuppressWarnings("unchecked")
public Object convert(String value, TypeLiteral<?> toType) {
return Enum.valueOf((Class) toType.getRawType(), value);
}
@Override public String toString() {
return "TypeConverter<E extends Enum<E>>";
}
});
internalConvertToTypes(
new AbstractMatcher<TypeLiteral<?>>() {
public boolean matches(TypeLiteral<?> typeLiteral) {
return typeLiteral.getRawType() == Class.class;
}
@Override public String toString() {
return "Class<?>";
}
},
new TypeConverter() {
@SuppressWarnings("unchecked")
public Object convert(String value, TypeLiteral<?> toType) {
try {
return Class.forName(value);
} catch (ClassNotFoundException e) {