Search in sources :

Example 1 with MethodInvoker

use of org.beetl.core.om.MethodInvoker in project beetl2.0 by javamonkey.

the class Type method getType.

public Type getType(String attrName) throws BeetlException {
    if (Map.class.isAssignableFrom(cls)) {
        if (types != null) {
            return types[1];
        } else {
        }
        return ObjectType;
    } else if (Collection.class.isAssignableFrom(cls)) {
        if (types != null) {
            return types[0];
        } else {
            return ObjectType;
        }
    } else // }
    if (cls == Object.class) {
        return new Type(Object.class);
    } else {
        MethodInvoker invoker = ObjectUtil.getInvokder(cls, attrName);
        if (invoker == null) {
            BeetlException be = new BeetlException(BeetlException.GET_CALL_ERROR);
            throw be;
        }
        Class returnCls = invoker.getReturnType();
        if (returnCls == Object.class) {
            return Type.ObjectType;
        } else {
            return new Type(returnCls);
        }
    }
}
Also used : BeetlException(org.beetl.core.exception.BeetlException) Collection(java.util.Collection) MethodInvoker(org.beetl.core.om.MethodInvoker)

Example 2 with MethodInvoker

use of org.beetl.core.om.MethodInvoker in project beetl2.0 by javamonkey.

the class HasAttributeFunction method call.

@Override
public Object call(Object[] paras, Context ctx) {
    Object o = paras[0];
    if (o == null) {
        throw new NullPointerException();
    }
    if (o instanceof Map) {
        return false;
    }
    Class type = o.getClass();
    for (int i = 1; i < paras.length; i++) {
        String key = (String) paras[i];
        MethodInvoker invoke = ObjectUtil.getInvokder(type, key);
        if (invoke == null) {
            return false;
        } else if (invoke instanceof GeneralGetMethodInvoker) {
            return false;
        }
    }
    return true;
}
Also used : GeneralGetMethodInvoker(org.beetl.core.om.GeneralGetMethodInvoker) Map(java.util.Map) GeneralGetMethodInvoker(org.beetl.core.om.GeneralGetMethodInvoker) MethodInvoker(org.beetl.core.om.MethodInvoker)

Aggregations

MethodInvoker (org.beetl.core.om.MethodInvoker)2 Collection (java.util.Collection)1 Map (java.util.Map)1 BeetlException (org.beetl.core.exception.BeetlException)1 GeneralGetMethodInvoker (org.beetl.core.om.GeneralGetMethodInvoker)1