public interface Discriminator extends Constructible
When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.
Modifier and Type | Method and Description |
---|---|
Discriminator |
addMapping(java.lang.String name,
java.lang.String value)
Maps the given name to the given value and stores it in this Discriminator's mapping property.
|
java.util.Map<java.lang.String,java.lang.String> |
getMapping()
Returns the mapping property from a Discriminator instance.
|
java.lang.String |
getPropertyName()
Returns the propertyName property from a Discriminator instance.
|
default Discriminator |
mapping(java.util.Map<java.lang.String,java.lang.String> mapping)
Sets this Discriminator's mapping property to the given map object.
|
default Discriminator |
propertyName(java.lang.String propertyName)
Sets this Discriminator's propertyName property to the given string.
|
void |
removeMapping(java.lang.String name)
Remove the given name to the given value and stores it in this Discriminator's mapping property.
|
void |
setMapping(java.util.Map<java.lang.String,java.lang.String> mapping)
Sets this Discriminator's mapping property to the given map object.
|
void |
setPropertyName(java.lang.String propertyName)
Sets this Discriminator's propertyName property to the given propertyName.
|
default Discriminator propertyName(java.lang.String propertyName)
propertyName
- the name of the property in the payload that will hold the discriminator valuejava.lang.String getPropertyName()
void setPropertyName(java.lang.String propertyName)
propertyName
- the name of the property in the payload that will hold the discriminator valueDiscriminator addMapping(java.lang.String name, java.lang.String value)
name
- a key which will be compared to information from a request body or response payload.value
- a schema name or reference. null values will be rejected (implementation will throw an exception) or ignored.void removeMapping(java.lang.String name)
name
- a key which will be compared to information from a request body or response payload.default Discriminator mapping(java.util.Map<java.lang.String,java.lang.String> mapping)
mapping
- a map containing keys and schema names or referencesjava.util.Map<java.lang.String,java.lang.String> getMapping()
void setMapping(java.util.Map<java.lang.String,java.lang.String> mapping)
mapping
- a map containing keys and schema names or references