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
|
static class |
HttpPartSchema.Format
Valid values for the
|
static class |
HttpPartSchema.Type
Valid values for the
|
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,
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.
|
HttpPartSchema.CollectionFormat |
getCollectionFormat()
Returns the
|
String |
getDefault()
Returns the
|
Set<String> |
getEnum()
Returns the
|
HttpPartSchema.Format |
getFormat()
Returns the
|
HttpPartSchema.Format |
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
|
HttpPartSchema.Type |
getType()
Returns the
|
HttpPartSchema.Type |
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
|
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, 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 HttpPartSchema.Type getType()
HttpPartSchemaBuilder.type(String)
public HttpPartSchema.Type getType(ClassMeta<?> cm)
cm
- The class meta of the object.
HttpPartSchemaBuilder.format(String)
public String getDefault()
HttpPartSchemaBuilder._default(String)
public HttpPartSchema.CollectionFormat getCollectionFormat()
HttpPartSchemaBuilder.collectionFormat(String)
public HttpPartSchema.Format getFormat()
HttpPartSchemaBuilder.format(String)
public HttpPartSchema.Format 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–2019 The Apache Software Foundation. All rights reserved.