当前位置: 首页>>代码示例>>Java>>正文


Java SerializerFeature.of方法代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.SerializerFeature.of方法的典型用法代码示例。如果您正苦于以下问题:Java SerializerFeature.of方法的具体用法?Java SerializerFeature.of怎么用?Java SerializerFeature.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.fastjson.serializer.SerializerFeature的用法示例。


在下文中一共展示了SerializerFeature.of方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSerializeFeatures

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public static int getSerializeFeatures(Class<?> clazz){
    JSONType annotation = TypeUtils.getAnnotation(clazz,JSONType.class);
    if(annotation == null){
        return 0;
    }
    return SerializerFeature.of(annotation.serialzeFeatures());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:TypeUtils.java

示例2: getSerializeFeatures

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public static int getSerializeFeatures(Class<?> clazz) {
    JSONType annotation = (JSONType) clazz.getAnnotation(JSONType.class);
    if (annotation == null) {
        return 0;
    }
    return SerializerFeature.of(annotation.serialzeFeatures());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:TypeUtils.java

示例3: getSerializeFeatures

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
public static int getSerializeFeatures(Class<?> clazz) {
    JSONType annotation = clazz.getAnnotation(JSONType.class);
    
    if (annotation == null) {
        return 0;
    }
    
    return SerializerFeature.of(annotation.serialzeFeatures());
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:10,代码来源:TypeUtils.java

示例4: computeFields

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
private static void computeFields(
        Class<?> clazz, //
        Map<String,String> aliasMap, //
        PropertyNamingStrategy propertyNamingStrategy, //
        Map<String,FieldInfo> fieldInfoMap, //
        Field[] fields){
    for(Field field : fields){
        if(Modifier.isStatic(field.getModifiers())){
            continue;
        }
        JSONField fieldAnnotation = field.getAnnotation(JSONField.class);
        int ordinal = 0, serialzeFeatures = 0, parserFeatures = 0;
        String propertyName = field.getName();
        String label = null;
        if(fieldAnnotation != null){
            if(!fieldAnnotation.serialize()){
                continue;
            }
            ordinal = fieldAnnotation.ordinal();
            serialzeFeatures = SerializerFeature.of(fieldAnnotation.serialzeFeatures());
            parserFeatures = Feature.of(fieldAnnotation.parseFeatures());
            if(fieldAnnotation.name().length() != 0){
                propertyName = fieldAnnotation.name();
            }
            if(fieldAnnotation.label().length() != 0){
                label = fieldAnnotation.label();
            }
        }
        if(aliasMap != null){
            propertyName = aliasMap.get(propertyName);
            if(propertyName == null){
                continue;
            }
        }
        if(propertyNamingStrategy != null){
            propertyName = propertyNamingStrategy.translate(propertyName);
        }
        if(!fieldInfoMap.containsKey(propertyName)){
            FieldInfo fieldInfo = new FieldInfo(propertyName, null, field, clazz, null, ordinal, serialzeFeatures, parserFeatures,
                    null, fieldAnnotation, label);
            fieldInfoMap.put(propertyName, fieldInfo);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:45,代码来源:TypeUtils.java

示例5: computeFields

import com.alibaba.fastjson.serializer.SerializerFeature; //导入方法依赖的package包/类
private static void computeFields(Class<?> clazz, Type type, PropertyNamingStrategy propertyNamingStrategy, List<FieldInfo> fieldList, Field[] fields) {
    for (Field field : fields) { // public static fields
        int modifiers = field.getModifiers();
        if ((modifiers & Modifier.STATIC) != 0) {
            continue;
        }

        if ((modifiers & Modifier.FINAL) != 0) {
            Class<?> fieldType = field.getType();
            boolean supportReadOnly = Map.class.isAssignableFrom(fieldType)
                    || Collection.class.isAssignableFrom(fieldType)
                    || AtomicLong.class.equals(fieldType) //
                    || AtomicInteger.class.equals(fieldType) //
                    || AtomicBoolean.class.equals(fieldType);
            if (!supportReadOnly) {
                continue;
            }
        }

        boolean contains = false;
        for (FieldInfo item : fieldList) {
            if (item.name.equals(field.getName())) {
                contains = true;
                break; // 已经是 contains = true,无需继续遍历
            }
        }

        if (contains) {
            continue;
        }

        int ordinal = 0, serialzeFeatures = 0, parserFeatures = 0;
        String propertyName = field.getName();

        JSONField fieldAnnotation = field.getAnnotation(JSONField.class);

        if (fieldAnnotation != null) {
            if (!fieldAnnotation.deserialize()) {
                continue;
            }

            ordinal = fieldAnnotation.ordinal();
            serialzeFeatures = SerializerFeature.of(fieldAnnotation.serialzeFeatures());
            parserFeatures = Feature.of(fieldAnnotation.parseFeatures());

            if (fieldAnnotation.name().length() != 0) {
                propertyName = fieldAnnotation.name();
            }
        }

        if (propertyNamingStrategy != null) {
            propertyName = propertyNamingStrategy.translate(propertyName);
        }

        add(fieldList, new FieldInfo(propertyName, null, field, clazz, type, ordinal, serialzeFeatures, parserFeatures, null,
                fieldAnnotation, null));
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:59,代码来源:JavaBeanInfo.java


注:本文中的com.alibaba.fastjson.serializer.SerializerFeature.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。