com.fasterxml.jackson.annotation.JsonInclude Java Examples

The following examples show how to use com.fasterxml.jackson.annotation.JsonInclude. 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: TypeHolderExample.java    From openapi-generator with Apache License 2.0 7 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 #2
Source File: SpspClientDefaults.java    From quilt with Apache License 2.0 6 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 #3
Source File: JacksonResourceFieldInformationProvider.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: EnumTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get enumString
 * @return enumString
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_ENUM_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public EnumStringEnum getEnumString() {
  return enumString;
}
 
Example #5
Source File: XmlItem.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get prefixNumber
 * @return prefixNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "1.234", value = "")
@JsonProperty(JSON_PROPERTY_PREFIX_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public BigDecimal getPrefixNumber() {
  return prefixNumber;
}
 
Example #6
Source File: AdditionalPropertiesObject.java    From openapi-generator with 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)
@JacksonXmlProperty(localName = "name")

public String getName() {
  return name;
}
 
Example #7
Source File: HCBatchOperations.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * @return {@code com.fasterxml.jackson.databind.ObjectWriter} to serialize {@link IndexRequest} instances
 */
// FIXME: design - wrap with Serializer(?) to allow other implementations
protected ObjectWriter configuredWriter() {
    return new ExtendedObjectMapper(new MappingJsonFactory())
            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
            .addMixIn(IndexRequest.class, IndexRequestMixIn.class)
            .writerFor(IndexRequest.class);
}
 
Example #8
Source File: XmlItem.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get namespaceString
 * @return namespaceString
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "string", value = "")
@JsonProperty(JSON_PROPERTY_NAMESPACE_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getNamespaceString() {
  return namespaceString;
}
 
Example #9
Source File: FormatTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get binary
 * @return binary
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_BINARY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public File getBinary() {
  return binary;
}
 
Example #10
Source File: Pet.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get tags
 * @return tags
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public List<Tag> getTags() {
  return tags;
}
 
Example #11
Source File: Pet.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get photoUrls
 * @return photoUrls
**/
@ApiModelProperty(required = true, value = "")
@JsonProperty(JSON_PROPERTY_PHOTO_URLS)
@JsonInclude(value = JsonInclude.Include.ALWAYS)

public Set<String> getPhotoUrls() {
  return photoUrls;
}
 
Example #12
Source File: XmlItem.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get namespaceString
 * @return namespaceString
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "string", value = "")
@JsonProperty(JSON_PROPERTY_NAMESPACE_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getNamespaceString() {
  return namespaceString;
}
 
Example #13
Source File: Zendesk.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public static ObjectMapper createMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
 
Example #14
Source File: XmlItem.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get namespaceNumber
 * @return namespaceNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "1.234", value = "")
@JsonProperty(JSON_PROPERTY_NAMESPACE_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public BigDecimal getNamespaceNumber() {
  return namespaceNumber;
}
 
Example #15
Source File: MapTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get mapMapOfString
 * @return mapMapOfString
**/
@javax.annotation.Nullable
@Valid
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_MAP_MAP_OF_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Map<String, Map<String, String>> getMapMapOfString() {
  return mapMapOfString;
}
 
Example #16
Source File: AdditionalPropertiesBoolean.java    From openapi-generator with 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 String getName() {
  return name;
}
 
Example #17
Source File: ModelReturn.java    From openapi-generator with 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 #18
Source File: Tag.java    From openapi-generator with 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 String getName() {
  return name;
}
 
Example #19
Source File: FormatTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get string
 * @return string
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getString() {
  return string;
}
 
Example #20
Source File: EnumArrays.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get justSymbol
 * @return justSymbol
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_JUST_SYMBOL)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public JustSymbolEnum getJustSymbol() {
  return justSymbol;
}
 
Example #21
Source File: Capitalization.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get scAETHFlowPoints
 * @return scAETHFlowPoints
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_SC_A_E_T_H_FLOW_POINTS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getScAETHFlowPoints() {
  return scAETHFlowPoints;
}
 
Example #22
Source File: Capitalization.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get capitalSnake
 * @return capitalSnake
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_CAPITAL_SNAKE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getCapitalSnake() {
  return capitalSnake;
}
 
Example #23
Source File: Capitalization.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get capitalSnake
 * @return capitalSnake
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_CAPITAL_SNAKE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public String getCapitalSnake() {
  return capitalSnake;
}
 
Example #24
Source File: Query.java    From simulacron with Apache License 2.0 5 votes vote down vote up
@JsonProperty("consistency_level")
@JsonInclude(NON_EMPTY)
public String[] getConsistency() {
  String[] consistency = new String[consistencyEnum.size()];
  for (int i = 0; i < consistencyEnum.size(); i++) {
    consistency[i] = consistencyEnum.get(i).toString();
  }
  return consistency;
}
 
Example #25
Source File: TestUtil.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
/**
 * Convert an object to JSON byte array.
 *
 * @param object
 *            the object to convert
 * @return the JSON byte array
 * @throws IOException
 */
public static byte[] convertObjectToJsonBytes(Object object)
        throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    JavaTimeModule module = new JavaTimeModule();
    mapper.registerModule(module);

    return mapper.writeValueAsBytes(object);
}
 
Example #26
Source File: FormatTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get integer
 * minimum: 10
 * maximum: 100
 * @return integer
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_INTEGER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Integer getInteger() {
  return integer;
}
 
Example #27
Source File: AdditionalPropertiesClass.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get mapMapString
 * @return mapMapString
**/
@javax.annotation.Nullable
@Valid
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_MAP_MAP_STRING)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Map<String, Map<String, String>> getMapMapString() {
  return mapMapString;
}
 
Example #28
Source File: Pet.java    From openapi-generator with 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 #29
Source File: OuterComposite.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Get myNumber
 * @return myNumber
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
@JsonProperty(JSON_PROPERTY_MY_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public BigDecimal getMyNumber() {
  return myNumber;
}
 
Example #30
Source File: User.java    From openapi-generator with 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;
}