Java 类com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion 实例源码

项目:report    文件:JsonMapper.java   
public JsonMapper(Inclusion inclusion, DateFormat df, boolean replaceNull) 
    {
        mapper = new ObjectMapper();
        // 设置输出时包含属性的风格
//      mapper.setSerializationInclusion(inclusion);
//      // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
//      mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//      // 禁止使用int代表Enum的order()來反序列化Enum
//      mapper.configure(DeserializationConfig.Feature.FAIL_ON_NUMBERS_FOR_ENUMS, true);
        // 允许单引号
        mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        mapper.setDateFormat(df);
        if (replaceNull) {
            // null 转换为 ""
            mapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() 
            {
                @Override
                public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException 
                {
                    jgen.writeString("");
                }

            });
        }
    }
项目:usergrid    文件:Results.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getId() {
    if ( id != null ) {
        return id;
    }
    if ( entity != null ) {
        id = entity.getUuid();
        return id;
    }
    if ( ( ids != null ) && ( ids.size() > 0 ) ) {
        id = ids.get( 0 );
        return id;
    }
    if ( ( entities != null ) && ( entities.size() > 0 ) ) {
        entity = entities.get( 0 );
        id = entity.getUuid();
        return id;
    }
    if ( ( refs != null ) && ( refs.size() > 0 ) ) {
        EntityRef ref = refs.get( 0 );
        id = ref.getUuid();
    }
    return id;
}
项目:usergrid    文件:Results.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public EntityRef getRef() {
    if ( ref != null ) {
        return ref;
    }
    ref = getEntity();
    if ( ref != null ) {
        return ref;
    }
    UUID u = getId();
    if ( u != null ) {
        String type= null;
        if(refs!=null && refs.size()>0){
            type = refs.get(0).getType();
        }
        return ref( type,u );
    }
    return null;
}
项目:report    文件:JsonResult.java   
/**
 * 返回日期处理成功结果
 * @param data 数据节点对象
 * @return JSON结果
 */
public static String success(Object data, String format)
{
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("code", GlobalResultStatus.SUCCESS.getCode());
    if (data != null)
    {
        map.put("data", data);
    }
    JsonMapper mapper = new JsonMapper(Inclusion.NON_NULL, new SimpleDateFormat(format));
    return mapper.toJson(map);
}
项目:json-view    文件:JsonViewSerializer.java   
boolean valueAllowed(Object value, Class cls) {
  return value != null
      || (serializerProvider.getConfig() != null
      && serializerProvider.getConfig().getSerializationInclusion() == Include.ALWAYS
      && getAnnotation(cls, JsonSerialize.class) == null)
      || (getAnnotation(cls, JsonSerialize.class) != null
      && readClassAnnotation(cls, JsonSerialize.class, "include") == Inclusion.ALWAYS);
}
项目:uncode-dal-all    文件:JsonUtils.java   
/**
 * 将对象转换成json, 可以设置输出属性
 *
 *
 * @param src 对象
 * @param inclusion 传入一个枚举值, 设置输出属性
 * @return 返回json字符串
 */
public static <T> String toJson(T src, Inclusion inclusion) {
    if (src instanceof String) {
        return (String) src;
    } else {
        ObjectMapper customMapper = generateMapper(inclusion);
        try {
            return customMapper.writeValueAsString(src);
        } catch (JsonProcessingException e) {
            LOG.error("JsonProcessingException: ", e);
        }
    }
    return null;
}
项目:uncode-dal-all    文件:JsonUtils.java   
/**
 * 通过Inclusion创建ObjectMapper对象
 *
 *
 * @param inclusion 传入一个枚举值, 设置输出属性
 * @return 返回ObjectMapper对象
 */
private static ObjectMapper generateMapper(Inclusion inclusion) {

    ObjectMapper customMapper = new ObjectMapper();
    // 所有日期格式都统一为以下样式
    customMapper.setDateFormat(new SimpleDateFormat(DATE_TIME_FORMAT));

    return customMapper;
}
项目:usergrid    文件:Results.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public Entity getEntity() {
    mergeEntitiesWithMetadata();
    if ( entity != null ) {
        return entity;
    }
    if ( ( entities != null ) && ( entities.size() > 0 ) ) {
        entity = entities.get( 0 );
        return entity;
    }
    return null;
}
项目:usergrid    文件:Results.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public Map<UUID, Entity> getEntitiesMap() {
    if ( entitiesMap != null ) {
        return entitiesMap;
    }
    if ( getEntities() != null ) {
        entitiesMap = new LinkedHashMap<UUID, Entity>();
        for ( Entity entity : getEntities() ) {
            entitiesMap.put( entity.getUuid(), entity );
        }
    }
    return entitiesMap;
}
项目:report    文件:JsonMapper.java   
public JsonMapper() 
{

    this(Inclusion.NON_NULL, null, false);
}
项目:report    文件:JsonMapper.java   
public JsonMapper(Inclusion inclusion) 
{
    this(inclusion, null, false);
}
项目:report    文件:JsonMapper.java   
public JsonMapper(Inclusion inclusion, DateFormat df)
{
    this(inclusion, df, false);
}
项目:report    文件:JsonMapper.java   
/**
 * 创建输出全部属性到Json字符串的Mapper.
 */
