@PublicSpi public abstract class AbstractDirectiveConstraint extends java.lang.Object implements DirectiveConstraint
| Constructor and Description |
|---|
AbstractDirectiveConstraint(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
appliesTo(graphql.schema.GraphQLArgument argument,
graphql.schema.GraphQLFieldDefinition fieldDefinition,
graphql.schema.GraphQLFieldsContainer fieldsContainer)
This is called to work out if this rule applies to the argument of a specified field
|
boolean |
appliesTo(graphql.schema.GraphQLFieldDefinition fieldDefinition,
graphql.schema.GraphQLFieldsContainer fieldsContainer)
This is called to work out if this rule applies to a specified field
|
protected abstract boolean |
appliesToListElements() |
protected abstract boolean |
appliesToType(graphql.schema.GraphQLInputType inputType)
A derived class will be called to indicate whether this input type applies to the constraint
|
protected java.math.BigDecimal |
asBigDecimal(java.lang.Object value)
Makes the object a BigDecimal with an assertion if we have no conversion of it
|
protected boolean |
asBoolean(java.lang.Object value)
Makes the object a boolean with an assertion if we have no conversion of it
|
protected java.util.Map |
asMap(java.lang.Object value)
Casts the object as a Map with an assertion of it is not one
|
protected boolean |
getBoolArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
Returns an boolean argument from a directive (or its default) and throws an assertion of the argument is null
|
protected int |
getIntArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
Returns an integer argument from a directive (or its default) and throws an assertion of the argument is null
|
protected java.lang.String |
getMessageTemplate() |
protected java.lang.String |
getMessageTemplate(graphql.schema.GraphQLAppliedDirective directive)
Returns the "message : String" argument from a directive or makes up one
called "graphql.validation.{name}.message"
|
java.lang.String |
getName() |
protected java.lang.String |
getStrArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
Returns an String argument from a directive (or its default) and throws an assertion of the argument is null
|
protected int |
getStringOrIDOrObjectOrMapLength(graphql.schema.GraphQLInputType inputType,
java.lang.Object value)
Returns the length of a String, ID, size of a list or size of a Map
|
protected boolean |
isMap(graphql.schema.GraphQLInputType inputType) |
protected boolean |
isOneOfTheseTypes(graphql.schema.GraphQLInputType inputType,
java.util.Collection<graphql.schema.GraphQLScalarType> scalarTypes)
Returns true of the input type is one of the specified scalar types, regardless of non null ness
|
protected boolean |
isOneOfTheseTypes(graphql.schema.GraphQLInputType inputType,
graphql.schema.GraphQLScalarType... scalarTypes) |
protected boolean |
isStringOrID(graphql.schema.GraphQLInputType inputType)
Return true if the type is a String or ID
|
protected boolean |
isStringOrIDOrList(graphql.schema.GraphQLInputType inputType)
Return true if the type is a String or ID or List type, regardless of non null ness
|
protected boolean |
isStringOrIDOrListOrMap(graphql.schema.GraphQLInputType inputType)
Return true if the type is a String or ID or List type or
GraphQLInputObjectType, regardless of non null ness |
protected java.util.List<graphql.GraphQLError> |
mkError(ValidationEnvironment validationEnvironment,
graphql.schema.GraphQLAppliedDirective directive,
java.util.Map<java.lang.String,java.lang.Object> msgParams)
Creates a new
GraphQLError |
protected java.util.List<graphql.GraphQLError> |
mkError(ValidationEnvironment validationEnvironment,
java.lang.Object... messageParameters) |
protected java.util.Map<java.lang.String,java.lang.Object> |
mkMessageParams(java.lang.Object validatedValue,
ValidationEnvironment validationEnvironment,
java.lang.Object... args)
Creates a map of named parameters for message interpolation
|
protected abstract java.util.List<graphql.GraphQLError> |
runConstraint(ValidationEnvironment validationEnvironment)
This is called to perform the constraint validation
|
java.util.List<graphql.GraphQLError> |
runValidation(ValidationEnvironment validationEnvironment)
This is called to runs the rule.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDocumentationpublic AbstractDirectiveConstraint(java.lang.String name)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getName()
getName in interface DirectiveConstraintprotected java.lang.String getMessageTemplate()
public boolean appliesTo(graphql.schema.GraphQLFieldDefinition fieldDefinition,
graphql.schema.GraphQLFieldsContainer fieldsContainer)
ValidationRuleappliesTo in interface ValidationRulefieldDefinition - the field to checkfieldsContainer - the field containerpublic boolean appliesTo(graphql.schema.GraphQLArgument argument,
graphql.schema.GraphQLFieldDefinition fieldDefinition,
graphql.schema.GraphQLFieldsContainer fieldsContainer)
ValidationRuleappliesTo in interface ValidationRuleargument - the argument to checkfieldDefinition - the field to checkfieldsContainer - the field containerprotected abstract boolean appliesToType(graphql.schema.GraphQLInputType inputType)
inputType - the input typeprotected abstract java.util.List<graphql.GraphQLError> runConstraint(ValidationEnvironment validationEnvironment)
validationEnvironment - the validation environmentpublic java.util.List<graphql.GraphQLError> runValidation(ValidationEnvironment validationEnvironment)
ValidationRuleGraphQLInputObjectType then it will be invoked for each attribute of that
type.
A rule should consult ValidationEnvironment.getValidatedElement() to check
what element is being validated. If the rule does not handle that type of element,
simply return an empty list of errors.
runValidation in interface ValidationRulevalidationEnvironment - the validation environmentprotected abstract boolean appliesToListElements()
protected boolean isOneOfTheseTypes(graphql.schema.GraphQLInputType inputType,
graphql.schema.GraphQLScalarType... scalarTypes)
protected boolean isOneOfTheseTypes(graphql.schema.GraphQLInputType inputType,
java.util.Collection<graphql.schema.GraphQLScalarType> scalarTypes)
inputType - the type to checkscalarTypes - the array of scalar typesprotected int getIntArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
directive - the directive to checkargName - the argument nameprotected java.lang.String getStrArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
directive - the directive to checkargName - the argument nameprotected boolean getBoolArg(graphql.schema.GraphQLAppliedDirective directive,
java.lang.String argName)
directive - the directive to checkargName - the argument nameprotected java.lang.String getMessageTemplate(graphql.schema.GraphQLAppliedDirective directive)
directive - the directive to checkprotected java.util.Map<java.lang.String,java.lang.Object> mkMessageParams(java.lang.Object validatedValue,
ValidationEnvironment validationEnvironment,
java.lang.Object... args)
validatedValue - the value being validatedvalidationEnvironment - the validation environmentargs - must be an key / value array with String keys as the even params and values as then odd paramsprotected java.util.List<graphql.GraphQLError> mkError(ValidationEnvironment validationEnvironment, graphql.schema.GraphQLAppliedDirective directive, java.util.Map<java.lang.String,java.lang.Object> msgParams)
GraphQLErrorvalidationEnvironment - the current validation environmentdirective - the directive being runmsgParams - the map of parametersprotected java.util.List<graphql.GraphQLError> mkError(ValidationEnvironment validationEnvironment, java.lang.Object... messageParameters)
protected boolean isStringOrIDOrList(graphql.schema.GraphQLInputType inputType)
inputType - the type to checkprotected boolean isStringOrIDOrListOrMap(graphql.schema.GraphQLInputType inputType)
GraphQLInputObjectType, regardless of non null nessinputType - the type to checkprotected boolean isMap(graphql.schema.GraphQLInputType inputType)
protected boolean isStringOrID(graphql.schema.GraphQLInputType inputType)
inputType - the type to checkprotected java.util.Map asMap(java.lang.Object value)
value - the object to turn into a mapprotected java.math.BigDecimal asBigDecimal(java.lang.Object value)
throws java.lang.NumberFormatException
value - the object to turn into a BigDecimaljava.lang.NumberFormatExceptionprotected boolean asBoolean(java.lang.Object value)
value - the boolean objectprotected int getStringOrIDOrObjectOrMapLength(graphql.schema.GraphQLInputType inputType,
java.lang.Object value)
inputType - the input typevalue - the value