functionalj.lens.lenses.java.time.ChronologyAccess 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.Clock;
import java.time.Instant;
import java.time.ZoneId;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.ChronoLocalDateTime;
import java.time.chrono.ChronoPeriod;
import java.time.chrono.ChronoZonedDateTime;
import java.time.chrono.Chronology;
import java.time.chrono.Era;
import java.time.format.ResolverStyle;
import java.time.format.TextStyle;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalField;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import functionalj.lens.lenses.AnyAccess;
import functionalj.lens.lenses.BooleanAccess;
import functionalj.lens.lenses.IntegerAccess;
import functionalj.lens.lenses.ListAccess;
import functionalj.lens.lenses.StringAccess;
import lombok.val;
@FunctionalInterface
public interface ChronologyAccess
extends AnyAccess {
public static ChronologyAccess of(Function func) {
return func::apply;
}
public default StringAccess getId() {
return host -> {
val value = apply(host);
return value.getId();
};
}
public default StringAccess getCalendarType() {
return host -> {
val value = apply(host);
return value.getCalendarType();
};
}
public default ChronoLocalDateAccess date(Era era, int yearOfEra, int month, int dayOfMonth) {
return host -> {
val value = apply(host);
return value.date(era, yearOfEra, month, dayOfMonth);
};
}
public default ChronoLocalDateAccess date(int prolepticYear, int month, int dayOfMonth) {
return host -> {
val value = apply(host);
return value.date(prolepticYear, month, dayOfMonth);
};
}
public default ChronoLocalDateAccess dateYearDay(Era era, int yearOfEra, int dayOfYear) {
return host -> {
val value = apply(host);
return value.dateYearDay(era, yearOfEra, dayOfYear);
};
}
public default ChronoLocalDateAccess dateYearDay(int prolepticYear, int dayOfYear) {
return host -> {
val value = apply(host);
return value.dateYearDay(prolepticYear, dayOfYear);
};
}
public default ChronoLocalDateAccess dateEpochDay(long epochDay) {
return host -> {
val value = apply(host);
return value.dateEpochDay(epochDay);
};
}
public default ChronoLocalDateAccess dateNow() {
return host -> {
val value = apply(host);
return value.dateNow();
};
}
public default ChronoLocalDateAccess dateNow(ZoneId zone) {
return host -> {
val value = apply(host);
return value.dateNow(zone);
};
}
public default ChronoLocalDateAccess dateNow(Clock clock) {
return host -> {
val value = apply(host);
return value.dateNow(clock);
};
}
public default ChronoLocalDateAccess date(TemporalAccessor temporal) {
return host -> {
val value = apply(host);
return value.date(temporal);
};
}
public default ChronoLocalDateTimeAccess>
localDateTime(TemporalAccessor temporal) {
return host -> {
val value = apply(host);
return value.localDateTime(temporal);
};
}
public default ChronoZonedDateTimeAccess>
zonedDateTime(TemporalAccessor temporal) {
return host -> {
val value = apply(host);
return value.zonedDateTime(temporal);
};
}
public default ChronoZonedDateTimeAccess>
zonedDateTime(Instant instant, ZoneId zone) {
return host -> {
val value = apply(host);
return value.zonedDateTime(instant, zone);
};
}
public default BooleanAccess isLeapYear(long prolepticYear) {
return host -> {
val value = apply(host);
return value.isLeapYear(prolepticYear);
};
}
public default IntegerAccess prolepticYear(Era era, int yearOfEra) {
return host -> {
val value = apply(host);
return value.prolepticYear(era, yearOfEra);
};
}
public default EraAccess eraOf(int eraValue) {
return host -> {
val value = apply(host);
return value.eraOf(eraValue);
};
}
public default ListAccess> eras() {
return ListAccess.of(host -> ChronologyAccess.this.apply(host).eras(), EraAccess::of);
}
public default ValueRangeAccess range(ChronoField field) {
return host -> {
val value = apply(host);
return value.range(field);
};
}
public default StringAccess getDisplayName(TextStyle style, Locale locale) {
return host -> {
val value = apply(host);
return value.getDisplayName(style, locale);
};
}
public default ChronoLocalDateAccess resolveDate(Map fieldValues, ResolverStyle resolverStyle) {
return host -> {
val value = apply(host);
return value.resolveDate(fieldValues, resolverStyle);
};
}
public default ChronoPeriodAccess period(int years, int months, int days) {
return host -> {
val value = apply(host);
return value.period(years, months, days);
};
}
public default IntegerAccess compareTo(Chronology other) {
return host -> {
val value = apply(host);
return value.compareTo(other);
};
}
public default BooleanAccess thatGreaterThan(Chronology anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
}
public default BooleanAccess thatLessThan(Chronology anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
}
public default BooleanAccess thatGreaterThanOrEqualsTo(Chronology anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
}
public default BooleanAccess thatLessThanOrEqualsTo(Chronology anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
}
}