Search in sources :

Example 1 with TnModifiedPropertySupport

use of org.dbflute.s2dao.metadata.TnModifiedPropertySupport in project dbflute-core by dbflute.

the class TnBeanMetaDataFactoryExtension method createModifiedPropertySupport.

// ===================================================================================
// Override for ModifiedProperty
// =============================
@Override
protected TnModifiedPropertySupport createModifiedPropertySupport() {
    return new TnModifiedPropertySupport() {

        public Set<String> getModifiedPropertyNames(Object bean) {
            if (bean instanceof Entity) {
                // all entities of DBFlute are here
                return ((Entity) bean).mymodifiedProperties();
            } else {
                // basically no way on DBFlute (S2Dao's route)
                final DfBeanDesc beanDesc = DfBeanDescFactory.getBeanDesc(bean.getClass());
                final String propertyName = MODIFIED_PROPERTY_PROPERTY_NAME;
                if (!beanDesc.hasPropertyDesc(propertyName)) {
                    return DfCollectionUtil.emptySet();
                } else {
                    final DfPropertyDesc propertyDesc = beanDesc.getPropertyDesc(propertyName);
                    final Object value = propertyDesc.getValue(bean);
                    if (value != null) {
                        @SuppressWarnings("unchecked") final Set<String> extractedSet = (Set<String>) value;
                        return extractedSet;
                    } else {
                        return DfCollectionUtil.emptySet();
                    }
                }
            }
        }
    };
}
Also used : Entity(org.dbflute.Entity) DfPropertyDesc(org.dbflute.helper.beans.DfPropertyDesc) Set(java.util.Set) TnModifiedPropertySupport(org.dbflute.s2dao.metadata.TnModifiedPropertySupport) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc)

Aggregations

Set (java.util.Set)1 Entity (org.dbflute.Entity)1 DfBeanDesc (org.dbflute.helper.beans.DfBeanDesc)1 DfPropertyDesc (org.dbflute.helper.beans.DfPropertyDesc)1 TnModifiedPropertySupport (org.dbflute.s2dao.metadata.TnModifiedPropertySupport)1