Examples of MethodDesc


Examples of chaschev.lang.reflect.MethodDesc

    private static Field _getField(Object object, String fieldName) {
        return getClassDesc(object.getClass()).getField(fieldName);
    }

    public static Optional<MethodDesc> getMethod(Object object, String methodName, Object... params) {
        MethodDesc methodDesc = getClassDesc(object.getClass()).getMethodDesc(methodName, false, params);
        return  Optional.fromNullable(methodDesc);
    }
View Full Code Here

Examples of chaschev.lang.reflect.MethodDesc

        }
    }

    public static Object invokeStatic(Class aClass, String name, Object... args) {
        try {
            final MethodDesc method = OpenBean.getClassDesc(aClass).getStaticMethodDesc(name, false);

            if (method == null) {
                throw new RuntimeException("no such method '" + name + "' " + " in class " + aClass);
            }

            return method.invoke(aClass, args);
        } catch (Exception e) {
            throw Exceptions.runtime(e);
        }
    }
View Full Code Here

Examples of chaschev.lang.reflect.MethodDesc

        }
    }

    public static Object invoke(Object object, String name, Object... args) {
        try {
            final MethodDesc method = OpenBean.getClassDesc(object.getClass()).getMethodDesc(name, false, args);

            if (method == null) {
                throw new RuntimeException("no such method '" + name + "' " + " in object " + object.getClass());
            }

            return method.invoke(object, args);
        } catch (Exception e) {
            throw Exceptions.runtime(e);
        }
    }
View Full Code Here

Examples of chaschev.lang.reflect.MethodDesc

                    return null;
                }else{
                    Method _method = method[0];

                    if(_method == null){
                        MethodDesc methodDesc = OpenBean.getClassDesc(input.getClass()).getMethodDesc(methodName, true);

                        Preconditions.checkNotNull(methodDesc, "no such method: " + methodName);

                        _method = method[0] = methodDesc.getMethod();
                    }
                   
                    try {
                        return (RETURN) _method.invoke(input);
                    } catch (Exception e) {
View Full Code Here

Examples of chaschev.lang.reflect.MethodDesc

    public void invoke(String method, Object... params) {
        Preconditions.checkNotNull(method, "method must not be null");

        setProjectVars();

        MethodDesc methodDesc = OpenBean.getClassDesc(getClass()).getMethodDesc(method, false, params);

        Configuration projectAnnotation = projectConf();
        Configuration methodAnnotation = methodDesc.getMethod().getAnnotation(Configuration.class);

        configureWithAnnotations(methodAnnotation, projectAnnotation);

        global.put(bear.useUI, useUI(firstNonNull(methodAnnotation, projectAnnotation)));

        Object result = methodDesc.invoke(this, params);

        System.out.println("returned result: " + result);
    }
View Full Code Here

Examples of chaschev.lang.reflect.MethodDesc

    public void invoke(String method, Object... params) {
        Preconditions.checkNotNull(method, "method must not be null");

        setProjectVars();

        MethodDesc methodDesc = OpenBean.getClassDesc(getClass()).getMethodDesc(method, false, params);

        Configuration projectAnnotation = projectConf();
        Configuration methodAnnotation = methodDesc.getMethod().getAnnotation(Configuration.class);

        configureWithAnnotations(methodAnnotation, projectAnnotation);

        global.put(bear.useUI, useUI(firstNonNull(methodAnnotation, projectAnnotation)));

        Object result = methodDesc.invoke(this, params);

        System.out.println("returned result: " + result);
    }
View Full Code Here

Examples of net.jini.constraint.BasicMethodConstraints.MethodDesc

            int testCase,
            String name,
            Class[] types,
            InvocationConstraints constraints) {
        if (testCase == 1) { // constructor without arguments
            return new MethodDesc(constraints);
        } else if (testCase == 2) { // constructor with 2 arguments
            return new MethodDesc(name, constraints);
        } else { // constructor with 3 arguments
            return new MethodDesc(name, types, constraints);
        }
    }
View Full Code Here

Examples of net.jini.constraint.BasicMethodConstraints.MethodDesc

                name = "someMethod";
                Class[] types2 = new Class[types.length];
                for (int j = 0; j < types.length; ++j) {
                    types2[j] = types[j];
                }
                MethodDesc md1 =
                    callConstructor(testCase, name, types, constraints);
                MethodDesc md2 =
                    callConstructor(testCase, name, types2, constraints);
                if (!md1.equals(md2)) {
                    throw new TestException(
                            "MethodDesc objects should be equal");
                }
                types2[0] = long.class;
                if (!md1.equals(md2)) {
                    throw new TestException(
                            "MethodDesc objects should be equal");
                }
            }
           
            // 6
            name = "someMethod";
            InvocationConstraints emptyConstraints = new InvocationConstraints(
                    (InvocationConstraint) null, null);
            MethodDesc md1 =
                callConstructor(testCase, name, types, emptyConstraints);
            MethodDesc md2 =
                callConstructor(testCase, name, types, null);
            if (!md1.equals(md2)) {
                throw new TestException(
                        "MethodDesc objects should be equal");
            }
View Full Code Here

Examples of net.jini.constraint.BasicMethodConstraints.MethodDesc

            String name = "someMethod";
            Class[] types = new Class[] {int.class, Object.class};
            InvocationConstraint ic = Delegation.YES;
            InvocationConstraints constraints = new InvocationConstraints(
                    ic, null);
            MethodDesc md = callConstructor(testCase, name, types, constraints);
            String result = md.toString();
            if (result.length() == 0) {
                throw new TestException(
                        "result should not be empty string");
            }
           
           
            // 2
            if (testCase == case2arg) {
                name = "*someMethod";
                md = callConstructor(testCase, name, types, constraints);
                result = md.toString();
                if (result.length() == 0) {
                    throw new TestException(
                            "result should not be empty string");
                }

                name = "*5someMethod";
                md = callConstructor(testCase, name, types, constraints);
                result = md.toString();
                if (result.length() == 0) {
                    throw new TestException(
                            "result should not be empty string");
                }
            }
           
            // 3
            if (testCase == case2arg) {
                name = "someMethod*";
                md = callConstructor(testCase, name, types, constraints);
                result = md.toString();
                if (result.length() == 0) {
                    throw new TestException(
                            "result should not be empty string");
                }
            }
View Full Code Here

Examples of net.jini.constraint.BasicMethodConstraints.MethodDesc

            int testCase,
            String name,
            Class[] types,
            InvocationConstraints constraints) {
        if (testCase == 1) { // constructor without arguments
            return new MethodDesc(constraints);
        } else if (testCase == 2) { // constructor with 2 arguments
            return new MethodDesc(name, constraints);
        } else { // constructor with 3 arguments
            return new MethodDesc(name, types, constraints);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.