Package io.github.mmm.validation.main
Class ObjectValidatorBuilder<V,PARENT,SELF extends ObjectValidatorBuilder<V,PARENT,SELF>>
- java.lang.Object
-
- io.github.mmm.validation.main.ObjectValidatorBuilder<V,PARENT,SELF>
-
- Type Parameters:
V
- the generic type of the value tovalidate
.PARENT
- the generic type of theparent builder
.SELF
- the generic type of this builder itself (this).
- All Implemented Interfaces:
Builder<Validator<? super V>>
,ValidatorRegistry<V,SELF>
- Direct Known Subclasses:
CharSequenceValidatorBuilder
,ComparableValidatorBuilder
,ContainerValidatorBuilder
,ValidatorBuilderBoolean
,ValidatorBuilderObject
,ValidatorBuilderRange
public abstract class ObjectValidatorBuilder<V,PARENT,SELF extends ObjectValidatorBuilder<V,PARENT,SELF>> extends Object implements Builder<Validator<? super V>>, ValidatorRegistry<V,SELF>
This is the base class to create instances ofAbstractValidator
using the builder pattern.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description ObjectValidatorBuilder(PARENT parent)
The constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description SELF
add(AbstractValidator<? super V> validator)
SELF
add(Validator<? super V> validator)
PARENT
and()
Validator<? super V>
build()
Creates a new instance of the object to build.protected <T> List<Validator<? super T>>
getValidators(ObjectValidatorBuilder<T,?,?> builder)
SELF
mandatory()
Value ismandatory
.SELF
max(String max)
This method allows to define a maximum.SELF
min(String min)
This method allows to define a minimum.abstract SELF
range(String min, String max)
This method allows to define a range in a generic way.protected SELF
self()
-
-
-
Method Detail
-
add
public SELF add(Validator<? super V> validator)
- Specified by:
add
in interfaceValidatorRegistry<V,PARENT>
- Parameters:
validator
- theAbstractValidator
to add to this builder.- Returns:
- this build instance for fluent API calls.
-
getValidators
protected <T> List<Validator<? super T>> getValidators(ObjectValidatorBuilder<T,?,?> builder)
- Type Parameters:
T
- the generic type of the value tovalidate
.- Parameters:
builder
- theObjectValidatorBuilder
.- Returns:
- the
List
of validators.
-
self
protected SELF self()
- Returns:
- this build instance for fluent API calls.
-
add
public SELF add(AbstractValidator<? super V> validator)
- Parameters:
validator
- theAbstractValidator
to add to this builder.- Returns:
- this build instance for fluent API calls.
-
mandatory
public SELF mandatory()
Value ismandatory
.- Returns:
- this build instance for fluent API calls.
-
min
public SELF min(String min)
This method allows to define a minimum. Values exceeding this minimum will be invalid. Avoid usingmin(String)
andmax(String)
and userange(String, String)
in such case.- Parameters:
min
- the minimum value allowed.- Returns:
- this build instance for fluent API calls.
-
max
public SELF max(String max)
This method allows to define a maximum. Values exceeding this maximum will be invalid.- Parameters:
max
- the maximum value allowed.- Returns:
- this build instance for fluent API calls.
-
range
public abstract SELF range(String min, String max)
This method allows to define a range in a generic way. If you have a properly typed builder please use more specific methods such asComparableValidatorBuilder.range(io.github.mmm.base.range.Range)
instead.- Parameters:
min
- the minimum value allowed ornull
for no lower bound.max
- the maximum value allowed ornull
for no upper bound.- Returns:
- this build instance for fluent API calls.
-
build
public Validator<? super V> build()
Description copied from interface:Builder
Creates a new instance of the object to build. If theBuilder
is reused, any additional changes to theBuilder
shall NOT have any effect on instances previously returned by this method.- Specified by:
build
in interfaceBuilder<V>
- Returns:
- the
AbstractValidator
-
-