A
- The constraint annotation type.T
- The TemporalAccessor
type to validate.P
- The TemporalAccessor
type that describes the part to validate.public abstract class MomentPartValidator<A extends Annotation,T extends TemporalAccessor,P extends TemporalAccessor> extends PartValidator<A,T,P>
TemporalAccessor
validators that validate only a specific part of the value against a specific moment in time.
This class combined the functionality of both PartValidator
and MomentValueValidator
.Modifier and Type | Class and Description |
---|---|
static class |
MomentPartValidator.ForInstant<A extends Annotation,P extends TemporalAccessor>
The base for all
Instant validators that validate only a specific part of the value against a specific moment in time. |
static class |
MomentPartValidator.ForZonedDateTime<A extends Annotation,P extends TemporalAccessor>
The base for all
ZonedDateTime validators that validate only a specific part of the value against a specific moment in time. |
static class |
MomentPartValidator.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 against a specific moment in time. |
Modifier | Constructor and Description |
---|---|
protected |
MomentPartValidator(Function<A,String> momentExtractor,
Function<String,P> momentParser,
Function<Clock,P> momentCreator,
Function<A,String> durationExtractor,
BiFunction<P,TemporalAmount,P> durationApplier,
Function<A,String> zoneIdExtractor,
BiFunction<T,ZoneId,P> partExtractor,
BiPredicate<P,P> validPredicate)
Creates a new validator that only validates
TemporalAccessor parts against a specific duration before or after a specific moment in
time. |
protected |
MomentPartValidator(Function<A,String> momentExtractor,
Function<String,P> momentParser,
Function<Clock,P> momentCreator,
Function<A,String> durationExtractor,
BiFunction<P,TemporalAmount,P> durationApplier,
Function<A,String> zoneIdExtractor,
Function<T,P> partExtractor,
BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier,
Function<ZonedDateTime,P> zonedDateTimePartExtractor,
BiPredicate<P,P> validPredicate)
Creates a new validator that only validates
TemporalAccessor parts against a specific duration before or after a specific moment in
time. |
protected |
MomentPartValidator(Function<A,String> momentExtractor,
Function<String,P> momentParser,
Function<Clock,P> momentCreator,
Function<A,String> zoneIdExtractor,
BiFunction<T,ZoneId,P> partExtractor,
BiPredicate<P,P> validPredicate)
Creates a new validator that only validates
TemporalAccessor parts against a specific moment in time. |
protected |
MomentPartValidator(Function<A,String> momentExtractor,
Function<String,P> momentParser,
Function<Clock,P> momentCreator,
Function<A,String> zoneIdExtractor,
Function<T,P> partExtractor,
BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier,
Function<ZonedDateTime,P> zonedDateTimePartExtractor,
BiPredicate<P,P> validPredicate)
Creates a new validator that only validates
TemporalAccessor parts against a specific moment in time. |
initialize, isValid, minus, not, plus, useReplacementMessageTemplate
protected MomentPartValidator(Function<A,String> momentExtractor, Function<String,P> momentParser, Function<Clock,P> momentCreator, Function<A,String> zoneIdExtractor, BiFunction<T,ZoneId,P> partExtractor, BiPredicate<P,P> validPredicate)
TemporalAccessor
parts against a specific moment in time.momentExtractor
- A function that extracts the moment value from a constraint annotation.momentParser
- A function that parses a moment value into a TemporalAccessor
.momentCreator
- A function that creates a new moment for a given clock.zoneIdExtractor
- A function that extracts the zone id from a constraint annotation.partExtractor
- A function that extracts a part from a TemporalAccessor
.validPredicate
- A predicate that determines whether or not a value (the first argument) is valid compared to a specific moment
(the second argument).protected MomentPartValidator(Function<A,String> momentExtractor, Function<String,P> momentParser, Function<Clock,P> momentCreator, Function<A,String> durationExtractor, BiFunction<P,TemporalAmount,P> durationApplier, Function<A,String> zoneIdExtractor, BiFunction<T,ZoneId,P> partExtractor, BiPredicate<P,P> validPredicate)
TemporalAccessor
parts against a specific duration before or after a specific moment in
time.momentExtractor
- A function that extracts the moment value from a constraint annotation.momentParser
- A function that parses a moment value into a TemporalAccessor
.momentCreator
- A function that creates a new moment for a given clock.durationExtractor
- A function that extracts the duration value from a constraint annotation.durationApplier
- A function that applies a duration to a TemporalAccessor
.zoneIdExtractor
- A function that extracts the zone id from a constraint annotation.partExtractor
- A function that extracts a part from a TemporalAccessor
.validPredicate
- A predicate that determines whether or not a value (the first argument) is valid compared to a specific moment
(the second argument).protected MomentPartValidator(Function<A,String> momentExtractor, Function<String,P> momentParser, Function<Clock,P> momentCreator, Function<A,String> zoneIdExtractor, Function<T,P> partExtractor, BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier, Function<ZonedDateTime,P> zonedDateTimePartExtractor, BiPredicate<P,P> validPredicate)
TemporalAccessor
parts against a specific moment in time.
This constructor is a specialization of MomentPartValidator(Function, Function, Function, Function, BiFunction, BiPredicate)
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 MomentPartValidator.ForZonedDateTime
for ZonedDateTime
,
momentExtractor
- A function that extracts the moment value from a constraint annotation.momentParser
- A function that parses a moment value into a TemporalAccessor
.momentCreator
- A function that creates a new moment for a given clock.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
.validPredicate
- A predicate that determines whether or not a value (the first argument) is valid compared to a specific moment
(the second argument).protected MomentPartValidator(Function<A,String> momentExtractor, Function<String,P> momentParser, Function<Clock,P> momentCreator, Function<A,String> durationExtractor, BiFunction<P,TemporalAmount,P> durationApplier, Function<A,String> zoneIdExtractor, Function<T,P> partExtractor, BiFunction<T,ZoneId,ZonedDateTime> zoneIdApplier, Function<ZonedDateTime,P> zonedDateTimePartExtractor, BiPredicate<P,P> validPredicate)
TemporalAccessor
parts against a specific duration before or after a specific moment in
time.
This constructor is a specialization of
MomentPartValidator(Function, Function, Function, Function, BiFunction, Function, BiFunction, BiPredicate)
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 MomentPartValidator.ForZonedDateTime
for ZonedDateTime
,
momentExtractor
- A function that extracts the moment value from a constraint annotation.momentParser
- A function that parses a moment value into a TemporalAccessor
.momentCreator
- A function that creates a new moment for a given clock.durationExtractor
- A function that extracts the duration value from a constraint annotation.durationApplier
- A function that applies a duration to a TemporalAccessor
.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
.validPredicate
- A predicate that determines whether or not a value (the first argument) is valid compared to a specific moment
(the second argument).Copyright © 2021–2022. All rights reserved.