public final class KeywordFactory extends Object
KeywordValidator instances for a given
schema
This class is only called once the schemas has been deemed valid, that is, after the following is true:
SyntaxValidator).| Modifier and Type | Field and Description |
|---|---|
private Map<String,Class<? extends KeywordValidator>> |
validators
Our existing set of keyword validators
|
| Constructor and Description |
|---|
KeywordFactory(KeywordBundle bundle)
The only constructor
|
| Modifier and Type | Method and Description |
|---|---|
private static KeywordValidator |
buildValidator(Class<? extends KeywordValidator> c,
JsonNode schema)
Build one validator
|
Set<KeywordValidator> |
getValidators(JsonNode schema)
Return the set of validators for a particular schema
|
private static KeywordValidator |
invalidValidator(Class<? extends KeywordValidator> c,
Exception e)
Build an invalid validator in the event of instantiation failure
|
private final Map<String,Class<? extends KeywordValidator>> validators
public KeywordFactory(KeywordBundle bundle)
bundle - The keyword bundle to usepublic Set<KeywordValidator> getValidators(JsonNode schema)
schema - the schema as a JsonNodeprivate static KeywordValidator buildValidator(Class<? extends KeywordValidator> c, JsonNode schema)
This is done by reflection. Remember that the contract is to have a
constructor which takes a JsonNode as an argument.
If instantiation fails for whatever reason, an "invalid validator" is returned which always fails.
c - the keyword validator classschema - the schemainvalidValidator(Class, Exception)private static KeywordValidator invalidValidator(Class<? extends KeywordValidator> c, Exception e)
e - the exception raised by the instantiation attemptCopyright © 2012. All Rights Reserved.