functionalj.lens.lenses.java.time.ChronoZonedDateTimeAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalj-core Show documentation
Show all versions of functionalj-core Show documentation
The module for FunctionalJ Core.
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.BooleanAccessPrimitive;
import functionalj.lens.lenses.IntegerAccessPrimitive;
import functionalj.lens.lenses.LongAccessPrimitive;
import functionalj.lens.lenses.StringAccess;
import lombok.val;
@FunctionalInterface
public interface ChronoZonedDateTimeAccess<
HOST,
CHRONO_ZONED_DATE_TIME extends ChronoZonedDateTime extends ChronoLocalDate>>
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 LongAccessPrimitive toEpochSecond() {
return host -> {
val value = apply(host);
return value.toEpochSecond();
};
}
public default IntegerAccessPrimitive 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 BooleanAccessPrimitive thatIsAfter(ChronoZonedDateTime> other) {
return host -> {
val value = apply(host);
return value.isAfter(other);
};
}
public default BooleanAccessPrimitive thatIsBefore(ChronoZonedDateTime> other) {
return host -> {
val value = apply(host);
return value.isBefore(other);
};
}
public default BooleanAccessPrimitive thatIsEqual(ChronoZonedDateTime> other) {
return host -> {
val value = apply(host);
return value.isEqual(other);
};
}
}