Search in sources :

Example 1 with DfBeanDesc

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;
}
Also used : DfBeanDescImpl(org.dbflute.helper.beans.impl.DfBeanDescImpl) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Example 2 with DfBeanDesc

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());
    }
}
Also used : DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) DfBeanIllegalPropertyException(org.dbflute.helper.beans.exception.DfBeanIllegalPropertyException) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Example 3 with DfBeanDesc

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());
    }
}
Also used : DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) DfBeanIllegalPropertyException(org.dbflute.helper.beans.exception.DfBeanIllegalPropertyException) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Example 4 with DfBeanDesc

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);
}
Also used : DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Example 5 with DfBeanDesc

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()]);
}
Also used : DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) ArrayList(java.util.ArrayList) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Aggregations

DfBeanDesc (org.dbflute.helper.beans.DfBeanDesc)13 DfPropertyDesc (org.dbflute.helper.beans.DfPropertyDesc)10 ArrayList (java.util.ArrayList)3 DfBeanIllegalPropertyException (org.dbflute.helper.beans.exception.DfBeanIllegalPropertyException)3 Method (java.lang.reflect.Method)2 List (java.util.List)2 Map (java.util.Map)2 MapParameterBean (org.dbflute.twowaysql.pmbean.MapParameterBean)2 Set (java.util.Set)1 Entity (org.dbflute.Entity)1 DfBeanMethodNotFoundException (org.dbflute.helper.beans.exception.DfBeanMethodNotFoundException)1 DfBeanDescImpl (org.dbflute.helper.beans.impl.DfBeanDescImpl)1 TnModifiedPropertySupport (org.dbflute.s2dao.metadata.TnModifiedPropertySupport)1 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)1 TnRelationPropertyType (org.dbflute.s2dao.metadata.TnRelationPropertyType)1 BindVariableCommentListIndexOutOfBoundsException (org.dbflute.twowaysql.exception.BindVariableCommentListIndexOutOfBoundsException)1 EmbeddedVariableCommentListIndexOutOfBoundsException (org.dbflute.twowaysql.exception.EmbeddedVariableCommentListIndexOutOfBoundsException)1 ForCommentListIndexOutOfBoundsException (org.dbflute.twowaysql.exception.ForCommentListIndexOutOfBoundsException)1 IfCommentListIndexOutOfBoundsException (org.dbflute.twowaysql.exception.IfCommentListIndexOutOfBoundsException)1 ReflectionFailureException (org.dbflute.util.DfReflectionUtil.ReflectionFailureException)1