Java Code Examples for com.fasterxml.jackson.annotation.JsonInclude

The following examples show how to use com.fasterxml.jackson.annotation.JsonInclude. These examples are extracted from open source projects. 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
@Override
public Optional<JsonIncludeStrategy> getJsonIncludeStrategy(BeanAttributeInformation attributeDesc) {
	Optional<JsonInclude> includeAnnotation = attributeDesc.getAnnotation(JsonInclude.class);
	if (includeAnnotation.isPresent()) {
		JsonInclude.Include value = includeAnnotation.get().value();
		JsonIncludeStrategy strategy;
		if (NON_NULL.equals(value)) {
			strategy = JsonIncludeStrategy.NOT_NULL;
		}
		else if (JsonInclude.Include.NON_EMPTY.equals(value)) {
			strategy = JsonIncludeStrategy.NON_EMPTY;
		}
		else {
			strategy = JsonIncludeStrategy.DEFAULT;
		}
		return Optional.of(strategy);
	}
	return Optional.empty();
}
 
Example 2
Source Project: openapi-generator   Source File: User.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get firstName
 * @return firstName
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_FIRST_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getFirstName() {
  return firstName;
}
 
Example 3
Source Project: quilt   Source File: SpspClientDefaults.java    License: Apache License 2.0 5 votes vote down vote up
private static ObjectMapper defaultMapper() {
  final ObjectMapper objectMapper = JsonMapper.builder()
      .serializationInclusion(JsonInclude.Include.NON_EMPTY)
      .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
      .configure(JsonWriteFeature.WRITE_NUMBERS_AS_STRINGS, false)
      .build()
      .registerModule(new Jdk8Module())
      .registerModule(new InterledgerModule(Encoding.BASE64));
  objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
  objectMapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
  return objectMapper;
}
 
