public class HttpPartSchema extends Object
The schema definition can be applied to any HTTP parts such as bodies, headers, query/form parameters, and URL path parts.
The API is generic enough to apply to any path part although some attributes may only applicable for certain parts.
Schema objects are created via builders instantiated through the create()
method.
This class is thread safe and reusable.
Modifier and Type | Field and Description |
---|---|
static HttpPartSchema |
DEFAULT
Reusable instance of this object, all default settings.
|
static HttpPartSchema |
T_ARRAY
Array type
|
static HttpPartSchema |
T_ARRAY_CSV
Comma-delimited array type
|
static HttpPartSchema |
T_ARRAY_MULTI
Multi-part array type
|
static HttpPartSchema |
T_ARRAY_PIPES
Pipe-delimited array type
|
static HttpPartSchema |
T_ARRAY_SSV
Space-delimited array type
|
static HttpPartSchema |
T_ARRAY_TSV
Tab-delimited array type
|
static HttpPartSchema |
T_ARRAY_UON
UON-formatted array type
|
static HttpPartSchema |
T_BINARY
Binary type
|
static HttpPartSchema |
T_BINARY_SPACED
Spaced binary type
|
static HttpPartSchema |
T_BOOLEAN
Boolean type
|
static HttpPartSchema |
T_BYTE
Byte type
|
static HttpPartSchema |
T_DATE
Date type
|
static HttpPartSchema |
T_DATETIME
Date-time type
|
static HttpPartSchema |
T_DOUBLE
Double type
|
static HttpPartSchema |
T_FILE
File type
|
static HttpPartSchema |
T_FLOAT
Float type
|
static HttpPartSchema |
T_INT32
Int32 type
|
static HttpPartSchema |
T_INT64
Int64 type
|
static HttpPartSchema |
T_INTEGER
Integer type
|
static HttpPartSchema |
T_NONE
No type
|
static HttpPartSchema |
T_NUMBER
Number type
|
static HttpPartSchema |
T_OBJECT
Object type
|
static HttpPartSchema |
T_OBJECT_CSV
Comma-delimited object type
|
static HttpPartSchema |
T_OBJECT_PIPES
Pipe-delimited object type
|
static HttpPartSchema |
T_OBJECT_SSV
Space-delimited object type
|
static HttpPartSchema |
T_OBJECT_TSV
Tab-delimited object type
|
static HttpPartSchema |
T_OBJECT_UON
UON-formated object type
|
static HttpPartSchema |
T_STRING
String type
|
static HttpPartSchema |
T_UON
UON-formated simple type
|
Modifier and Type | Method and Description |
---|---|
static HttpPartSchemaBuilder |
create()
Instantiates a new builder for this object.
|
static HttpPartSchema |
create(Annotation a)
Finds the schema information on the specified annotation.
|
static HttpPartSchema |
create(Annotation a,
String defaultName)
Finds the schema information on the specified annotation.
|
static HttpPartSchema |
create(Class<? extends Annotation> c,
Method m)
Finds the schema information for the specified method return.
|
static HttpPartSchema |
create(Class<? extends Annotation> c,
ParamInfo mpi)
Finds the schema information for the specified method parameter.
|
static HttpPartSchema |
create(Class<? extends Annotation> c,
Type t)
Finds the schema information for the specified class.
|
static HttpPartSchemaBuilder |
create(String type)
Shortcut for calling
|
static HttpPartSchemaBuilder |
create(String type,
String format)
Shortcut for calling
|
Integer |
getCode(Integer def)
Returns the first HTTP status code on a schema.
|
Set<Integer> |
getCodes()
Returns the HTTP status code or codes defined on a schema.
|
Set<Integer> |
getCodes(Integer def)
Returns the HTTP status code or codes defined on a schema.
|
HttpPartCollectionFormat |
getCollectionFormat()
Returns the
|
String |
getDefault()
Returns the
|
Set<String> |
getEnum()
Returns the
|
HttpPartFormat |
getFormat()
Returns the
|
HttpPartFormat |
getFormat(ClassMeta<?> cm)
Returns the
|
HttpPartSchema |
getItems()
Returns the
|
Number |
getMaximum()
Returns the
|
Long |
getMaxItems()
Returns the
|
Long |
getMaxLength()
Returns the
|
Long |
getMaxProperties()
Returns the
|
Number |
getMinimum()
Returns the
|
Long |
getMinItems()
Returns the
|
Long |
getMinLength()
Returns the
|
Long |
getMinProperties()
Returns the
|
Number |
getMultipleOf()
Returns the
|
String |
getName()
Returns the name of the object described by this schema, for example the query or form parameter name.
|
ClassMeta<?> |
getParsedType()
Returns the default parsed type for this schema.
|
Class<? extends HttpPartParser> |
getParser()
Returns the
|
Pattern |
getPattern()
Returns the
|
HttpPartSchema |
getProperty(String name)
Returns the schema information for the specified property.
|
Class<? extends HttpPartSerializer> |
getSerializer()
Returns the
|
HttpPartDataType |
getType()
Returns the
|
HttpPartDataType |
getType(ClassMeta<?> cm)
Returns the
|
boolean |
hasProperties()
Returns
|
boolean |
isAllowEmptyValue()
Returns the
|
boolean |
isExclusiveMaximum()
Returns the
|
boolean |
isExclusiveMinimum()
Returns the
|
boolean |
isRequired()
Returns the
|
boolean |
isSkipIfEmpty()
Returns the
|
boolean |
isUniqueItems()
Returns the
|
static HttpPartSchemaBuilder |
tArray()
Shortcut for
|
static HttpPartSchemaBuilder |
tArray(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayCsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayCsv(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayMulti()
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayMulti(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayPipes()
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayPipes(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArraySsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tArraySsv(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayTsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayTsv(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayUon()
Shortcut for
|
static HttpPartSchemaBuilder |
tArrayUon(HttpPartSchemaBuilder items)
Shortcut for
|
static HttpPartSchemaBuilder |
tBinary()
Shortcut for
|
static HttpPartSchemaBuilder |
tBinarySpaced()
Shortcut for
|
static HttpPartSchemaBuilder |
tBoolean()
Shortcut for
|
static HttpPartSchemaBuilder |
tByte()
Shortcut for
|
static HttpPartSchemaBuilder |
tDate()
Shortcut for
|
static HttpPartSchemaBuilder |
tDateTime()
Shortcut for
|
static HttpPartSchemaBuilder |
tDouble()
Shortcut for
|
static HttpPartSchemaBuilder |
tFile()
Shortcut for
|
static HttpPartSchemaBuilder |
tFloat()
Shortcut for
|
static HttpPartSchemaBuilder |
tInt32()
Shortcut for
|
static HttpPartSchemaBuilder |
tInt64()
Shortcut for
|
static HttpPartSchemaBuilder |
tInteger()
Shortcut for
|
static HttpPartSchemaBuilder |
tNone()
Shortcut for
|
static HttpPartSchemaBuilder |
tNumber()
Shortcut for
|
static HttpPartSchemaBuilder |
tObject()
Shortcut for
|
static HttpPartSchemaBuilder |
tObjectCsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tObjectPipes()
Shortcut for
|
static HttpPartSchemaBuilder |
tObjectSsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tObjectTsv()
Shortcut for
|
static HttpPartSchemaBuilder |
tObjectUon()
Shortcut for
|
String |
toString() |
static HttpPartSchemaBuilder |
tString()
Shortcut for
|
static HttpPartSchemaBuilder |
tUon()
Shortcut for
|
String |
validateInput(String in)
Throws a
ParseException if the specified pre-parsed input does not validate against this schema. |
<T> T |
validateOutput(T o,
BeanContext bc)
Throws a
ParseException if the specified parsed output does not validate against this schema. |
public static final HttpPartSchema DEFAULT
public static final HttpPartSchema T_BOOLEAN
public static final HttpPartSchema T_FILE
public static final HttpPartSchema T_INTEGER
public static final HttpPartSchema T_INT32
public static final HttpPartSchema T_INT64
public static final HttpPartSchema T_NONE
public static final HttpPartSchema T_NUMBER
public static final HttpPartSchema T_FLOAT
public static final HttpPartSchema T_DOUBLE
public static final HttpPartSchema T_STRING
public static final HttpPartSchema T_BYTE
public static final HttpPartSchema T_BINARY
public static final HttpPartSchema T_BINARY_SPACED
public static final HttpPartSchema T_DATE
public static final HttpPartSchema T_DATETIME
public static final HttpPartSchema T_UON
public static final HttpPartSchema T_ARRAY
public static final HttpPartSchema T_ARRAY_CSV
public static final HttpPartSchema T_ARRAY_PIPES
public static final HttpPartSchema T_ARRAY_SSV
public static final HttpPartSchema T_ARRAY_TSV
public static final HttpPartSchema T_ARRAY_UON
public static final HttpPartSchema T_ARRAY_MULTI
public static final HttpPartSchema T_OBJECT
public static final HttpPartSchema T_OBJECT_CSV
public static final HttpPartSchema T_OBJECT_PIPES
public static final HttpPartSchema T_OBJECT_SSV
public static final HttpPartSchema T_OBJECT_TSV
public static final HttpPartSchema T_OBJECT_UON
public static HttpPartSchemaBuilder create()
public static HttpPartSchemaBuilder tBoolean()
public static HttpPartSchemaBuilder tFile()
public static HttpPartSchemaBuilder tInteger()
public static HttpPartSchemaBuilder tInt32()
public static HttpPartSchemaBuilder tInt64()
public static HttpPartSchemaBuilder tNone()
public static HttpPartSchemaBuilder tNumber()
public static HttpPartSchemaBuilder tFloat()
public static HttpPartSchemaBuilder tDouble()
public static HttpPartSchemaBuilder tString()
public static HttpPartSchemaBuilder tByte()
public static HttpPartSchemaBuilder tBinary()
public static HttpPartSchemaBuilder tBinarySpaced()
public static HttpPartSchemaBuilder tDate()
public static HttpPartSchemaBuilder tDateTime()
public static HttpPartSchemaBuilder tUon()
public static HttpPartSchemaBuilder tArray()
public static HttpPartSchemaBuilder tArray(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArrayCsv()
public static HttpPartSchemaBuilder tArrayCsv(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArrayPipes()
public static HttpPartSchemaBuilder tArrayPipes(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArraySsv()
public static HttpPartSchemaBuilder tArraySsv(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArrayTsv()
public static HttpPartSchemaBuilder tArrayTsv(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArrayUon()
public static HttpPartSchemaBuilder tArrayUon(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tArrayMulti()
public static HttpPartSchemaBuilder tArrayMulti(HttpPartSchemaBuilder items)
items
- The schema of the array items.public static HttpPartSchemaBuilder tObject()
public static HttpPartSchemaBuilder tObjectCsv()
public static HttpPartSchemaBuilder tObjectPipes()
public static HttpPartSchemaBuilder tObjectSsv()
public static HttpPartSchemaBuilder tObjectTsv()
public static HttpPartSchemaBuilder tObjectUon()
public static HttpPartSchema create(Class<? extends Annotation> c, ParamInfo mpi)
This method will gather all the schema information from the annotations at the following locations:
c
- The annotation to look for.
mpi
- The Java method parameter.public static HttpPartSchema create(Class<? extends Annotation> c, Method m)
This method will gather all the schema information from the annotations at the following locations:
c
- The annotation to look for.
m
- The Java method with the return type being checked.public static HttpPartSchema create(Class<? extends Annotation> c, Type t)
This method will gather all the schema information from the annotations on the class and all parent classes/interfaces.
c
- The annotation to look for.
t
- The class containing the parameter.public static HttpPartSchemaBuilder create(String type)
type
- The schema type value.public static HttpPartSchemaBuilder create(String type, String format)
type
- The schema type value.format
- The schema format value.public static HttpPartSchema create(Annotation a)
a
- The annotation to find the schema information on..public static HttpPartSchema create(Annotation a, String defaultName)
a
- The annotation to find the schema information on..defaultName
- The default part name if not specified on the annotation.public ClassMeta<?> getParsedType()
public String getName()
HttpPartSchemaBuilder.name(String)
public Set<Integer> getCodes()
HttpPartSchemaBuilder.code(int)
,
HttpPartSchemaBuilder.codes(int[])
public Set<Integer> getCodes(Integer def)
def
- The default value if there are no codes defined.HttpPartSchemaBuilder.code(int)
,
HttpPartSchemaBuilder.codes(int[])
public Integer getCode(Integer def)
def
- The default value if there are no codes defined.HttpPartSchemaBuilder.code(int)
,
HttpPartSchemaBuilder.codes(int[])
public HttpPartDataType getType()
HttpPartSchemaBuilder.type(String)
public HttpPartDataType getType(ClassMeta<?> cm)
cm
- The class meta of the object.
HttpPartSchemaBuilder.format(String)
public String getDefault()
HttpPartSchemaBuilder._default(String)
public HttpPartCollectionFormat getCollectionFormat()
HttpPartSchemaBuilder.collectionFormat(String)
public HttpPartFormat getFormat()
HttpPartSchemaBuilder.format(String)
public HttpPartFormat getFormat(ClassMeta<?> cm)
cm
- The class meta of the object.
HttpPartSchemaBuilder.format(String)
public HttpPartSchema getItems()
HttpPartSchemaBuilder.items(HttpPartSchemaBuilder)
public Number getMaximum()
HttpPartSchemaBuilder.maximum(Number)
public Number getMinimum()
HttpPartSchemaBuilder.minimum(Number)
public Number getMultipleOf()
HttpPartSchemaBuilder.multipleOf(Number)
public Pattern getPattern()
HttpPartSchemaBuilder.pattern(String)
public Long getMaxLength()
HttpPartSchemaBuilder.maxLength(Long)
public Long getMinLength()
HttpPartSchemaBuilder.minLength(Long)
public Long getMaxItems()
HttpPartSchemaBuilder.maxItems(Long)
public Long getMinItems()
HttpPartSchemaBuilder.minItems(Long)
public Long getMaxProperties()
HttpPartSchemaBuilder.maxProperties(Long)
public Long getMinProperties()
HttpPartSchemaBuilder.minProperties(Long)
public boolean isExclusiveMaximum()
HttpPartSchemaBuilder.exclusiveMaximum(Boolean)
public boolean isExclusiveMinimum()
HttpPartSchemaBuilder.exclusiveMinimum(Boolean)
public boolean isUniqueItems()
HttpPartSchemaBuilder.uniqueItems(Boolean)
public boolean isRequired()
HttpPartSchemaBuilder.required(Boolean)
public boolean isSkipIfEmpty()
HttpPartSchemaBuilder.skipIfEmpty(Boolean)
public boolean isAllowEmptyValue()
HttpPartSchemaBuilder.skipIfEmpty(Boolean)
public Set<String> getEnum()
HttpPartSchemaBuilder._enum(Set)
public Class<? extends HttpPartParser> getParser()
HttpPartSchemaBuilder.parser(Class)
public Class<? extends HttpPartSerializer> getSerializer()
HttpPartSchemaBuilder.serializer(Class)
public String validateInput(String in) throws SchemaValidationException
ParseException
if the specified pre-parsed input does not validate against this schema.in
- The input.SchemaValidationException
- if the specified pre-parsed input does not validate against this schema.public <T> T validateOutput(T o, BeanContext bc) throws SchemaValidationException
ParseException
if the specified parsed output does not validate against this schema.o
- The parsed output.bc
- The bean context used to detect POJO types.SchemaValidationException
- if the specified parsed output does not validate against this schema.public HttpPartSchema getProperty(String name)
name
- The property name.public boolean hasProperties()
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.