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

functionalj.lens.lenses.java.time.LocalDateLens 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.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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy