![JAR search and dependency download from the Maven repository](/logo.png)
fr.landel.utils.assertor.predicate.PredicateAssertorStepDate Maven / Gradle / Ivy
/*-
* #%L
* utils-assertor
* %%
* Copyright (C) 2016 - 2018 Gilles Landel
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package fr.landel.utils.assertor.predicate;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import fr.landel.utils.assertor.StepAssertor;
import fr.landel.utils.assertor.commons.MessageAssertor;
import fr.landel.utils.assertor.helper.HelperStep;
import fr.landel.utils.assertor.utils.AssertorDate;
/**
* This class define methods that can be applied on the checked {@link Date}
* object. To provide a result, it's also provide a chain builder by returning a
* {@link PredicateStepDate}. The chain looks like:
*
*
* {@link PredicateAssertorStepDate} > {@link PredicateStepDate} > {@link PredicateAssertorStepDate} > {@link PredicateStepDate}...
*
*
* This chain always starts with a {@link PredicateAssertorStepDate} and ends
* with {@link PredicateStepDate}.
*
* @since Aug 3, 2016
* @author Gilles
*
*/
@FunctionalInterface
public interface PredicateAssertorStepDate extends PredicateAssertorStep {
/**
* {@inheritDoc}
*/
@Override
default PredicateStepDate get(final StepAssertor result) {
return () -> result;
}
/**
* {@inheritDoc}
*/
@Override
default PredicateAssertorStepDate not() {
return () -> HelperStep.not(getStep());
}
/**
* Check if the checked {@link Date} is equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isEqual(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isEqual(final Date date) {
return this.isEqual(date, null);
}
/**
* Check if the checked {@link Date} is equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isEqual(date2, "not equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isEqual(final Date date, final CharSequence message, final Object... arguments) {
return this.isEqual(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isEqual(date2, Locale.US, "not equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isEqual(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isEqual(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is NOT equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isNotEqual(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isNotEqual(final Date date) {
return this.isNotEqual(date, null);
}
/**
* Check if the checked {@link Date} is NOT equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isNotEqual(date2, "not equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isNotEqual(final Date date, final CharSequence message, final Object... arguments) {
return this.isNotEqual(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is NOT equal to the {@code date}.
*
*
* precondition: none
*
*
*
* Assertor.that(date).isNotEqual(date2, Locale.US, "not equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isNotEqual(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isNotEqual(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAround(date2, Calendar.DAY_OF_YEAR, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isAround(final Date date, final int calendarField, final int calendarAmount) {
return this.isAround(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAround(date2, Calendar.DAY_OF_YEAR, 1, "not around").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAround(final Date date, final int calendarField, final int calendarAmount, final CharSequence message,
final Object... arguments) {
return this.isAround(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAround(date2, Calendar.DAY_OF_YEAR, 1, Locale.US, "not around").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAround(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isAround(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is NOT around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isNotEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isNotAround(date2, Calendar.DAY_OF_YEAR, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isNotAround(final Date date, final int calendarField, final int calendarAmount) {
return this.isNotAround(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is NOT around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isNotEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isNotAround(date2, Calendar.DAY_OF_YEAR, 1, "must not be around").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isNotAround(final Date date, final int calendarField, final int calendarAmount, final CharSequence message,
final Object... arguments) {
return this.isNotAround(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is NOT around the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isNotEqual}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isNotAround(date2, Calendar.DAY_OF_YEAR, 1, Locale.US, "must not be around").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isNotAround(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isNotAround(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is between the {@code dateStart} and
* {@code dateEnd}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBetween(date1, date2).orElseThrow();
*
*
* @param dateStart
* the start date to compare
* @param dateEnd
* the end date to compare
* @return the assertor step
*/
default PredicateStepDate isBetween(final Date dateStart, final Date dateEnd) {
return this.isBetween(dateStart, dateEnd, null);
}
/**
* Check if the checked {@link Date} is between the {@code dateStart} and
* {@code dateEnd}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBetween(date1, date2, "Not between dates").orElseThrow();
*
*
* @param dateStart
* the start date to compare
* @param dateEnd
* the end date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBetween(final Date dateStart, final Date dateEnd, final CharSequence message, final Object... arguments) {
return this.isBetween(dateStart, dateEnd, null, message, arguments);
}
/**
* Check if the checked {@link Date} is between the {@code dateStart} and
* {@code dateEnd}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBetween(date1, date2, Locale.US, "Not between dates").orElseThrow();
*
*
* @param dateStart
* the start date to compare
* @param dateEnd
* the end date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBetween(final Date dateStart, final Date dateEnd, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorDate.isBetween(this.getStep(), dateStart, dateEnd, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isAfter(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date) {
return this.isAfter(date, null);
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isAfter(date2, "not after").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date, final CharSequence message, final Object... arguments) {
return this.isAfter(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isAfter(date2, Locale.US, "not after").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isAfter(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfter(Date)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfter(date2, Calendar.MONTH, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date, final int calendarField, final int calendarAmount) {
return this.isAfter(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfter(Date, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfter(date2, Calendar.MONTH, 1, "not after").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date, final int calendarField, final int calendarAmount, final CharSequence message,
final Object... arguments) {
return this.isAfter(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is after the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfter(Date, Locale, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfter(date2, Calendar.MONTH, 1, Locale.US, "not after").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfter(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isAfter(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* precondition: neither can be {@code null}
*
*
*
* Assertor.that(date).isAfterOrEqual(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date) {
return this.isAfterOrEqual(date, null);
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* precondition: neither can be {@code null}
*
*
*
* Assertor.that(date).isAfterOrEqual(date2, "not after or equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date, final CharSequence message, final Object... arguments) {
return this.isAfterOrEqual(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* precondition: neither can be {@code null}
*
*
*
* Assertor.that(date).isAfterOrEqual(date2, Locale.US, "not after or equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isAfterOrEqual(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfterOrEqual(Date)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfterOrEqual(date2, Calendar.MONTH, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date, final int calendarField, final int calendarAmount) {
return this.isAfterOrEqual(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfterOrEqual(Date, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfterOrEqual(date2, Calendar.MONTH, 1, "not after or equal").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date, final int calendarField, final int calendarAmount, final CharSequence message,
final Object... arguments) {
return this.isAfterOrEqual(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is after or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isAfterOrEqual(Date, Locale, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isAfterOrEqual(date2, Calendar.MONTH, 1, Locale.US, "not after or equal").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isAfterOrEqual(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isAfterOrEqual(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBefore(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date) {
return this.isBefore(date, null);
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBefore(date2, "not before").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date, final CharSequence message, final Object... arguments) {
return this.isBefore(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBefore(date2, Locale.US, "not before").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isBefore(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBefore(Date)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBefore(date2, Calendar.MONTH, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date, final int calendarField, final int calendarAmount) {
return this.isBefore(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBefore(Date, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBefore(date2, Calendar.MONTH, 1, "not before").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date, final int calendarField, final int calendarAmount, final CharSequence message,
final Object... arguments) {
return this.isBefore(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is before to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBefore(Date, Locale, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBefore(date2, Calendar.MONTH, 1, Locale.US, "not before").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBefore(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isBefore(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2).orElseThrow();
*
*
* @param date
* the date to compare
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date) {
return this.isBeforeOrEqual(date, null);
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2, "not before or equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date, final CharSequence message, final Object... arguments) {
return this.isBeforeOrEqual(date, null, message, arguments);
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* precondition: neither dates can be {@code null}
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2, Locale.US, "not before or equal").orElseThrow();
*
*
* @param date
* the date to compare
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isBeforeOrEqual(this.getStep(), date, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBeforeOrEqual(Date)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2, Calendar.MONTH, 1).orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date, final int calendarField, final int calendarAmount) {
return this.isBeforeOrEqual(date, calendarField, calendarAmount, null);
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBeforeOrEqual(Date, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2, Calendar.MONTH, 1, "not before or equal").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date, final int calendarField, final int calendarAmount,
final CharSequence message, final Object... arguments) {
return this.isBeforeOrEqual(date, calendarField, calendarAmount, null, message, arguments);
}
/**
* Check if the checked {@link Date} is before or equal to the {@code date}.
*
*
* If the {@code calendarField} is equal to -1, the method does exactly the
* same as {@link #isBeforeOrEqual(Date, Locale, CharSequence, Object...)}.
*
*
*
* precondition: if {@code calendarField} is not equal to -1. Neither dates
* can be {@code null}, the {@code calendarField} must be a valid field and
* the {@code calendarAmount} cannot be equal to zero.
*
*
*
* Assertor.that(date).isBeforeOrEqual(date2, Calendar.MONTH, 1, Locale.US, "not before or equal").orElseThrow();
*
*
* Valid calendar field:
*
* - {@link Calendar#ERA}
* - {@link Calendar#YEAR}
* - {@link Calendar#MONTH}
* - {@link Calendar#WEEK_OF_YEAR}
* - {@link Calendar#WEEK_OF_MONTH}
* - {@link Calendar#DATE}
* - {@link Calendar#DAY_OF_MONTH}
* - {@link Calendar#DAY_OF_YEAR}
* - {@link Calendar#DAY_OF_WEEK}
* - {@link Calendar#DAY_OF_WEEK_IN_MONTH}
* - {@link Calendar#AM_PM}
* - {@link Calendar#HOUR}
* - {@link Calendar#HOUR_OF_DAY}
* - {@link Calendar#MINUTE}
* - {@link Calendar#SECOND}
* - {@link Calendar#MILLISECOND}
*
*
* @param date
* the date to compare
* @param calendarField
* the calendar field
* @param calendarAmount
* the calendar amount
* @param locale
* the message locale
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
*/
default PredicateStepDate isBeforeOrEqual(final Date date, final int calendarField, final int calendarAmount, final Locale locale,
final CharSequence message, final Object... arguments) {
return () -> AssertorDate.isBeforeOrEqual(this.getStep(), date, calendarField, calendarAmount,
MessageAssertor.of(locale, message, arguments));
}
}