use of cn.taketoday.beans.BeanProperty in project today-framework by TAKETODAY.
the class TypeDescriptorTests method nestedPropertyTypeMapTwoLevels.
@Test
public void nestedPropertyTypeMapTwoLevels() throws Exception {
final BeanProperty property = BeanProperty.valueOf(getClass(), "test4");
TypeDescriptor t1 = TypeDescriptor.nested(property.getField(), 2);
assertThat(t1.getType()).isEqualTo(String.class);
}
use of cn.taketoday.beans.BeanProperty in project today-framework by TAKETODAY.
the class TypeDescriptorTests method propertyGenericTypeList.
@Test
void propertyGenericTypeList() throws Exception {
GenericType<Integer> genericBean = new IntegerType();
BeanProperty property = BeanProperty.valueOf(genericBean.getClass().getMethod("getListProperty"), genericBean.getClass().getMethod("setListProperty", List.class));
TypeDescriptor desc = property.getTypeDescriptor();
assertThat(desc.getType()).isEqualTo(List.class);
assertThat(desc.getElementDescriptor().getType()).isEqualTo(Integer.class);
}
use of cn.taketoday.beans.BeanProperty in project today-framework by TAKETODAY.
the class TypeDescriptorTests method propertyComplex.
@Test
public void propertyComplex() throws Exception {
BeanProperty complexProperty = BeanProperty.valueOf(getClass(), "complexProperty");
TypeDescriptor desc = complexProperty.getTypeDescriptor();
assertThat(desc.getMapKeyDescriptor().getType()).isEqualTo(String.class);
assertThat(desc.getMapValueDescriptor().getElementDescriptor().getElementDescriptor().getType()).isEqualTo(Integer.class);
}
use of cn.taketoday.beans.BeanProperty in project today-framework by TAKETODAY.
the class TypeDescriptorTests method upCastNotSuper.
@Test
public void upCastNotSuper() throws Exception {
final BeanProperty property = BeanProperty.valueOf(getClass(), "property");
TypeDescriptor descriptor = property.getTypeDescriptor();
assertThatIllegalArgumentException().isThrownBy(() -> descriptor.upcast(Collection.class)).withMessage("interface java.util.Map is not assignable to interface java.util.Collection");
}
use of cn.taketoday.beans.BeanProperty in project today-framework by TAKETODAY.
the class BeanPropertyRowMapper method initialize.
protected void initialize(Class<T> mappedClass, BeanMetadata metadata) {
this.mappedClass = mappedClass;
setConversionService(ApplicationConversionService.getSharedInstance());
HashSet<String> mappedProperties = new HashSet<>();
HashMap<String, BeanProperty> mappedFields = new HashMap<>();
for (BeanProperty property : metadata) {
if (property.isWriteable()) {
String lowerCaseName = lowerCaseName(property.getName());
mappedFields.put(lowerCaseName, property);
String underscoreName = underscoreName(property.getName());
if (!lowerCaseName.equals(underscoreName)) {
mappedFields.put(underscoreName, property);
}
mappedProperties.add(property.getName());
}
}
this.mappedFields = mappedFields;
this.mappedProperties = mappedProperties;
}
Aggregations