public class CustomEnumDefinitionProvider extends Object implements CustomDefinitionProviderV2
CustomDefinitionProviderV2 interface for treating enum types as plain strings based on a JsonValue annotation
being present with value = true on exactly one argument-free method and/or JsonProperty annotations being present on all enum
constants. If no such annotations exist, no custom definition will be returned; thereby falling back on whatever is defined in a following custom
definition (e.g. from one of the standard generator Options).| Constructor and Description |
|---|
CustomEnumDefinitionProvider(boolean checkForJsonValueAnnotatedMethod,
boolean checkForJsonPropertyAnnotations)
Constructor indicating how to attempt to serialise enum constant values.
|
| Modifier and Type | Method and Description |
|---|---|
protected com.fasterxml.classmate.members.ResolvedMethod |
getJsonValueAnnotatedMethod(com.fasterxml.classmate.ResolvedType javaType,
SchemaGenerationContext context)
Look-up the single
JsonValue annotated method with value = true and no expected arguments. |
protected List<String> |
getSerializedValuesFromJsonProperty(com.fasterxml.classmate.ResolvedType javaType,
Object[] enumConstants)
Check whether the given type is an enum with at least one constant value and each enum constant value has a
JsonProperty annotation. |
protected List<Object> |
getSerializedValuesFromJsonValue(com.fasterxml.classmate.ResolvedType javaType,
Object[] enumConstants,
SchemaGenerationContext context)
Check whether the given type is an enum with at least one constant value and a single
JsonValue annotated method with
value = true and no expected arguments. |
CustomDefinition |
provideCustomSchemaDefinition(com.fasterxml.classmate.ResolvedType javaType,
SchemaGenerationContext context) |
public CustomEnumDefinitionProvider(boolean checkForJsonValueAnnotatedMethod,
boolean checkForJsonPropertyAnnotations)
true, the JsonValue
annotated method will take precedence over JsonProperty annotations.checkForJsonValueAnnotatedMethod - whether a single JsonValue annotated method should be invoked on each enum constant valuecheckForJsonPropertyAnnotations - whether each enum constant's JsonProperty annotation's value should be usedpublic CustomDefinition provideCustomSchemaDefinition(com.fasterxml.classmate.ResolvedType javaType, SchemaGenerationContext context)
provideCustomSchemaDefinition in interface CustomDefinitionProviderV2protected List<Object> getSerializedValuesFromJsonValue(com.fasterxml.classmate.ResolvedType javaType, Object[] enumConstants, SchemaGenerationContext context)
JsonValue annotated method with
value = true and no expected arguments.javaType - encountered type during schema generationenumConstants - non-empty array of enum constantscontext - current generation contextJsonValue annotated method for each enum constant (or null if the criteria are not met)protected com.fasterxml.classmate.members.ResolvedMethod getJsonValueAnnotatedMethod(com.fasterxml.classmate.ResolvedType javaType,
SchemaGenerationContext context)
JsonValue annotated method with value = true and no expected arguments.javaType - targeted type to look-up serialization method forcontext - generation context providing access to type resolution contextJsonValue annotationprotected List<String> getSerializedValuesFromJsonProperty(com.fasterxml.classmate.ResolvedType javaType, Object[] enumConstants)
JsonProperty annotation.javaType - encountered type during schema generationenumConstants - non-empty array of enum constantsJsonProperty.value() for each enum constant (or null if the criteria are not met)Copyright © 2021 VicTools. All rights reserved.