functionalj.lens.lenses.java.time.LocalDateLens 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.Month;
import functionalj.lens.core.LensSpec;
import functionalj.lens.lenses.IntegerLens;
import functionalj.lens.lenses.ObjectLensImpl;
public class LocalDateLens
extends ObjectLensImpl
implements LocalDateAccess {
public static final LocalDateLens theLocalDate = new LocalDateLens(LensSpec.of(LocalDate.class));
public final IntegerLens year = createSubLens(LocalDate::getYear, (inst, year) -> inst.withYear(year), IntegerLens::of);
public final MonthLens month = createSubLens(LocalDate::getMonth, (inst, month) -> inst.withMonth(((Month)month).getValue()), MonthLens::new);
public final IntegerLens day = createSubLens(LocalDate::getDayOfMonth, (inst, day) -> inst.withDayOfMonth(day), IntegerLens::of);
public final IntegerLens monthValue = createSubLens(LocalDate::getMonthValue, (inst, month) -> inst.withMonth(month), IntegerLens::of);
public final IntegerLens dayOfYear = createSubLens(LocalDate::getDayOfYear, (inst, day) -> inst.withDayOfYear(day), IntegerLens::of);
public static LocalDateLens of(LensSpec spec) {
return new LocalDateLens(spec);
}
public LocalDateLens(LensSpec spec) {
super(spec);
}
}