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

functionalj.lens.lenses.java.time.ChronoZonedDateTimeAccess 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.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.IntegerAccess;
import functionalj.lens.lenses.LongAccess;
import functionalj.lens.lenses.StringAccess;
import lombok.val;

@FunctionalInterface
public interface ChronoZonedDateTimeAccess<
                            HOST, 
                            CHRONO_ZONED_DATE_TIME extends ChronoZonedDateTime>
                        extends AnyAccess     
                        ,       TemporalAccess {
    
    public static >
                ChronoLocalDateTimeAccess of(Function func) {
        return func::apply;
    }
    
    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();
        };
    }
    public default ChronoLocalDateTimeAccess> toLocalDateTime() {
        return host -> {
            val value = apply(host);
            return value.toLocalDateTime();
        };
    }
    
    @SuppressWarnings("unchecked")
    public default  ChronologyAccess getChronology() {
        return host -> {
            val value = apply(host);
            return (CHRONOLOGY)value.getChronology();
        };
    }
    
    public default ZoneOffsetAccess getOffset() {
        return host -> {
            val value = apply(host);
            return value.getOffset();
        };
    }
    public default ZoneIdAccess getZone() {
        return host -> {
            val value = apply(host);
            return value.getZone();
        };
    }
    
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess withEarlierOffsetAtOverlap() {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.withEarlierOffsetAtOverlap();
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess withLaterOffsetAtOverlap() {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.withLaterOffsetAtOverlap();
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess withZoneSameLocal(ZoneId zone) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.withZoneSameLocal(zone);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess withZoneSameInstant(ZoneId zone) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.withZoneSameInstant(zone);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess with(TemporalAdjuster adjuster) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.with(adjuster);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess with(TemporalField field, long newValue) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.with(field, newValue);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess plus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.plus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess plus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.plus(amountToAdd, unit);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess minus(TemporalAmount amount) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.minus(amount);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoZonedDateTimeAccess minus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return (CHRONO_ZONED_DATE_TIME) value.minus(amountToAdd, unit);
        };
    }
    
    public default StringAccess format(DateTimeFormatter formatter) {
        return host -> {
            val value = apply(host);
            return value.format(formatter);
        };
    }
    
    public default InstantAccess toInstant() {
        return host -> {
            val value = apply(host);
            return value.toInstant();
        };
    }
    
    public default LongAccess toEpochSecond() {
        return host -> {
            val value = apply(host);
            return value.toEpochSecond();
        };
    }
    
    public default IntegerAccess compareTo(ChronoZonedDateTime other) {
        return host -> {
            val value = apply(host);
            return value.compareTo(other);
        };
    }
    public default BooleanAccess thatGreaterThan(ChronoZonedDateTime anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
    }
    public default BooleanAccess thatLessThan(ChronoZonedDateTime anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
    }
    public default BooleanAccess thatGreaterThanOrEqualsTo(ChronoZonedDateTime anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
    }
    public default BooleanAccess thatLessThanOrEqualsTo(ChronoZonedDateTime anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
    }
    
    public default BooleanAccess thatIsAfter(ChronoZonedDateTime other) {
        return host -> {
            val value = apply(host);
            return value.isAfter(other);
        };
    }
    public default BooleanAccess thatIsBefore(ChronoZonedDateTime other) {
        return host -> {
            val value = apply(host);
            return value.isBefore(other);
        };
    }
    public default BooleanAccess thatIsEqual(ChronoZonedDateTime other) {
        return host -> {
            val value = apply(host);
            return value.isEqual(other);
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy