Package com.alibaba.citrus.generictype

Examples of com.alibaba.citrus.generictype.MethodInfo


            addProperty(prop);
        }
    }

    private PropertyInfo createMappedProperty(Method javaMethod, String propName, boolean read, int paramIndex) {
        MethodInfo method = factory.getMethod(javaMethod, getType());
        TypeInfo declaringType = method.getDeclaringType();
        TypeInfo type = paramIndex >= 0 ? method.getParameterTypes().get(paramIndex) : method.getReturnType();
        MethodInfo readMethod = read ? method : null;
        MethodInfo writMethod = read ? null : method;

        return new MappedPropertyImpl(propName, declaringType, type, readMethod, writMethod);
    }
View Full Code Here


    /** 转换成字符串。 */
    @Override
    public String toString() {
        StringBuilder buf = new StringBuilder();
        MethodInfo reader = getReadMethod();
        MethodInfo writer = getWriteMethod();

        buf.append(getDescription()).append(" {\n");
        buf.append("  declaringType = ").append(getDeclaringType()).append("\n");
        buf.append("  type          = ").append(getType()).append("\n");
        buf.append("  name          = ").append(getName()).append("\n");
View Full Code Here

    private PropertyInfo createSimpleProperty(Method javaMethod, String propName, boolean read, int paramIndex) {
        if (StringUtil.isEmpty(propName)) {
            return null;
        }

        MethodInfo method = factory.getMethod(javaMethod, getType());
        TypeInfo declaringType = method.getDeclaringType();
        TypeInfo type = paramIndex >= 0 ? method.getParameterTypes().get(paramIndex) : method.getReturnType();
        MethodInfo readMethod = read ? method : null;
        MethodInfo writMethod = read ? null : method;

        return new SimplePropertyImpl(propName, declaringType, type, readMethod, writMethod);
    }
View Full Code Here

        ClassTypeInfo class3 = factory.getClassType(Class3.class);

        System.out.printf("Context class:                   %s\n", class3);

        // Class1.getArrayList()
        MethodInfo getArrayList = factory.getMethod(Class1.class.getMethod("getArrayList"));

        System.out.printf("Method:                          %s\n", getArrayList);

        // ArrayList<A>
        ClassTypeInfo returnType = (ClassTypeInfo) getArrayList.getReturnType();

        System.out.printf("Return type of method:           %s\n", returnType);

        // resolve ArrayList<A>
        ClassTypeInfo resolvedType = returnType.resolve(class3);
View Full Code Here

*/
public class MapPropertiesFinder extends SinglePropertyFinder {
    @Override
    protected PropertyInfo createPropertyInfo(TypeInfo type) {
        if (type instanceof ClassTypeInfo && Map.class.isAssignableFrom(type.getRawType())) {
            MethodInfo writeMethod = ((ClassTypeInfo) type).getMethod("put", Object.class, Object.class);
            Class<?> keyType = writeMethod.getParameterTypes().get(0).getRawType();

            if (keyType.isAssignableFrom(String.class)) {
                MethodInfo readMethod = ((ClassTypeInfo) type).getMethod("get", Object.class);
                TypeInfo propertyType = writeMethod.getParameterTypes().get(1);

                return new MapPropertyImpl(readMethod.getDeclaringType(), propertyType, readMethod, writeMethod);
            }
        }

        return null;
    }
View Full Code Here

            addProperty(prop);
        }
    }

    private PropertyInfo createIndexedProperty(Method javaMethod, String propName, boolean read, int paramIndex) {
        MethodInfo method = factory.getMethod(javaMethod, getType());
        TypeInfo declaringType = method.getDeclaringType();
        TypeInfo type = paramIndex >= 0 ? method.getParameterTypes().get(paramIndex) : method.getReturnType();
        MethodInfo readMethod = read ? method : null;
        MethodInfo writMethod = read ? null : method;

        return new IndexedPropertyImpl(propName, declaringType, type, readMethod, writMethod);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.generictype.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.