Search in sources :

Example 1 with PropertyDesc

use of org.lastaflute.di.helper.beans.PropertyDesc in project lastaflute by lastaflute.

the class Lato method resolveBeanExpression.

protected static String resolveBeanExpression(Object obj, Map<Object, String> alreadyAppearedSet) {
    if (obj == null) {
        throw new IllegalArgumentException("The argument 'obj' should not be null.");
    }
    final Class<? extends Object> targetType = obj.getClass();
    final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(targetType);
    final int propertySize = beanDesc.getPropertyDescSize();
    final StringBuilder sb = new StringBuilder();
    sb.append("{");
    for (int i = 0; i < propertySize; i++) {
        final PropertyDesc pd = beanDesc.getPropertyDesc(i);
        final String propertyName = pd.getPropertyName();
        final Object propertyValue = pd.getValue(obj);
        final String exp = deriveExpression(propertyValue, alreadyAppearedSet, () -> {
            return resolveObjectString(propertyValue, alreadyAppearedSet);
        });
        sb.append(i > 0 ? ", " : "").append(propertyName).append("=").append(exp);
    }
    sb.append("}");
    return sb.toString();
}
Also used : BeanDesc(org.lastaflute.di.helper.beans.BeanDesc) PropertyDesc(org.lastaflute.di.helper.beans.PropertyDesc)

Aggregations

BeanDesc (org.lastaflute.di.helper.beans.BeanDesc)1 PropertyDesc (org.lastaflute.di.helper.beans.PropertyDesc)1