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 | Class and Description |
---|---|
static class |
HttpPartSchema.CollectionFormat
Valid values for the
collectionFormat field. |
static class |
HttpPartSchema.Format
Valid values for the
format field. |
static class |
HttpPartSchema.Type
Valid values for the
type field. |
Modifier and Type | Field and Description |
---|---|
static HttpPartSchema |
DEFAULT
Reusable instance of this object, all default settings.
|
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,
Method m,
int mi)
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
create().type(type); |
static HttpPartSchemaBuilder |
create(String type,
String format)
Shortcut for calling
create().type(type).format(format); |
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.
|
HttpPartSchema.CollectionFormat |
getCollectionFormat()
Returns the
collectionFormat field of this schema. |
String |
getDefault()
Returns the
default field of this schema. |
Set<String> |
getEnum()
Returns the
enum field of this schema. |
HttpPartSchema.Format |
getFormat()
Returns the
format field of this schema. |
HttpPartSchema.Format |
getFormat(ClassMeta<?> cm)
Returns the
format field of this schema. |
HttpPartSchema |
getItems()
Returns the
maximum field of this schema. |
Number |
getMaximum()
Returns the
maximum field of this schema. |
Long |
getMaxItems()
Returns the
xxx field of this schema. |
Long |
getMaxLength()
Returns the
xxx field of this schema. |
Long |
getMaxProperties()
Returns the
xxx field of this schema. |
Number |
getMinimum()
Returns the
minimum field of this schema. |
Long |
getMinItems()
Returns the
xxx field of this schema. |
Long |
getMinLength()
Returns the
xxx field of this schema. |
Long |
getMinProperties()
Returns the
xxx field of this schema. |
Number |
getMultipleOf()
Returns the
xxx field of this schema. |
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
parser field of this schema. |
Pattern |
getPattern()
Returns the
xxx field of this schema. |
HttpPartSchema |
getProperty(String name)
Returns the schema information for the specified property.
|
Class<? extends HttpPartSerializer> |
getSerializer()
Returns the
serializer field of this schema. |
HttpPartSchema.Type |
getType()
Returns the
type field of this schema. |
HttpPartSchema.Type |
getType(ClassMeta<?> cm)
Returns the
type field of this schema. |
boolean |
hasProperties()
Returns
|
boolean |
isAllowEmptyValue()
Returns the
allowEmptyValue field of this schema. |
boolean |
isExclusiveMaximum()
Returns the
exclusiveMaximum field of this schema. |
boolean |
isExclusiveMinimum()
Returns the
exclusiveMinimum field of this schema. |
boolean |
isRequired()
Returns the
required field of this schema. |
boolean |
isSkipIfEmpty()
Returns the
skipIfEmpty field of this schema. |
boolean |
isUniqueItems()
Returns the
uniqueItems field of this schema. |
String |
toString() |
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 HttpPartSchemaBuilder create()
public static HttpPartSchema create(Class<? extends Annotation> c, Method m, int mi)
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 containing the parameter.mi
- The index of the parameter on the method.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)
create().type(type);
type
- The schema type value.public static HttpPartSchemaBuilder create(String type, String format)
create().type(type).format(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 HttpPartSchema.Type getType()
type
field of this schema.type
field of this schema, or HttpPartSchemaBuilder.type(String)
public HttpPartSchema.Type getType(ClassMeta<?> cm)
type
field of this schema.cm
- The class meta of the object.
HttpPartSchemaBuilder.format(String)
public String getDefault()
default
field of this schema.HttpPartSchemaBuilder._default(String)
public HttpPartSchema.CollectionFormat getCollectionFormat()
collectionFormat
field of this schema.collectionFormat
field of this schema, or HttpPartSchemaBuilder.collectionFormat(String)
public HttpPartSchema.Format getFormat()
format
field of this schema.format
field of this schema, or HttpPartSchemaBuilder.format(String)
public HttpPartSchema.Format getFormat(ClassMeta<?> cm)
format
field of this schema.cm
- The class meta of the object.
format
field of this schema, or HttpPartSchemaBuilder.format(String)
public HttpPartSchema getItems()
maximum
field of this schema.HttpPartSchemaBuilder.items(HttpPartSchemaBuilder)
public Number getMaximum()
maximum
field of this schema.maximum
field of this schema, or HttpPartSchemaBuilder.maximum(Number)
public Number getMinimum()
minimum
field of this schema.minimum
field of this schema, or HttpPartSchemaBuilder.minimum(Number)
public Number getMultipleOf()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.multipleOf(Number)
public Pattern getPattern()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.pattern(String)
public Long getMaxLength()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.maxLength(Long)
public Long getMinLength()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.minLength(Long)
public Long getMaxItems()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.maxItems(Long)
public Long getMinItems()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.minItems(Long)
public Long getMaxProperties()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.maxProperties(Long)
public Long getMinProperties()
xxx
field of this schema.xxx
field of this schema, or HttpPartSchemaBuilder.minProperties(Long)
public boolean isExclusiveMaximum()
exclusiveMaximum
field of this schema.exclusiveMaximum
field of this schema.HttpPartSchemaBuilder.exclusiveMaximum(Boolean)
public boolean isExclusiveMinimum()
exclusiveMinimum
field of this schema.exclusiveMinimum
field of this schema.HttpPartSchemaBuilder.exclusiveMinimum(Boolean)
public boolean isUniqueItems()
uniqueItems
field of this schema.uniqueItems
field of this schema.HttpPartSchemaBuilder.uniqueItems(Boolean)
public boolean isRequired()
required
field of this schema.required
field of this schema.HttpPartSchemaBuilder.required(Boolean)
public boolean isSkipIfEmpty()
skipIfEmpty
field of this schema.skipIfEmpty
field of this schema.HttpPartSchemaBuilder.skipIfEmpty(Boolean)
public boolean isAllowEmptyValue()
allowEmptyValue
field of this schema.skipIfEmpty
field of this schema.HttpPartSchemaBuilder.skipIfEmpty(Boolean)
public Set<String> getEnum()
enum
field of this schema.enum
field of this schema, or HttpPartSchemaBuilder._enum(Set)
public Class<? extends HttpPartParser> getParser()
parser
field of this schema.parser
field of this schema, or HttpPartSchemaBuilder.parser(Class)
public Class<? extends HttpPartSerializer> getSerializer()
serializer
field of this schema.serializer
field of this schema, or 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 © 2018 Apache. All rights reserved.