Package com.strobel.reflection

Examples of com.strobel.reflection.MethodInfo


    }

    public static <A extends Annotation> AnnotationBuilder<A> create(final Type<A> annotationType, final Object value) {
        VerifyArgument.notNull(annotationType, "annotationType");

        final MethodInfo valueProperty = annotationType.getMethod("value");

        if (valueProperty == null) {
            throw Error.annotationHasNoDefaultAttribute();
        }
View Full Code Here


        if (propertyCount != valueCount) {
            throw Error.attributeValueCountMismatch();
        }

        if (valueCount == 0) {
            final MethodInfo defaultProperty = annotationType.getMethod("value");

            if (defaultProperty != null) {
                throw Error.annotationRequiresValue(annotationType);
            }
        }
View Full Code Here

        final String name,
        final Set<BindingFlags> bindingFlags,
        final CallingConvention callingConvention,
        final Type... parameterTypes) {

        final MethodInfo method = type.getMethod(name, bindingFlags, callingConvention, parameterTypes);

        return methodArgumentsMatch(method, parameterTypes) ? method : null;
    }
View Full Code Here

            return null;
        }

        final MethodList methods = interfaceType.getMethods();

        MethodInfo invokeMethod = null;

        for (final MethodInfo method : methods) {
            if (method.isDefault()) {
                continue;
            }
View Full Code Here

        final ExpressionType binaryType,
        final Type leftType,
        final Type rightType,
        final String name) {

        final MethodInfo method = getMethodValidated(
            leftType,
            name,
            BindingFlags.PublicInstance,
            CallingConvention.Standard,
            rightType
View Full Code Here

        final ExpressionType binaryType,
        final Type leftType,
        final Type rightType,
        final String name) {

        final MethodInfo method = getMethodValidated(
            leftType,
            name,
            BindingFlags.PublicStatic,
            CallingConvention.Standard,
            leftType,
View Full Code Here

        final Type leftType = left.getType();
        final Type rightType = right.getType();

        if (name != null) {
            // try exact match first
            MethodInfo method = getBinaryOperatorStaticMethod(binaryType, leftType, rightType, name);

            if (method != null) {
                return new MethodBinaryExpression(binaryType, left, right, method.getReturnType(), method);
            }

            method = getBinaryOperatorMethod(binaryType, leftType, rightType, name);

            if (method != null) {
                return new MethodBinaryExpression(binaryType, left, right, method.getReturnType(), method);
            }

            // try auto(un)boxing call
            if (TypeUtils.isAutoUnboxed(rightType)) {
                final Type unboxedRightType = TypeUtils.getUnderlyingPrimitive(rightType);

                method = getBinaryOperatorMethod(binaryType, leftType, unboxedRightType, name);

                if (method != null) {
                    return new MethodBinaryExpression(binaryType, left, right, method.getReturnType(), method);
                }
            }
            else if (rightType.isPrimitive()) {
                if (TypeUtils.isAutoUnboxed(rightType)) {
                    final Type boxedRightType = TypeUtils.getBoxedType(rightType);

                    method = getBinaryOperatorMethod(binaryType, leftType, boxedRightType, name);

                    if (method != null) {
                        return new MethodBinaryExpression(binaryType, left, right, method.getReturnType(), method);
                    }
                }
            }
        }
View Full Code Here

        final Expression right) {

        final Type leftType = left.getType();
        final Type rightType = right.getType();

        MethodInfo method;

        if (TypeUtils.areEquivalent(leftType, rightType)) {
            final Type comparable = Types.Comparable.makeGenericType(leftType);

            if (leftType.implementsInterface(comparable)) {
                method = getMethodValidated(
                    Types.Comparer,
                    "compare",
                    BindingFlags.PublicStatic,
                    CallingConvention.Standard,
                    Types.Comparable,
                    Types.Comparable
                );

                if (method != null) {
                    method = method.makeGenericMethod(leftType);
                    return new CompareMethodBasedLogicalBinaryExpression(binaryType, left, right, method);
                }
            }
        }
View Full Code Here

        final String name,
        final Expression left,
        final Expression right,
        final LambdaExpression<?> conversion) {

        final MethodInfo method = getBinaryOperatorMethod(binaryType, left.getType(), right.getType(), name);

        if (method != null) {
            return new MethodBinaryExpression(binaryType, left, right, method.getReturnType(), method);
        }

        return null;
    }
View Full Code Here

        final Expression left,
        final MethodInfo method,
        final ExpressionType nodeType) {

        final Type interfaceType = conversion.getType();
        final MethodInfo invokeMethod = getInvokeMethod(conversion);
        final ParameterList parameters = invokeMethod.getParameters();

        if (parameters.size() != 1) {
            throw Error.incorrectNumberOfMethodCallArguments(invokeMethod);
        }

        if (!TypeUtils.hasIdentityPrimitiveOrBoxingConversion(invokeMethod.getReturnType(), left.getType())) {
            throw Error.operandTypesDoNotMatchParameters(nodeType, invokeMethod);
        }

        if (method != null) {
            if (!TypeUtils.hasIdentityPrimitiveOrBoxingConversion(
View Full Code Here

TOP

Related Classes of com.strobel.reflection.MethodInfo

Copyright © 2018 www.massapicom. 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.