use of org.dbflute.helper.beans.DfBeanDesc in project dbflute-core by dbflute.
the class DfBeanDescFactory method getBeanDesc.
// ===================================================================================
// Main
// ====
public static DfBeanDesc getBeanDesc(Class<?> clazz) {
DfBeanDesc beanDesc = beanDescCache.get(clazz);
if (beanDesc == null) {
beanDesc = new DfBeanDescImpl(clazz);
beanDescCache.put(clazz, beanDesc);
}
return beanDesc;
}
use of org.dbflute.helper.beans.DfBeanDesc in project dbflute-core by dbflute.
the class DfPropertyDescImplTest method test_getValue_illegalProperty.
public void test_getValue_illegalProperty() throws Exception {
// ## Arrange ##
DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(MockBean.class);
DfPropertyDesc pd = beanDesc.getPropertyDesc("writeOnlyName");
MockBean bean = new MockBean();
bean.setWriteOnlyName("foo");
// ## Act ##
try {
pd.getValue(bean);
// ## Assert ##
fail();
} catch (DfBeanIllegalPropertyException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.helper.beans.DfBeanDesc in project dbflute-core by dbflute.
the class DfPropertyDescImplTest method test_setValue_illegalProperty.
public void test_setValue_illegalProperty() throws Exception {
// ## Arrange ##
DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(MockBean.class);
DfPropertyDesc pd = beanDesc.getPropertyDesc("readOnlyName");
MockBean bean = new MockBean();
// ## Act ##
try {
pd.setValue(bean, "foo");
// ## Assert ##
fail();
} catch (DfBeanIllegalPropertyException e) {
// OK
log(e.getMessage());
}
}
use of org.dbflute.helper.beans.DfBeanDesc in project dbflute-core by dbflute.
the class TnIdentifierGeneratorFactory method setProperty.
protected static void setProperty(TnIdentifierGenerator generator, String propertyName, String value) {
final DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(generator.getClass());
final DfPropertyDesc pd = beanDesc.getPropertyDesc(propertyName);
pd.setValue(generator, value);
}
use of org.dbflute.helper.beans.DfBeanDesc in project dbflute-core by dbflute.
the class TnDBMetaPropertyTypeFactory method createBeanPropertyTypes.
// ===================================================================================
// Implementation
// ==============
public TnPropertyType[] createBeanPropertyTypes() {
final List<TnPropertyType> list = new ArrayList<TnPropertyType>();
final DfBeanDesc beanDesc = getBeanDesc();
final List<String> proppertyNameList = beanDesc.getProppertyNameList();
for (String proppertyName : proppertyNameList) {
final DfPropertyDesc pd = beanDesc.getPropertyDesc(proppertyName);
// read-only property (that is NOT column) is unnecessary!
if (!pd.isWritable()) {
// is set by classification writer method.
if (!isColumn(pd)) {
continue;
}
}
// (because native type is valid)
if (isClassification(pd)) {
continue;
}
// (because a relation mapping is other process)
if (isRelation(pd)) {
continue;
}
final TnPropertyType pt = createPropertyType(pd);
pt.setPrimaryKey(isPrimaryKey(pd));
pt.setPersistent(isPersistent(pt));
list.add(pt);
}
return list.toArray(new TnPropertyType[list.size()]);
}
Aggregations