public static JsonMapper buildNormalMapper() 
{
    return new JsonMapper(Inclusion.ALWAYS);
}
项目:report    文件:JsonMapper.java   
/**
 * 创建只输出非空属性到Json字符串的Mapper.
 */
public static JsonMapper buildNonNullMapper() 
{
    return new JsonMapper(Inclusion.NON_NULL);
}
项目:report    文件:JsonMapper.java   
/**
 * 创建只输出初始值被改变的属性到Json字符串的Mapper.
 */
public static JsonMapper buildNonDefaultMapper() 
{
    return new JsonMapper(Inclusion.NON_DEFAULT);
}
项目:report    文件:JsonMapper.java   
/**
 * 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper.
 */
public static JsonMapper buildNonEmptyMapper() 
{
    return new JsonMapper(Inclusion.NON_EMPTY);
}
项目:report    文件:JsonResult.java   
/**
 * 报表返回格式日期处理成功结果
 * @param data 数据节点对象
 * @return JSON结果
 */
public static String reportSuccess(Object data, String format)
{
    JsonMapper mapper = new JsonMapper(Inclusion.NON_NULL, new SimpleDateFormat(format));
    return mapper.toJson(data);
}
项目:usergrid_android_sdk    文件:ApiResponse.java   
/**
   * Returns the OAuth token that was sent with the request
   *
   * @return the OAuth token
   */
@JsonProperty("access_token")
@JsonSerialize(include = Inclusion.NON_NULL)
public String getAccessToken() {
    return accessToken;
}
项目:usergrid_android_sdk    文件:ApiResponse.java   
/**
   * Returns the 'error_description' property of the response.
   *
   * @return the error description
   */
@JsonSerialize(include = Inclusion.NON_NULL)
@JsonProperty("error_description")
public String getErrorDescription() {
    return errorDescription;
}
项目:usergrid_android_sdk    文件:ApiResponse.java   
/**
   * Returns the 'error_uri' property of the response.
   *
   * @return the error URI
   */
@JsonSerialize(include = Inclusion.NON_NULL)
@JsonProperty("error_uri")
public String getErrorUri() {
    return errorUri;
}
项目:usergrid_android_sdk    文件:ApiResponse.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getLast() {
    return last;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getUser() {
    return user;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getGroup() {
    return group;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public String getCategory() {
    return category;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public String getName() {
    return name;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public List<AggregateCounter> getValues() {
    return values;
}
项目:usergrid_android_sdk    文件:AggregateCounterSet.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getQueue() {
    return queue;
}
项目:usergrid_android_sdk    文件:Message.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public Long getTimestamp() {
    return JsonUtils.getLongProperty(properties, PROPERTY_TIMESTAMP);
}
项目:usergrid_android_sdk    文件:Activity.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public String getCategory() {
    return category;
}
项目:hawkular-metrics    文件:TenantDefinition.java   
@ApiModelProperty("Retention settings for metrics, expressed in days")
@JsonProperty("retentions")
@JsonSerialize(include = Inclusion.NON_EMPTY, keyUsing = MetricTypeKeySerializer.class)
public Map<MetricType<?>, Integer> getRetentionSettings() {
    return retentionSettings;
}
项目:hawkular-metrics    文件:Metric.java   
@ApiModelProperty("Metric tags")
@JsonSerialize(include = Inclusion.NON_EMPTY)
public Map<String, String> getTags() {
    return tags;
}
项目:hawkular-metrics    文件:Metric.java   
@ApiModelProperty("Metric data points")
@JsonSerialize(include = Inclusion.NON_EMPTY)
public List<DataPoint<T>> getDataPoints() {
    return dataPoints;
}
项目:hawkular-metrics    文件:Metric.java   
@ApiModelProperty("Timestamp of the metric's oldest data point")
@JsonSerialize(include = Inclusion.NON_EMPTY)
public Long getMinTimestamp() {
    return minTimestamp;
}
项目:hawkular-metrics    文件:Metric.java   
@ApiModelProperty("Timestamp of the metric's most recent data point")
@JsonSerialize(include = Inclusion.NON_EMPTY)
public Long getMaxTimestamp() {
    return maxTimestamp;
}
项目:usergrid    文件:User.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public Boolean getDisabled() {
    return disabled;
}
项目:usergrid    文件:Activity.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public String getDisplayName() {
    return displayName;
}
项目:usergrid    文件:Role.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public Set<String> getPermissions() {
    return permissions;
}
项目:apigee-android-sdk    文件:ApiResponse.java   
/**
 * Returns the OAuth token that was sent with the request
 *
 * @return the OAuth token
 */
@JsonProperty("access_token")
@JsonSerialize(include = Inclusion.NON_NULL)
public String getAccessToken() {
    return accessToken;
}
项目:usergrid    文件:ApiResponse.java   
@JsonSerialize( include = Inclusion.NON_NULL )
@JsonProperty( "error_description" )
public String getErrorDescription() {
    return errorDescription;
}
项目:usergrid    文件:User.java   
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getActivities() {
    return activities;
}