Package com.networknt.schema.keyword
Class DiscriminatorState
java.lang.Object
com.networknt.schema.keyword.DiscriminatorState
Discriminator state for an instance location.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the discriminating value, which is the value in the payload corresponding with the property name.Gets the mapped schema which is the discriminating value mapped to the schema name or uri.Gets the matched schema $ref.Gets the property name defined in the discriminator keyword schema.booleanReturns true if the discriminating value is found in the payload corresponding to the property name.booleanReturns true if there was a schema that matched the discriminating value.booleanGets whether the mapping is explicit using the mappings on the discriminator keyword.booleanDetermines if there is a match of the mapped schema to the ref and update the matched schema if there is a match.voidsetDiscriminatingValue(String discriminatingValue) Sets the discriminating value, which is the value in the payload corresponding with the property name.voidsetExplicitMapping(boolean explicitMapping) Sets whether the mapping is explicit using the mappings on the discriminator keyword.voidsetMappedSchema(String mappedSchema) Sets the mapped schema which is the discriminating value mapped to the schema name or uri.voidsetMatchedSchema(String matchedSchema) Sets the matched schema $ref.voidsetPropertyName(String propertyName) Sets the property name defined in the discriminator keyword schema.
-
Constructor Details
-
DiscriminatorState
public DiscriminatorState()
-
-
Method Details
-
matches
Determines if there is a match of the mapped schema to the ref and update the matched schema if there is a match.- Parameters:
refSchema- the $ref value- Returns:
- true if there is a match
-
getPropertyName
Gets the property name defined in the discriminator keyword schema.- Returns:
-
setPropertyName
Sets the property name defined in the discriminator keyword schema.- Parameters:
propertyName- the property name
-
getDiscriminatingValue
Gets the discriminating value, which is the value in the payload corresponding with the property name.- Returns:
- the discriminating value
-
setDiscriminatingValue
Sets the discriminating value, which is the value in the payload corresponding with the property name.- Parameters:
discriminatingValue-
-
hasDiscriminatingValue
public boolean hasDiscriminatingValue()Returns true if the discriminating value is found in the payload corresponding to the property name.- Returns:
- true if the discriminating value is found in the payload corresponding to the property name
-
getMappedSchema
Gets the mapped schema which is the discriminating value mapped to the schema name or uri.- Returns:
- the mapped schema
-
setMappedSchema
Sets the mapped schema which is the discriminating value mapped to the schema name or uri.- Parameters:
mappedSchema- the mapped schema
-
isExplicitMapping
public boolean isExplicitMapping()Gets whether the mapping is explicit using the mappings on the discriminator keyword.- Returns:
- true if the mapping is explicitly mapped using mappings
-
setExplicitMapping
public void setExplicitMapping(boolean explicitMapping) Sets whether the mapping is explicit using the mappings on the discriminator keyword.- Parameters:
explicitMapping- true if explicitly mapped using mappings
-
setMatchedSchema
Sets the matched schema $ref.- Parameters:
matchedSchema- the matched schema $ref
-
getMatchedSchema
Gets the matched schema $ref.- Returns:
- the matched schema $ref
-
hasMatchedSchema
public boolean hasMatchedSchema()Returns true if there was a schema that matched the discriminating value.If the discriminating value does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail. Therefore if this returns false validation should fail.
- Returns:
- true if there was a schema that matched the discriminating value.
-