S - the type of this builder's source object (eg. ConfigValueBuilder or ConstraintsBuilderT - the type of Constraint this builder should outputpublic class ConstraintsBuilder<S,T> extends AbstractConstraintsBuilder<S,T,T>
Constraints.
The constraints created by this builder consider constrained values as atomic, and do not allow the specification
of component-level constraints.
Settings with aggregate types, such as arrays and collections, should be created using AggregateConstraintsBuilder.
AggregateConstraintsBuildersource, sourceConstraints, type| Constructor and Description |
|---|
ConstraintsBuilder(S source,
java.util.List<Constraint<? super T>> constraints,
java.lang.Class<T> type)
Creates a new scalar constraint builder
|
| Modifier and Type | Method and Description |
|---|---|
ConstraintsBuilder<S,T> |
atLeast(T min)
Implies that any value must be bigger than or equal to
min |
ConstraintsBuilder<S,T> |
atMost(T max)
Implies that any value must be smaller than or equal to
max |
CompositeConstraintsBuilder<? extends ConstraintsBuilder<S,T>,T> |
composite(CompositeType type)
Creates a new
CompositeConstraintBuilder from this ConstraintsBuilder. |
S |
finish()
Finishes building constraints.
|
ConstraintsBuilder<S,T> |
maxLength(int max) |
ConstraintsBuilder<S,T> |
minLength(int min) |
ConstraintsBuilder<S,T> |
range(T min,
T max)
Convenience method to specify a range of valid values a number can take.
|
ConstraintsBuilder<S,T> |
regex(java.lang.String regexPattern) |
public ConstraintsBuilder(S source, java.util.List<Constraint<? super T>> constraints, java.lang.Class<T> type)
source - the ConfigValueBuilder this ConstraintsBuilder originates fromconstraints - the list of constraints this builder will add totype - the class of the type of values checked by constraints built by this builderpublic ConstraintsBuilder<S,T> atLeast(T min) throws RuntimeFiberException
AbstractConstraintsBuilderminatLeast in class AbstractConstraintsBuilder<S,T,T>min - The minimum valueRuntimeFiberExceptionpublic ConstraintsBuilder<S,T> atMost(T max)
AbstractConstraintsBuildermaxatMost in class AbstractConstraintsBuilder<S,T,T>max - The maximum valuepublic ConstraintsBuilder<S,T> range(T min, T max)
AbstractConstraintsBuilder This method behaves as if: this.atLeast(min).atMost(max)
range in class AbstractConstraintsBuilder<S,T,T>min - The minimum valuemax - The maximum valuepublic ConstraintsBuilder<S,T> minLength(int min)
minLength in class AbstractConstraintsBuilder<S,T,T>public ConstraintsBuilder<S,T> maxLength(int max)
maxLength in class AbstractConstraintsBuilder<S,T,T>public ConstraintsBuilder<S,T> regex(java.lang.String regexPattern)
regex in class AbstractConstraintsBuilder<S,T,T>public CompositeConstraintsBuilder<? extends ConstraintsBuilder<S,T>,T> composite(CompositeType type)
CompositeConstraintBuilder from this ConstraintsBuilder.
Composite constraints are constraints that have 0 or more child constraints.
Whether or not a value satisfies a composite constraint is specified by the composite's CompositeType.
type - the type of composite to createpublic S finish()
As a result of this call, the built constraints will be added to the source ConfigValue builder.