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

functionalj.lens.lenses.java.time.ChronoLocalDateTimeAccess 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.ZoneId;
import java.time.ZoneOffset;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import java.time.chrono.ChronoZonedDateTime;
import java.time.chrono.Chronology;
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.BooleanAccessPrimitive;
import functionalj.lens.lenses.IntegerAccessPrimitive;
import functionalj.lens.lenses.LongAccessPrimitive;
import functionalj.lens.lenses.StringAccess;
import lombok.val;


@FunctionalInterface
public interface ChronoLocalDateTimeAccess>
                                extends AnyAccess             
                                ,       TemporalAccess        
                                ,       TemporalAdjusterAccess {
    
    public static >
                ChronoLocalDateTimeAccess of(Function func) {
        return func::apply;
    }
    
    @SuppressWarnings("unchecked")
    public default  ChronologyAccess getChronology() {
        return host -> {
            val value = apply(host);
            return (CHRONOLOGY)value.getChronology();
        };
    }
    
    public default LocalDateAccess toLocalDate() {
        return host -> {
            val value = apply(host);
            return (LocalDate)value.toLocalDate();
        };
    }
    public default LocalTimeAccess toLocalTime() {
        return host -> {
            val value = apply(host);
            return (LocalTime)value.toLocalTime();
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess with(TemporalAdjuster adjuster) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.with(adjuster);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess with(TemporalField field, long newValue) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.with(field, newValue);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess plus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.plus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess plus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.plus(amountToAdd, unit);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess minus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.minus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoLocalDateTimeAccess minus(long amountToSubtract, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_LOCAL_DATE_TIME) value.minus(amountToSubtract, unit);
        };
    }
    
    public default StringAccess format(DateTimeFormatter formatter) {
        return host -> {
            val value = apply(host);
            return value.format(formatter);
        };
    }
    
    public default ChronoZonedDateTimeAccess> atZone(ZoneId zone) {
        return host -> {
            val value = apply(host);
            return value.atZone(zone);
        };
    }
    
    public default InstantAccess toInstant(ZoneOffset offset) {
        return host -> {
            val value = apply(host);
            return value.toInstant(offset);
        };
    }
    public default LongAccessPrimitive toEpochSecond(ZoneOffset offset) {
        return host -> {
            val value = apply(host);
            return value.toEpochSecond(offset);
        };
    }
    
    public default IntegerAccessPrimitive compareTo(ChronoLocalDateTime other) {
        return host -> {
            val value = apply(host);
            return value.compareTo(other);
        };
    }
    public default BooleanAccess thatGreaterThan(CHRONO_LOCAL_DATE_TIME anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
    }
    public default BooleanAccess thatLessThan(CHRONO_LOCAL_DATE_TIME anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
    }
    public default BooleanAccess thatGreaterThanOrEqualsTo(CHRONO_LOCAL_DATE_TIME anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
    }
    public default BooleanAccess thatLessThanOrEqualsTo(CHRONO_LOCAL_DATE_TIME anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
    }
    
    public default BooleanAccessPrimitive thatIsAfter(CHRONO_LOCAL_DATE_TIME other) {
        return host -> {
            val value = apply(host);
            return value.isAfter(other);
        };
    }
    public default BooleanAccessPrimitive thatIsBefore(CHRONO_LOCAL_DATE_TIME other) {
        return host -> {
            val value = apply(host);
            return value.isBefore(other);
        };
    }
    public default BooleanAccessPrimitive thatIsEqual(CHRONO_LOCAL_DATE_TIME other) {
        return host -> {
            val value = apply(host);
            return value.isEqual(other);
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy