Example usage for org.apache.ibatis.reflection MetaObject getGetterType

List of usage examples for org.apache.ibatis.reflection MetaObject getGetterType

Introduction

In this page you can find the example usage for org.apache.ibatis.reflection MetaObject getGetterType.

Prototype

public Class<?> getGetterType(String name) 

Source Link

Usage

From source file:com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.ConditionalTagHandler.java

License:Apache License

protected long compare(SqlTagContext ctx, SqlTag tag, Object parameterObject) {
    String comparePropertyName = tag.getComparePropertyAttr();
    String compareValue = tag.getCompareValueAttr();

    String prop = getResolvedProperty(ctx, tag);
    Object value1;/* w ww  . j av  a  2  s. com*/
    Class type;

    MetaObject metaObject = SystemMetaObject.forObject(parameterObject);
    if (prop != null) {
        value1 = metaObject.getValue(prop);
        type = metaObject.getGetterType(prop);
    } else {
        value1 = parameterObject;
        if (value1 != null) {
            type = parameterObject.getClass();
        } else {
            type = Object.class;
        }
    }
    if (comparePropertyName != null) {
        Object value2 = metaObject.getValue(comparePropertyName);
        return compareValues(type, value1, value2);
    } else if (compareValue != null) {
        return compareValues(type, value1, compareValue);
    } else {
        throw new RuntimeException("Error comparing in conditional fragment.  Uknown 'compare to' values.");
    }
}