Package com.alibaba.citrus.generictype

Examples of com.alibaba.citrus.generictype.TypeInfo


        }
    }

    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


        }
    }

    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

        }
    }

    @Test
    public void equalsHashCode() {
        TypeInfo newType = factory.getType(getReturnType(ownerType, methodName));

        assertEquals(newType, typeInfo);
        assertNotSame(newType, typeInfo);
        assertEquals(newType.hashCode(), typeInfo.hashCode());

        newType = factory.getType(getReturnType(TestClass.class, "zzz"));

        assertThat(typeInfo, not(equalTo(newType)));
        assertNotSame(newType, typeInfo);
        assertThat(typeInfo.hashCode(), not(equalTo(newType.hashCode())));
    }
View Full Code Here

        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

        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

            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);
            }
        }
View Full Code Here

        }
    }

    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

        assertEquals(toString, typeInfo.toString());
    }

    @Test
    public void equalsHashCode() {
        TypeInfo newType = factory.getType(getReturnType(ownerType, methodName));

        if (typeInfo.getComponentType() instanceof RawTypeInfo) {
            assertSame(newType, typeInfo);
        } else {
            assertEquals(newType, typeInfo);
            assertNotSame(newType, typeInfo);
            assertEquals(newType.hashCode(), typeInfo.hashCode());
        }

        newType = factory.getType(Exception[].class);

        assertThat(typeInfo, not(equalTo(newType)));
        assertNotSame(newType, typeInfo);
        assertThat(typeInfo.hashCode(), not(equalTo(newType.hashCode())));
    }
View Full Code Here

        }
    }

    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

import com.alibaba.citrus.generictype.introspect.Introspector;
import com.alibaba.citrus.generictype.introspect.PropertyInfo;

public class Main {
    public static void main(String[] args) throws Exception {
        TypeInfo listBType = TypeInfo.factory.getType(ClassB.class.getMethod("getList").getGenericReturnType());

        Introspector intro = Introspector.getInstance(listBType);
        Map<String, List<PropertyInfo>> props = intro.getProperties();
        System.out.println(props);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.generictype.TypeInfo

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.