All Downloads are FREE. Search and download functionalities are using the official Maven repository.

functionalj.lens.lenses.java.time.LocalDateAccess Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
package functionalj.lens.lenses.java.time;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.Period;
import java.time.ZoneId;
import java.time.chrono.ChronoLocalDate;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalField;
import java.time.temporal.TemporalUnit;
import java.util.function.Function;

import functionalj.lens.lenses.AnyAccess;
import functionalj.lens.lenses.ConcreteAccess;
import functionalj.lens.lenses.IntegerAccess;
import lombok.val;

@SuppressWarnings("javadoc")
@FunctionalInterface
public interface LocalDateAccess
                    extends AnyAccess             
                    ,       TemporalAccess        
                    ,       TemporalAdjusterAccess
                    ,       ChronoLocalDateAccess 
                    ,       ConcreteAccess        > {
    
    public static  LocalDateAccess of(Function func) {
        return func::apply;
    }
    
    public default LocalDateAccess newAccess(Function accessToValue) {
        return host -> accessToValue.apply(host);
    }
    
    public default PeriodAccess periodTo(LocalDate endDateExclusive) {
        return host -> {
            val value = apply(host);
            return Period.between(value, endDateExclusive);
        };
    }
    
    public default PeriodAccess periodFrom(LocalDate startDateInclusive) {
        return host -> {
            val value = apply(host);
            return Period.between(startDateInclusive, value);
        };
    }
    
    public default IsoChronologyAccess getIsoChronology() {
        return host -> {
            val value = apply(host);
            return value.getChronology();
        };
    }
    public default IntegerAccess getYear() {
        return host -> {
            val value = apply(host);
            return value.getYear();
        };
    }
    public default IntegerAccess getMonthValue() {
        return host -> {
            val value = apply(host);
            return value.getMonthValue();
        };
    }
    public default MonthAccess getMonth() {
        return host -> {
            val value = apply(host);
            return value.getMonth();
        };
    }
    public default IntegerAccess getDayOfMonth() {
        return host -> {
            val value = apply(host);
            return value.getDayOfMonth();
        };
    }
    public default IntegerAccess getDayOfYear() {
        return host -> {
            val value = apply(host);
            return value.getDayOfYear();
        };
    }
    public default DayOfWeekAccess getDayOfWeek() {
        return host -> {
            val value = apply(host);
            return value.getDayOfWeek();
        };
    }
    public default LocalDateAccess with(TemporalAdjuster adjuster) {
        return host -> {
            val value = apply(host);
            return value.with(adjuster);
        };
    }
    public default LocalDateAccess with(TemporalField field, long newValue) {
        return host -> {
            val value = apply(host);
            return value.with(field, newValue);
        };
    }
    public default LocalDateAccess withYear(int year) {
        return host -> {
            val value = apply(host);
            return value.withYear(year);
        };
    }
    public default LocalDateAccess withMonth(int month) {
        return host -> {
            val value = apply(host);
            return value.withMonth(month);
        };
    }
    public default LocalDateAccess withDayOfMonth(int dayOfMonth) {
        return host -> {
            val value = apply(host);
            return value.withMonth(dayOfMonth);
        };
    }
    public default LocalDateAccess withDayOfYear(int dayOfYear) {
        return host -> {
            val value = apply(host);
            return value.withMonth(dayOfYear);
        };
    }
    public default LocalDateAccess plus(TemporalAmount amountToAdd) {
        return host -> {
            val value = apply(host);
            return value.plus(amountToAdd);
        };
    }
    public default LocalDateAccess plus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return value.plus(amountToAdd, unit);
        };
    }
    public default LocalDateAccess plusYears(long yearsToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusYears(yearsToAdd);
        };
    }
    public default LocalDateAccess plusMonths(long monthsToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusMonths(monthsToAdd);
        };
    }
    public default LocalDateAccess plusWeeks(long weeksToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusWeeks(weeksToAdd);
        };
    }
    public default LocalDateAccess plusDays(long daysToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusDays(daysToAdd);
        };
    }
    public default LocalDateAccess minus(TemporalAmount amountToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minus(amountToSubtract);
        };
    }
    public default LocalDateAccess minus(long amountToSubtract, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return value.minus(amountToSubtract, unit);
        };
    }
    public default LocalDateAccess minusYears(long yearsToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusYears(yearsToSubtract);
        };
    }
    public default LocalDateAccess minusMonths(long monthsToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusMonths(monthsToSubtract);
        };
    }
    public default LocalDateAccess minusWeeks(long weeksToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusWeeks(weeksToSubtract);
        };
    }
    public default LocalDateAccess minusDays(long daysToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusDays(daysToSubtract);
        };
    }
    public default PeriodAccess until(ChronoLocalDate endDateExclusive) {
        return host -> {
            val value = apply(host);
            return value.until(endDateExclusive);
        };
    }
    public default LocalDateTimeAccess atTime(LocalTime time) {
        return host -> {
            val value = apply(host);
            return value.atTime(time);
        };
    }
    public default LocalDateTimeAccess atTime(int hour, int minute) {
        return host -> {
            val value = apply(host);
            return value.atTime(hour, minute);
        };
    }
    public default LocalDateTimeAccess atTime(int hour, int minute, int second) {
        return host -> {
            val value = apply(host);
            return value.atTime(hour, minute, second);
        };
    }
    public default LocalDateTimeAccess atTime(int hour, int minute, int second, int nanoOfSecond) {
        return host -> {
            val value = apply(host);
            return value.atTime(hour, minute, second, nanoOfSecond);
        };
    }
    public default OffsetDateTimeAccess atTime(OffsetTime time) {
        return host -> {
            val value = apply(host);
            return value.atTime(time);
        };
    }
    public default LocalDateTimeAccess atStartOfDay() {
        return host -> {
            val value = apply(host);
            return value.atStartOfDay();
        };
    }
    public default ZonedDateTimeAccess atStartOfDay(ZoneId zone) {
        return host -> {
            val value = apply(host);
            return value.atStartOfDay(zone);
        };
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy