public final class ArgumentConstraints extends Object
For example, this is how join describes its arguments:
public JoinFunction() {
super(
ArgumentConstraints.typeOf(JmesPathType.STRING),
ArgumentConstraints.arrayOf(ArgumentConstraints.typeOf(JmesPathType.STRING))
);
}
I.e. accept exactly two argument, where the first must be a string and the
second must be an array of strings.
The static methods of this class can be used to compose constraints for most
situations, but you can also create your own constraints (that can be combined
with other constraints) by implementing the ArgumentConstraint
interface.
| Modifier and Type | Method and Description |
|---|---|
static ArgumentConstraint |
anyValue()
Describes a single argument of any value.
|
static ArgumentConstraint |
arrayOf(ArgumentConstraint constraint)
Describes a single argument that is an array.
|
static ArgumentConstraint |
expression()
Describes a single expression argument.
|
static ArgumentConstraint |
listOf(ArgumentConstraint... constraints)
Describes a heterogeneous list of arguments.
|
static ArgumentConstraint |
listOf(int min,
ArgumentConstraint constraint)
Describes a homogeneous list of arguments without upper limit.
|
static ArgumentConstraint |
listOf(int min,
int max,
ArgumentConstraint constraint)
Describes a homogeneous list of arguments, of fixed or variable length.
|
static ArgumentConstraint |
typeOf(JmesPathType... types)
Describes a single argument that is of one of the specified value types.
|
static ArgumentConstraint |
typeOf(JmesPathType type)
Describes a single argument of a specified value type.
|
public static ArgumentConstraint listOf(ArgumentConstraint... constraints)
ArityException will be thrown when
the number of arguments does not exactly match the number of constraints.
May only be used as a top level constraint – and is already built in to
Function, so direct usage of this method should not be needed.
public static ArgumentConstraint listOf(int min, int max, ArgumentConstraint constraint)
ArityException will be thrown when there are fewer arguments
than the specified minimum arity, or when there are more arguments than
the specified maximum arity.
May only be used as a top level constraint.
public static ArgumentConstraint listOf(int min, ArgumentConstraint constraint)
ArityException will be thrown when there are fewer arguments
than the specified minimum arity.
May only be used as a top level constraint.
public static ArgumentConstraint anyValue()
ArgumentTypeException
will be thrown when the argument is an expression.public static ArgumentConstraint typeOf(JmesPathType type)
ArgumentTypeException
will be thrown when the argument is of the wrong type (as determined by
Adapter.typeOf(T)) or is an expression.public static ArgumentConstraint typeOf(JmesPathType... types)
ArgumentTypeException will be thrown when the argument is not of
one of the specified types (as determined by Adapter.typeOf(T))
or is an expression.public static ArgumentConstraint arrayOf(ArgumentConstraint constraint)
ArgumentTypeException
is thrown when the argument does not represent an array value.public static ArgumentConstraint expression()
ArgumentTypeException
will be thrown when the argument is not an expression.Copyright © 2016–2023. All rights reserved.