use of org.dbflute.helper.beans.DfPropertyDesc 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();
}
}
}
}
};
}
use of org.dbflute.helper.beans.DfPropertyDesc in project dbflute-core by dbflute.
the class TnIdentifierAbstractGenerator method reflectIdentifier.
protected void reflectIdentifier(Object bean, Object value) {
final DfPropertyDesc pd = _propertyType.getPropertyDesc();
// setting by reflection here
pd.setValue(bean, value);
}
use of org.dbflute.helper.beans.DfPropertyDesc in project dbflute-core by dbflute.
the class BoundValueTracer method trace.
// ===================================================================================
// Set up
// ======
public void trace(BoundValue boundValue) {
Object value = boundValue.getFirstValue();
if (value == null) {
// if null, do nothing
return;
}
// if value is not null, required
Class<?> clazz = boundValue.getFirstType();
// LikeSearchOption handling here is for OutsideSql.
FilteringBindOption filteringBindOption = null;
for (int pos = 1; pos < _nameList.size(); pos++) {
if (value == null) {
break;
}
final String currentName = _nameList.get(pos);
final DfBeanDesc beanDesc = getBeanDesc(clazz);
if (hasLikeSearchProperty(beanDesc, currentName, value)) {
final FilteringBindOption currentOption = getFilteringBindOption(beanDesc, currentName, value);
if (currentOption != null) {
// if exists, override option
filteringBindOption = currentOption;
}
}
if (beanDesc.hasPropertyDesc(currentName)) {
// main case
final DfPropertyDesc pd = beanDesc.getPropertyDesc(currentName);
value = getPropertyValue(clazz, value, currentName, pd);
clazz = (value != null ? value.getClass() : pd.getPropertyType());
continue;
}
if (MapParameterBean.class.isInstance(value)) {
// used by union-query internally
final Map<?, ?> map = ((MapParameterBean<?>) value).getParameterMap();
// (different specification with Map)
if (map.containsKey(currentName)) {
value = map.get(currentName);
clazz = (value != null ? value.getClass() : null);
continue;
}
}
if (Map.class.isInstance(value)) {
final Map<?, ?> map = (Map<?, ?>) value;
// if the key does not exist, treated same as a null value
value = map.get(currentName);
clazz = (value != null ? value.getClass() : null);
continue;
}
if (List.class.isInstance(value)) {
if (currentName.startsWith("get(") && currentName.endsWith(")")) {
final List<?> list = (List<?>) value;
final String exp = Srl.extractScopeFirst(currentName, "get(", ")").getContent();
try {
final Integer index = DfTypeUtil.toInteger(exp);
value = list.get(index);
} catch (NumberFormatException e) {
throwListIndexNotNumberException(exp, e);
} catch (IndexOutOfBoundsException e) {
throwListIndexOutOfBoundsException(exp, e);
}
clazz = (value != null ? value.getClass() : null);
continue;
}
}
throwNotFoundPropertyException(clazz, currentName);
}
adjustLikeSearchDBWay(filteringBindOption);
boundValue.setTargetValue(value);
boundValue.setTargetType(clazz);
boundValue.setFilteringBindOption(filteringBindOption);
}
use of org.dbflute.helper.beans.DfPropertyDesc in project dbflute-core by dbflute.
the class TnAbstractEntityHandler method updateTimestampIfNeed.
protected void updateTimestampIfNeed(Object bean, int index) {
final List<Timestamp> newTimestampList = _newTimestampList;
if (newTimestampList == null || newTimestampList.isEmpty()) {
return;
}
final DfPropertyDesc pd = getBeanMetaData().getTimestampPropertyType().getPropertyDesc();
final Timestamp timestamp = newTimestampList.get(index);
final boolean localDateTime = pd.getPropertyType().isAssignableFrom(LocalDateTime.class);
final Object realValue = localDateTime ? DfTypeUtil.toLocalDateTime(timestamp) : timestamp;
pd.setValue(bean, realValue);
}
use of org.dbflute.helper.beans.DfPropertyDesc in project dbflute-core by dbflute.
the class TnAbstractEntityHandler method updateVersionNoIfNeed.
protected void updateVersionNoIfNeed(Object bean, int index) {
final List<Long> newVersionNoList = _newVersionNoList;
if (newVersionNoList == null || newVersionNoList.isEmpty()) {
return;
}
final DfPropertyDesc pd = getBeanMetaData().getVersionNoPropertyType().getPropertyDesc();
pd.setValue(bean, newVersionNoList.get(index));
}
Aggregations