com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion Java Examples

The following examples show how to use com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Results.java    From usergrid with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: Results.java    From usergrid with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: Results.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #4
Source File: JsonViewSerializer.java    From json-view with GNU General Public License v3.0 5 votes vote down vote up
boolean valueAllowed(AccessibleProperty property, Object value, Class cls) {
  Include defaultInclude = serializerProvider.getConfig() == null ? Include.ALWAYS : serializerProvider.getConfig().getSerializationInclusion();
  JsonInclude jsonInclude = getAnnotation(property, JsonInclude.class);
  JsonSerialize jsonSerialize = getAnnotation(cls, JsonSerialize.class);

  // Make sure local annotations win over global ones
  if(jsonInclude != null && jsonInclude.value() == Include.NON_NULL && value == null) {
    return false;
  }

  return value != null
      || (defaultInclude == Include.ALWAYS && jsonSerialize == null)
      || (jsonSerialize != null && jsonSerialize.include() == Inclusion.ALWAYS);
}
 
Example #5
Source File: JsonUtils.java    From uncode-dal-all with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 将对象转换成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;
}
 
Example #6
Source File: JsonUtils.java    From uncode-dal-all with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 通过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;
}
 
Example #7
Source File: Results.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public Set<String> getTypes() {
    if ( types != null ) {
        return types;
    }
    getEntityRefsByType("entity");
    if ( entitiesByType != null ) {
        types = entitiesByType.keySet();
    }
    else if ( refsByType != null ) {
        types = refsByType.keySet();
    }
    return types;
}
 
Example #8
Source File: Activity.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getEntityType() {
    return entityType;
}
 
Example #9
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
public String getCursor() {
    return cursor;
}
 
Example #10
Source File: Group.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getRoles() {
    return roles;
}
 
Example #11
Source File: User.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getRoles() {
    return roles;
}
 
Example #12
Source File: Activity.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String[] getDownstreamDuplicates() {
    return downstreamDuplicates;
}
 
Example #13
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getDescription() {
    return description;
}
 
Example #14
Source File: ApiResponse.java    From apigee-android-sdk with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getLast() {
	return last;
}
 
Example #15
Source File: Activity.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getUpdated() {
    return updated;
}
 
Example #16
Source File: User.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getEmail() {
    return email;
}
 
Example #17
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getAssets() {
    return assets;
}
 
Example #18
Source File: User.java    From usergrid with Apache License 2.0 4 votes vote down vote up
/** @return the deactivated */
@JsonSerialize(include = Inclusion.NON_NULL)
public Long getDeactivated() {
    return deactivated;
}
 
Example #19
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL  )
public List<Entity> getEntities() {
    return entities;
}
 
Example #20
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getRedirectUris() {
    return redirectUris;
}
 
Example #21
Source File: User.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getActivities() {
    return activities;
}
 
Example #22
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getEvents() {
    return events;
}
 
Example #23
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
@JsonProperty( "error_description" )
public String getErrorDescription() {
    return errorDescription;
}
 
Example #24
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getJavaScriptOrigins() {
    return javaScriptOrigins;
}
 
Example #25
Source File: Activity.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public ActivityObject[] getItems() {
    return items;
}
 
Example #26
Source File: Activity.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getId() {
    return id;
}
 
Example #27
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
public Map<String, List<String>> getParams() {
    return params;
}
 
Example #28
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonProperty("configuration")
@JsonSerialize( include = Inclusion.NON_NULL )
public OrganizationConfig getOrganizationConfig() {
    return organizationConfig;
}
 
Example #29
Source File: ApiResponse.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
public ClientCredentialsInfo getCredentials() {
    return credentials;
}
 
Example #30
Source File: Application.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getVersion() {
    return version;
}