com.fasterxml.jackson.annotation.JsonSubTypes.Type Java Examples
The following examples show how to use
com.fasterxml.jackson.annotation.JsonSubTypes.Type.
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: OpenApiClientGenerator.java From spring-openapi with MIT License | 5 votes |
private void parseDiscriminator(TypeSpec.Builder typeSpecBuilder, Discriminator discriminator, String targetPackage, boolean generateDiscriminatorProperty) { if (discriminator.getPropertyName() != null) { AnnotationSpec.Builder annotationSpecBuilder = AnnotationSpec.builder(JsonTypeInfo.class) .addMember("use", "JsonTypeInfo.Id.NAME") .addMember("include", "JsonTypeInfo.As.PROPERTY") .addMember("property", "$S", discriminator.getPropertyName()); if (generateDiscriminatorProperty) { annotationSpecBuilder.addMember("visible", "true"); } typeSpecBuilder.addAnnotation(annotationSpecBuilder.build()); } if (discriminator.getMapping() != null) { List<AnnotationSpec> annotationSpecs = discriminator.getMapping().entrySet().stream() .map(discriminatorMappingEntry -> AnnotationSpec.builder(Type.class) .addMember("value", "$T.class", ClassName.get(targetPackage, discriminatorMappingEntry.getValue())) .addMember("name", "$S", discriminatorMappingEntry.getKey()) .build()) .collect(Collectors.toList()); AnnotationSpec jsonSubTypesAnnotation = AnnotationSpec.builder(JsonSubTypes.class) .addMember("value", wrapAnnotationsIntoArray(annotationSpecs)) .build(); typeSpecBuilder.addAnnotation(jsonSubTypesAnnotation); } }
Example #2
Source File: CustomBuilderDeserialize.java From immutables with Apache License 2.0 | 5 votes |
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME) @JsonSubTypes({ @Type(name = "I", value = Integer.class), @Type(name = "O", value = Double.class) }) // the annotation will be copied to a builder setter public abstract @Nullable Object value();
Example #3
Source File: IParameterDomain.java From AILibs with GNU Affero General Public License v3.0 | 4 votes |
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @Type(value = NumericParameterDomain.class, name = "numeric"), @Type(value = CategoricalParameterDomain.class, name = "categorical"), @Type(value = BooleanParameterDomain.class, name = "boolean") }) public boolean contains(Object item);
Example #4
Source File: DmfMultiActionRequest.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "topic", defaultImpl = DmfActionRequest.class) @JsonSubTypes({ @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD"), @Type(value = DmfDownloadAndUpdateRequest.class, name = "DOWNLOAD_AND_INSTALL") }) public void setAction(final DmfActionRequest action) { this.action = action; }