A
- The constraint annotation type.T
- The TemporalAccessor
type to validate.P
- The TemporalAccessor
type that describes the part to validate.public abstract class PartValidator<A extends Annotation,T extends TemporalAccessor,P extends TemporalAccessor> extends BaseValidator<A,T>
TemporalAccessor
validators that validate only a specific part of the value.Modifier and Type | Class and Description |
---|---|
static class |
PartValidator.ForInstant<A extends Annotation,P extends TemporalAccessor>
The base for all
Instant validators that validate only a specific part of the value. |
static class |
PartValidator.ForZonedDateTime<A extends Annotation,P extends TemporalAccessor>
The base for all
ZonedDateTime validators that validate only a specific part of the value. |
static class |
PartValidator.WithoutZoneId<A extends Annotation,T extends TemporalAccessor,P extends TemporalAccessor>
The base for all
TemporalAccessor validators that validate only a specific part of the value. |
Modifier | Constructor and Description |
---|---|
protected |
PartValidator(Function<A,String> zoneIdExtractor,
BiFunction<T,ZoneId,P> partExtractor,
Function<A,BiPredicate<P,ClockProvider>> partPredicateExtractor)
Creates a new validator.
|
protected |
PartValidator(Function<A,String> zoneIdExtractor,
Function<T,P> partExtractor,
BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier,
Function<ZonedDateTime,P> zonedDateTimePartExtractor,
Function<A,BiPredicate<P,ClockProvider>> partPredicateExtractor)
Creates a new validator.
|
initialize, isValid, minus, not, plus, useReplacementMessageTemplate
protected PartValidator(Function<A,String> zoneIdExtractor, BiFunction<T,ZoneId,P> partExtractor, Function<A,BiPredicate<P,ClockProvider>> partPredicateExtractor)
zoneIdExtractor
- A function that extracts the zone id from a constraint annotation.partExtractor
- A function that extracts a part from a TemporalAccessor
.partPredicateExtractor
- A function that extracts a part predicate from a constraint annotation.
This predicate will be called in BaseValidator.isValid(Object, ConstraintValidatorContext)
,
with as arguments the part extracted from the value to validate and the ClockProvider
returned by
ConstraintValidatorContext.getClockProvider()
.protected PartValidator(Function<A,String> zoneIdExtractor, Function<T,P> partExtractor, BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier, Function<ZonedDateTime,P> zonedDateTimePartExtractor, Function<A,BiPredicate<P,ClockProvider>> partPredicateExtractor)
This constructor is a specialization of PartValidator(Function, BiFunction, Function)
that uses a part extractor that does the
following:
return zoneId == null
? partExtractor.apply(value)
: zonedDateTimePartExtractor.apply(zoneIdApplier.apply(value, zoneId))
This can be used for types that use zones like OffsetDateTime
.
Note: to prevent duplicating arguments, use PartValidator.ForZonedDateTime
for ZonedDateTime
,
zoneIdExtractor
- A function that extracts the zone id from a constraint annotation.partExtractor
- A function that extracts a part directly from a TemporalAccessor
.zoneIdApplier
- A function that applies a zone id to a TemporalAccessor
, resulting in a ZonedDateTime
.
The result should represent the same instant.zonedDateTimePartExtractor
- A function that extracts the part from a ZonedDateTime
.partPredicateExtractor
- A function that extracts a part predicate from a constraint annotation.
This predicate will be called in BaseValidator.isValid(Object, ConstraintValidatorContext)
,
with as arguments the part extracted from the value to validate and the ClockProvider
returned by
ConstraintValidatorContext.getClockProvider()
.Copyright © 2021–2022. All rights reserved.