Example 4
Source Project: openapi-generator   Source File: InlineObject3.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * None
 * @return string
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "None")
@JsonProperty(JSON_PROPERTY_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getString() {
  return string;
}
 
Example 5
Source Project: openapi-generator   Source File: FormatTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get _byte
 * @return _byte
**/
@ApiModelProperty(required = true, value = "")
@JsonProperty(JSON_PROPERTY_BYTE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
@JacksonXmlProperty(localName = "byte")

public byte[] getByte() {
  return _byte;
}
 
Example 6
@Override
public JsonInclude.Value findPropertyInclusion(Annotated a)
{
    JsonInclude.Value v2 = _secondary.findPropertyInclusion(a);
    JsonInclude.Value v1 = _primary.findPropertyInclusion(a);

    if (v2 == null) { // shouldn't occur but
        return v1;
    }
    return v2.withOverrides(v1);
}
 
Example 7
Source Project: openapi-generator   Source File: TypeHolderExample.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get boolItem
 * @return boolItem
**/
@NotNull
@ApiModelProperty(example = "true", required = true, value = "")
@JsonProperty(JSON_PROPERTY_BOOL_ITEM)
@JsonInclude(value = JsonInclude.Include.ALWAYS)

public Boolean isBoolItem() {
  return boolItem;
}
 
Example 8
Source Project: openapi-generator   Source File: Pet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * pet status in the store
 * @return status
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "pet status in the store")
@JsonProperty(JSON_PROPERTY_STATUS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public StatusEnum getStatus() {
  return status;
}
 
Example 9
Source Project: openapi-generator   Source File: XmlItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get prefixNsNumber
 * @return prefixNsNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "1.234", value = "")
@JsonProperty(JSON_PROPERTY_PREFIX_NS_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public BigDecimal getPrefixNsNumber() {
  return prefixNsNumber;
}
 
Example 10
Source Project: openapi-generator   Source File: XmlItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get prefixString
 * @return prefixString
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "string", value = "")
@JsonProperty(JSON_PROPERTY_PREFIX_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getPrefixString() {
  return prefixString;
}
 
Example 11
/**
 * Get name
 * @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getName() {
  return name;
}
 
Example 12
Source Project: openapi-generator   Source File: DogAllOf.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get breed
 * @return breed
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_BREED)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getBreed() {
  return breed;
}
 
Example 13
Source Project: openapi-generator   Source File: Model200Response.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get propertyClass
 * @return propertyClass
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_PROPERTY_CLASS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getPropertyClass() {
  return propertyClass;
}
 
Example 14
Source Project: openapi-generator   Source File: ComplexQuadrilateral.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get shapeType
 * @return shapeType
**/
@ApiModelProperty(required = true, value = "")
@JsonProperty(JSON_PROPERTY_SHAPE_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)

public String getShapeType() {
  return shapeType;
}
 
Example 15
Source Project: openapi-generator   Source File: Capitalization.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get smallSnake
 * @return smallSnake
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_SMALL_SNAKE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getSmallSnake() {
  return smallSnake;
}
 
Example 16
Source Project: spring-boot-start-current   Source File: JsonUtils.java    License: Apache License 2.0 5 votes vote down vote up
private CustomizationObjectMapper (DateFormat dateFormat) {
	super();
	// 设置格式化
	setDateFormat( dateFormat );
	// <code>null<code> 不序列化
	setSerializationInclusion( JsonInclude.Include.NON_NULL );
	// 遇到未知属性,略过
	configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
}
 
Example 17
Source Project: openapi-generator   Source File: Model200Response.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get name
 * @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Integer getName() {
  return name;
}
 
Example 18
Source Project: openapi-generator   Source File: Pet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get photoUrls
 * @return photoUrls
**/
@NotNull
@ApiModelProperty(required = true, value = "")
@JsonProperty(JSON_PROPERTY_PHOTO_URLS)
@JsonInclude(value = JsonInclude.Include.ALWAYS)

public Set<String> getPhotoUrls() {
  return photoUrls;
}
 
Example 19
/**
 * Get mapMapAnytype
 * @return mapMapAnytype
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_MAP_MAP_ANYTYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Map<String, Map<String, Object>> getMapMapAnytype() {
  return mapMapAnytype;
}
 
Example 20
/**
 * Get mapBoolean
 * @return mapBoolean
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_MAP_BOOLEAN)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Map<String, Boolean> getMapBoolean() {
  return mapBoolean;
}
 
Example 21
Source Project: openapi-generator   Source File: Order.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get id
 * @return id
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Long getId() {
  return id;
}
 
Example 22
Source Project: openapi-generator   Source File: Model200Response.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get propertyClass
 * @return propertyClass
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_PROPERTY_CLASS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getPropertyClass() {
  return propertyClass;
}
 
Example 23
Source Project: openapi-generator   Source File: Order.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get id
 * @return id
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Long getId() {
  return id;
}
 
Example 24
Source Project: openapi-generator   Source File: User.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get password
 * @return password
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_PASSWORD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getPassword() {
  return password;
}
 
Example 25
Source Project: openapi-generator   Source File: ModelReturn.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get _return
 * @return _return
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_RETURN)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Integer getReturn() {
  return _return;
}
 
Example 26
Source Project: openapi-generator   Source File: User.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get password
 * @return password
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_PASSWORD)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getPassword() {
  return password;
}
 
Example 27
Source Project: openapi-generator   Source File: XmlItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get nameNumber
 * @return nameNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "1.234", value = "")
@JsonProperty(JSON_PROPERTY_NAME_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public BigDecimal getNameNumber() {
  return nameNumber;
}
 
Example 28
Source Project: openapi-generator   Source File: FormatTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get int64
 * @return int64
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_INT64)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Long getInt64() {
  return int64;
}
 
Example 29
Source Project: openapi-generator   Source File: FileSchemaTestClass.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get files
 * @return files
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_FILES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public List<java.io.File> getFiles() {
  return files;
}
 
Example 30
Source Project: lams   Source File: BasicSerializerFactory.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Helper method used for finding inclusion definitions for structured
 * container types like <code>Map</code>s and referential types
 * (like <code>AtomicReference</code>).
 *
 * @param contentType Declared full content type of container
 * @param configType Raw base type under which `configOverride`, if any, needs to be defined
 */
protected JsonInclude.Value _findInclusionWithContent(SerializerProvider prov,
        BeanDescription beanDesc,
        JavaType contentType, Class<?> configType)
    throws JsonMappingException
{
    final SerializationConfig config = prov.getConfig();

    // Defaulting gets complicated because we might have two distinct
    //   axis to consider: Container type itself , and then value (content) type.
    //  Start with Container-defaults, then use more-specific value override, if any.

    // Start by getting global setting, overridden by Map-type-override
    JsonInclude.Value inclV = beanDesc.findPropertyInclusion(config.getDefaultPropertyInclusion());
    inclV = config.getDefaultPropertyInclusion(configType, inclV);

    // and then merge content-type overrides, if any. But note that there's
    // content-to-value inclusion shift we have to do
    JsonInclude.Value valueIncl = config.getDefaultPropertyInclusion(contentType.getRawClass(), null);

    if (valueIncl != null) {
        switch (valueIncl.getValueInclusion()) {
        case USE_DEFAULTS:
            break;
        case CUSTOM:
            inclV = inclV.withContentFilter(valueIncl.getContentFilter());
            break;
        default:
            inclV = inclV.withContentInclusion(valueIncl.getValueInclusion());
        }
    }
    return inclV;
}