Class PojoGenerator
- java.lang.Object
-
- org.apache.johnzon.jsonschema.generator.PojoGenerator
-
public class PojoGenerator extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PojoGenerator.Attribute
static class
PojoGenerator.PojoConfiguration
static class
PojoGenerator.Ref
-
Field Summary
Fields Modifier and Type Field Description protected List<PojoGenerator.Attribute>
attributes
private PojoGenerator.PojoConfiguration
configuration
protected Set<String>
imports
private boolean
isEnum
protected Map<String,String>
nested
-
Constructor Summary
Constructors Constructor Description PojoGenerator(PojoGenerator.PojoConfiguration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
afterClassName()
protected String
afterEnumName(Map<String,String> values, boolean valuesAreInjected)
protected String
asType(String javaName, jakarta.json.JsonObject schema, boolean required)
protected String
beforeClassDeclaration()
protected String
beforeClassEnd()
protected String
beforeEnumDeclaration()
protected String
beforeEnumEnd()
private void
doEnum(jakarta.json.JsonValue enumList, String className)
protected String
enumImports()
protected String
enumName(String javaName, jakarta.json.JsonObject schema)
Map<String,String>
generate()
private static <T> T
getValueAs(jakarta.json.JsonObject schema, String attribute, Class<T> type)
protected boolean
isReserved(String name)
protected PojoGenerator
newSubPojoGenerator(PojoGenerator.PojoConfiguration pojoConfiguration, jakarta.json.JsonObject schema)
protected String
onEnum(String javaName, jakarta.json.JsonValue enumList, jakarta.json.JsonObject schema)
protected String
onItemSchema(String javaName, jakarta.json.JsonObject schema)
protected String
onObjectAttribute(String javaName, jakarta.json.JsonObject schema)
protected String
onRef(PojoGenerator.Ref ref)
PojoGenerator
setNested(Map<String,String> nested)
protected String
toCamelCase(String name)
protected String
toJavaName(String key)
private static <T> T
valueAs(jakarta.json.JsonObject schema, Class<T> type, jakarta.json.JsonValue value)
PojoGenerator
visitSchema(jakarta.json.JsonObject schema)
-
-
-
Field Detail
-
configuration
private final PojoGenerator.PojoConfiguration configuration
-
attributes
protected final List<PojoGenerator.Attribute> attributes
-
isEnum
private boolean isEnum
-
-
Constructor Detail
-
PojoGenerator
public PojoGenerator(PojoGenerator.PojoConfiguration configuration)
-
-
Method Detail
-
setNested
public PojoGenerator setNested(Map<String,String> nested)
-
visitSchema
public PojoGenerator visitSchema(jakarta.json.JsonObject schema)
-
onRef
protected String onRef(PojoGenerator.Ref ref)
- Parameters:
ref
- the reference to resolve.- Returns:
- the reference class name if resolved else null.
-
beforeEnumEnd
protected String beforeEnumEnd()
-
beforeClassEnd
protected String beforeClassEnd()
-
afterClassName
protected String afterClassName()
-
afterEnumName
protected String afterEnumName(Map<String,String> values, boolean valuesAreInjected)
- Parameters:
values
- the enum values (key is json name, value is java name).valuesAreInjected
- is there a toString() with json name or is the enum anemic (only values, no method)- Returns:
- the data to add after enum name and before the opening brace in enum declaration.
-
enumImports
protected String enumImports()
-
beforeEnumDeclaration
protected String beforeEnumDeclaration()
-
beforeClassDeclaration
protected String beforeClassDeclaration()
-
onEnum
protected String onEnum(String javaName, jakarta.json.JsonValue enumList, jakarta.json.JsonObject schema)
-
doEnum
private void doEnum(jakarta.json.JsonValue enumList, String className)
-
onObjectAttribute
protected String onObjectAttribute(String javaName, jakarta.json.JsonObject schema)
-
newSubPojoGenerator
protected PojoGenerator newSubPojoGenerator(PojoGenerator.PojoConfiguration pojoConfiguration, jakarta.json.JsonObject schema)
-
isReserved
protected boolean isReserved(String name)
-
getValueAs
private static <T> T getValueAs(jakarta.json.JsonObject schema, String attribute, Class<T> type)
-
valueAs
private static <T> T valueAs(jakarta.json.JsonObject schema, Class<T> type, jakarta.json.JsonValue value)
-
-