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 ofAbstractValidatorusing 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 SELFadd(AbstractValidator<? super V> validator)SELFadd(Validator<? super V> validator)PARENTand()Validator<? super V>build()Creates a new instance of the object to build.protected <T> List<Validator<? super T>>getValidators(ObjectValidatorBuilder<T,?,?> builder)SELFmandatory()Value ismandatory.SELFmax(String max)This method allows to define a maximum.SELFmin(String min)This method allows to define a minimum.abstract SELFrange(String min, String max)This method allows to define a range in a generic way.protected SELFself()
-
-
-
Method Detail
-
add
public SELF add(Validator<? super V> validator)
- Specified by:
addin interfaceValidatorRegistry<V,PARENT>- Parameters:
validator- theAbstractValidatorto 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
Listof validators.
-
self
protected SELF self()
- Returns:
- this build instance for fluent API calls.
-
add
public SELF add(AbstractValidator<? super V> validator)
- Parameters:
validator- theAbstractValidatorto 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 ornullfor no lower bound.max- the maximum value allowed ornullfor no upper bound.- Returns:
- this build instance for fluent API calls.
-
build
public Validator<? super V> build()
Description copied from interface:BuilderCreates a new instance of the object to build. If theBuilderis reused, any additional changes to theBuildershall NOT have any effect on instances previously returned by this method.- Specified by:
buildin interfaceBuilder<V>- Returns:
- the
AbstractValidator
-
-