Java 类com.alibaba.fastjson.annotation.JSONType 实例源码

项目:GitHub    文件:SerializeBeanInfo.java   
public SerializeBeanInfo(Class<?> beanType, //
                         JSONType jsonType, //
                         String typeName, //
                         String typeKey,
                         int features,
                         FieldInfo[] fields, //
                         FieldInfo[] sortedFields
                         ){
    this.beanType = beanType;
    this.jsonType = jsonType;
    this.typeName = typeName;
    this.typeKey = typeKey;
    this.features = features;
    this.fields = fields;
    this.sortedFields = sortedFields;
}
项目:GitHub    文件:JavaBeanInfo.java   
public static Class<?> getBuilderClass(Class<?> clazz, JSONType type) {
    if (clazz != null && clazz.getName().equals("org.springframework.security.web.savedrequest.DefaultSavedRequest")) {
        return TypeUtils.loadClass("org.springframework.security.web.savedrequest.DefaultSavedRequest$Builder");
    }

    if (type == null) {
        return null;
    }

    Class<?> builderClass = type.builder();

    if (builderClass == Void.class) {
        return null;
    }

    return builderClass;
}
项目:itmarry    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = clazz.getAnnotation(JSONType.class);

    if (jsonType != null && jsonType.ignores() != null) {
        for (String item : jsonType.ignores()) {
            if (propertyName.equalsIgnoreCase(item)) {
                return true;
            }
        }
    }

    if (clazz.getSuperclass() != Object.class && clazz.getSuperclass() != null) {
        if (isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
            return true;
        }
    }

    return false;
}
项目:android_http_demo    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = clazz.getAnnotation(JSONType.class);

    if (jsonType != null && jsonType.ignores() != null) {
        for (String item : jsonType.ignores()) {
            if (propertyName.equalsIgnoreCase(item)) {
                return true;
            }
        }
    }

    if (clazz.getSuperclass() != Object.class) {
        if (isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
            return true;
        }
    }

    return false;
}
项目:cartman    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = clazz.getAnnotation(JSONType.class);

    if (jsonType != null && jsonType.ignores() != null) {
        for (String item : jsonType.ignores()) {
            if (propertyName.equalsIgnoreCase(item)) {
                return true;
            }
        }
    }

    if (clazz.getSuperclass() != Object.class && clazz.getSuperclass() != null) {
        if (isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
            return true;
        }
    }

    return false;
}
项目:AndroidNio    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = clazz.getAnnotation(JSONType.class);

    if (jsonType != null && jsonType.ignores() != null) {
        for (String item : jsonType.ignores()) {
            if (propertyName.equalsIgnoreCase(item)) {
                return true;
            }
        }
    }

    if (clazz.getSuperclass() != Object.class) {
        if (isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
            return true;
        }
    }

    return false;
}
项目:GitHub    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName){
    JSONType jsonType = TypeUtils.getAnnotation(clazz,JSONType.class);
    if(jsonType != null){
        // 1、新增 includes 支持,如果 JSONType 同时设置了includes 和 ignores 属性,则以includes为准。
        // 2、个人认为对于大小写敏感的Java和JS而言,使用 equals() 比 equalsIgnoreCase() 更好,改动的唯一风险就是向后兼容性的问题
        // 不过,相信开发者应该都是严格按照大小写敏感的方式进行属性设置的
        String[] fields = jsonType.includes();
        if(fields.length > 0){
            for(int i = 0; i < fields.length; i++){
                if(propertyName.equals(fields[i])){
                    return false;
                }
            }
            return true;
        } else{
            fields = jsonType.ignores();
            for(int i = 0; i < fields.length; i++){
                if(propertyName.equals(fields[i])){
                    return true;
                }
            }
        }
    }
    if(clazz.getSuperclass() != Object.class && clazz.getSuperclass() != null){
        if(isJSONTypeIgnore(clazz.getSuperclass(), propertyName)){
            return true;
        }
    }
    return false;
}
项目:GitHub    文件:TypeUtils.java   
public static int getSerializeFeatures(Class<?> clazz){
    JSONType annotation = TypeUtils.getAnnotation(clazz,JSONType.class);
    if(annotation == null){
        return 0;
    }
    return SerializerFeature.of(annotation.serialzeFeatures());
}
项目:GitHub    文件:TypeUtils.java   
public static int getParserFeatures(Class<?> clazz){
    JSONType annotation = TypeUtils.getAnnotation(clazz,JSONType.class);
    if(annotation == null){
        return 0;
    }
    return Feature.of(annotation.parseFeatures());
}
项目:boohee_v5.6    文件:SerializeConfig.java   
public ObjectSerializer createJavaBeanSerializer(Class<?> clazz) {
    if (!Modifier.isPublic(clazz.getModifiers())) {
        return new JavaBeanSerializer(clazz);
    }
    boolean asm = this.asm;
    if ((asm && this.asmFactory.isExternalClass(clazz)) || clazz == Serializable.class || clazz == Object.class) {
        asm = false;
    }
    JSONType annotation = (JSONType) clazz.getAnnotation(JSONType.class);
    if (!(annotation == null || annotation.asm())) {
        asm = false;
    }
    if (asm && !ASMUtils.checkName(clazz.getName())) {
        asm = false;
    }
    if (asm) {
        try {
            ObjectSerializer asmSerializer = createASMSerializer(clazz);
            if (asmSerializer != null) {
                return asmSerializer;
            }
        } catch (ClassCastException e) {
        } catch (Throwable e2) {
            JSONException jSONException = new JSONException("create asm serializer error, class " + clazz, e2);
        }
    }
    return new JavaBeanSerializer(clazz);
}
项目:boohee_v5.6    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = (JSONType) clazz.getAnnotation(JSONType.class);
    if (!(jsonType == null || jsonType.ignores() == null)) {
        for (String item : jsonType.ignores()) {
            if (propertyName.equalsIgnoreCase(item)) {
                return true;
            }
        }
    }
    if (clazz.getSuperclass() == Object.class || clazz.getSuperclass() == null || !isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
        return false;
    }
    return true;
}
项目:boohee_v5.6    文件:TypeUtils.java   
public static int getSerializeFeatures(Class<?> clazz) {
    JSONType annotation = (JSONType) clazz.getAnnotation(JSONType.class);
    if (annotation == null) {
        return 0;
    }
    return SerializerFeature.of(annotation.serialzeFeatures());
}
项目:boohee_v5.6    文件:TypeUtils.java   
public static int getParserFeatures(Class<?> clazz) {
    JSONType annotation = (JSONType) clazz.getAnnotation(JSONType.class);
    if (annotation == null) {
        return 0;
    }
    return Feature.of(annotation.parseFeatures());
}
项目:uavstack    文件:TypeUtils.java   
private static boolean isJSONTypeIgnore(Class<?> clazz, String propertyName) {
    JSONType jsonType = clazz.getAnnotation(JSONType.class);

    if (jsonType != null) {
        // 1、新增 includes 支持,如果 JSONType 同时设置了includes 和 ignores 属性,则以includes为准。
        // 2、个人认为对于大小写敏感的Java和JS而言,使用 equals() 比 equalsIgnoreCase() 更好,改动的唯一风险就是向后兼容性的问题
        // 不过,相信开发者应该都是严格按照大小写敏感的方式进行属性设置的
        String[] fields = jsonType.includes();
        if (fields.length > 0) {
            for (int i = 0; i < fields.length; i++) {
                if (propertyName.equals(fields[i])) {
                    return false;
                }
            }
            return true;
        } else {
            fields = jsonType.ignores();
            for (int i = 0; i < fields.length; i++) {
                if (propertyName.equals(fields[i])) {
                    return true;
                }
            }
        }
    }

    if (clazz.getSuperclass() != Object.class && clazz.getSuperclass() != null) {
        if (isJSONTypeIgnore(clazz.getSuperclass(), propertyName)) {
            return true;
        }
    }

    return false;
}
项目:uavstack    文件:TypeUtils.java   
public static int getSerializeFeatures(Class<?> clazz) {
    JSONType annotation = clazz.getAnnotation(JSONType.class);

    if (annotation == null) {
        return 0;
    }

    return SerializerFeature.of(annotation.serialzeFeatures());
}
项目:uavstack    文件:TypeUtils.java   
public static int getParserFeatures(Class<?> clazz) {
    JSONType annotation = clazz.getAnnotation(JSONType.class);

    if (annotation == null) {
        return 0;
    }

    return Feature.of(annotation.parseFeatures());
}
项目:cartman    文件:TypeUtils.java   
public static int getSerializeFeatures(Class<?> clazz) {
    JSONType annotation = clazz.getAnnotation(JSONType.class);

    if (annotation == null) {
        return 0;
    }

    return SerializerFeature.of(annotation.serialzeFeatures());
}
项目:cartman    文件:TypeUtils.java   
public static int getParserFeatures(Class<?> clazz) {
    JSONType annotation = clazz.getAnnotation(JSONType.class);

    if (annotation == null) {
        return 0;
    }

    return Feature.of(annotation.parseFeatures());
}
项目:GitHub    文件:TypeUtils.java   
public static List<FieldInfo> computeGetters(Class<?> clazz, Map<String,String> aliasMap, boolean sorted){
    JSONType jsonType = TypeUtils.getAnnotation(clazz,JSONType.class);
    Map<String,Field> fieldCacheMap = new HashMap<String,Field>();
    ParserConfig.parserAllFieldToCache(clazz, fieldCacheMap);
    return computeGetters(clazz, jsonType, aliasMap, fieldCacheMap, sorted, PropertyNamingStrategy.CamelCase);
}
项目:GitHub    文件:JavaBeanInfo.java   
public static Class<?> getBuilderClass(JSONType type) {
    return getBuilderClass(null, type);
}
项目:boohee_v5.6    文件:TypeUtils.java   
public static JSONType getJSONType(Class<?> clazz) {
    return (JSONType) clazz.getAnnotation(JSONType.class);
}
项目:uavstack    文件:TypeUtils.java   
public static JSONType getJSONType(Class<?> clazz) {
    return clazz.getAnnotation(JSONType.class);
}
项目:cartman    文件:TypeUtils.java   
public static JSONType getJSONType(Class<?> clazz) {
    return clazz.getAnnotation(JSONType.class);
}