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

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

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

import java.time.LocalTime;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import java.time.chrono.ChronoPeriod;
import java.time.chrono.Chronology;
import java.time.chrono.Era;
import java.time.format.DateTimeFormatter;
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.BooleanAccess;
import functionalj.lens.lenses.IntegerAccess;
import functionalj.lens.lenses.LongAccess;
import functionalj.lens.lenses.StringAccess;
import lombok.val;

@FunctionalInterface
public interface ChronoLocalDateAccess
                    extends AnyAccess             
                    ,       TemporalAccess        
                    ,       TemporalAdjusterAccess {
    
    public static  ChronoLocalDateAccess of(Function func) {
        return func::apply;
    }
    
    @SuppressWarnings("unchecked")
    public default  ChronologyAccess getChronology() {
        return host -> {
            val value = apply(host);
            return (CHRONOLOGY)value.getChronology();
        };
    }
    
    public default EraAccess getEra() {
        return host -> {
            val value = apply(host);
            return value.getEra();
        };
    }
    public default BooleanAccess thatIsLeapYear() {
        return host -> {
            val value = apply(host);
            return value.isLeapYear();
        };
    }
    public default IntegerAccess lengthOfMonth() {
        return host -> {
            val value = apply(host);
            return value.lengthOfMonth();
        };
    }
    public default IntegerAccess lengthOfYear() {
        return host -> {
            val value = apply(host);
            return value.lengthOfYear();
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess with(TemporalAdjuster adjuster) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.with(adjuster);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess with(TemporalField field, long newValue) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.with(field, newValue);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess plus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.plus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess plus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.plus(amountToAdd, unit);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess minus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.minus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateAccess minus(long amountToSubtract, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE) value.minus(amountToSubtract, unit);
        };
    }
    
    public default ChronoPeriodAccess until(ChronoLocalDate endDateExclusive) {
        return host -> {
            val value = apply(host);
            return value.until(endDateExclusive);
        };
    }
    
    public default StringAccess format(DateTimeFormatter formatter) {
        return host -> {
            val value = apply(host);
            return value.format(formatter);
        };
    }
    
    public default ChronoLocalDateTimeAccess>
                    atTime(LocalTime localTime) {
        return host -> {
            val value = apply(host);
            return value.atTime(localTime);
        };
    }
    
    public default LongAccess toEpochDay() {
        return host -> {
            val value = apply(host);
            return value.toEpochDay();
        };
    }
    
    public default IntegerAccess compareTo(ChronoLocalDate other) {
        return host -> {
            val value = apply(host);
            return value.compareTo(other);
        };
    }
    public default BooleanAccess thatGreaterThan(ChronoLocalDate anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
    }
    public default BooleanAccess thatLessThan(ChronoLocalDate anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
    }
    public default BooleanAccess thatGreaterThanOrEqualsTo(ChronoLocalDate anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
    }
    public default BooleanAccess thatLessThanOrEqualsTo(ChronoLocalDate anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
    }
    
    public default BooleanAccess thatIsAfter(ChronoLocalDate other) {
        return host -> {
            val value = apply(host);
            return value.isAfter(other);
        };
    }
    public default BooleanAccess thatIsBefore(ChronoLocalDate other) {
        return host -> {
            val value = apply(host);
            return value.isBefore(other);
        };
    }
    public default BooleanAccess thatIsEqual(ChronoLocalDate other) {
        return host -> {
            val value = apply(host);
            return value.isEqual(other);
        };
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy