use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class ConverterTest method testDateConversions.
@Test
public void testDateConversions() {
Converters converters = new Converters(null);
Converter converter = converters.getConverter(Date.class);
Date testDate1 = new Date();
checkConversion(converter, testDate1);
Date testDate2 = new Date(0);
checkConversion(converter, testDate2);
Date testDate3 = new Date(Long.MAX_VALUE);
checkConversion(converter, testDate3);
Date testDate4 = null;
checkConversion(converter, testDate4);
// TODO: Not working based on date formate (yyyy), max year is 9999
// Date testDate5 = new Date(Long.MIN_VALUE);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class ClassRepositoryImpl method createClassInfoForClass.
private ClassInfo createClassInfoForClass(final Class<?> beanClass) {
final List<PropertyInfo> propertyInfos = new ArrayList<>();
final List<PropertyInfo> observableListInfos = new ArrayList<>();
for (Field field : ReflectionHelper.getInheritedDeclaredFields(beanClass)) {
PropertyType type = null;
if (Property.class.isAssignableFrom(field.getType())) {
type = PropertyType.PROPERTY;
} else if (ObservableList.class.isAssignableFrom(field.getType())) {
type = PropertyType.OBSERVABLE_LIST;
}
final Class<?> parameterType = ReflectionHelper.getTypeParameter(field);
if (type != null && parameterType != null) {
final String attributeName = DolphinUtils.getDolphinAttributePropertyNameForField(field);
final Converter converter = converters.getConverter(parameterType);
final PropertyInfo propertyInfo = new ClassPropertyInfo(attributeName, converter, field);
if (type == PropertyType.PROPERTY) {
propertyInfos.add(propertyInfo);
} else {
observableListInfos.add(propertyInfo);
}
}
}
return new ClassInfo(beanClass, propertyInfos, observableListInfos);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class ConverterTest method testDoubleConversions.
@Test
public void testDoubleConversions() {
Converters converters = new Converters(null);
Converter converter = converters.getConverter(Double.class);
checkConversion(converter, 2.9d);
checkConversion(converter, null);
checkConversion(converter, 0.0);
checkConversion(converter, Double.MAX_VALUE);
checkConversion(converter, Double.MIN_VALUE);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class ConverterTest method testStringConversions.
@Test
public void testStringConversions() {
Converters converters = new Converters(null);
Converter converter = converters.getConverter(String.class);
checkConversion(converter, "");
checkConversion(converter, null);
checkConversion(converter, "Hello");
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testConverterCreation.
@Test
public void testConverterCreation() {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
Assert.assertNotNull(converter);
converter = factory.getConverterForType(GregorianCalendar.class);
Assert.assertNotNull(converter);
}
Aggregations