Package com.alibaba.fastjson.util

Examples of com.alibaba.fastjson.util.ParameterizedTypeImpl


    public void test_null() throws Exception {
        FieldInfo fieldInfo = new FieldInfo("getValue", Entity.class.getMethod("getValue"), null);
        Assert.assertEquals(null, fieldInfo.getAnnotation(JSONField.class));

        Field field = GenericFieldEntity.class.getField("value");
        Type type = new ParameterizedTypeImpl(new Type[] { ValueObject.class }, null, GenericFieldEntity.class);
        FieldInfo fieldInfoOfField = new FieldInfo("value", null, field, GenericFieldEntity.class, type);
        Assert.assertEquals(fieldInfoOfField.getFieldType(), ValueObject.class);
        Assert.assertEquals(fieldInfoOfField.getFieldClass(), ValueObject.class);

        field = GenericListFieldEntity.class.getField("value");
        type = new ParameterizedTypeImpl(new Type[] { ValueObject.class }, null, GenericListFieldEntity.class);
        FieldInfo fieldInfoOfListField = new FieldInfo("value", null, field, GenericListFieldEntity.class, type);
        ParameterizedTypeImpl actualFieldType = (ParameterizedTypeImpl) fieldInfoOfListField.getFieldType();
        Assert.assertEquals(actualFieldType.getActualTypeArguments()[0], ValueObject.class);
        Assert.assertEquals(actualFieldType.getRawType(), List.class);
        Assert.assertEquals(fieldInfoOfListField.getFieldClass(), List.class);
        Assert.assertEquals(null, ((ParameterizedTypeImpl) type).getOwnerType());

        Method method = GenericSetterEntity.class.getMethod("setValue", Object.class);
        type = new ParameterizedTypeImpl(new Type[] { ValueObject.class }, null, GenericSetterEntity.class);
        FieldInfo fieldInfoOfSetter = new FieldInfo("value", method, null, GenericSetterEntity.class, type);
        Assert.assertEquals(fieldInfoOfSetter.getFieldType(), ValueObject.class);
        Assert.assertEquals(fieldInfoOfSetter.getFieldClass(), ValueObject.class);
       
        fieldInfoOfSetter.toString();

        method = GenericListSetterEntity.class.getMethod("setValue", List.class);
        type = new ParameterizedTypeImpl(new Type[] { ValueObject.class }, null, GenericListSetterEntity.class);
        FieldInfo fieldInfoOfListSetter = new FieldInfo("value", method, null, GenericListSetterEntity.class, type);
        Assert.assertEquals(actualFieldType.getActualTypeArguments()[0], ValueObject.class);
        Assert.assertEquals(actualFieldType.getRawType(), List.class);
        Assert.assertEquals(fieldInfoOfListSetter.getFieldClass(), List.class);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.util.ParameterizedTypeImpl

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.