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

functionalj.lens.lenses.java.time.ChronoPeriodAccess Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
package functionalj.lens.lenses.java.time;

import java.time.chrono.ChronoPeriod;
import java.time.chrono.Chronology;
import java.time.temporal.TemporalAmount;
import java.util.function.Function;

import functionalj.lens.lenses.AnyAccess;
import functionalj.lens.lenses.BooleanAccessPrimitive;
import lombok.val;


@FunctionalInterface
public interface ChronoPeriodAccess
                    extends AnyAccess           
                    ,       TemporalAmountAccess {
    
    public static  ChronoPeriodAccess of(Function func) {
        return func::apply;
    }
    
    public default ChronologyAccess getChronology() {
        return host -> {
            val value = apply(host);
            return value.getChronology();
        };
    }
    public default BooleanAccessPrimitive isZero() {
        return host -> {
            val value = apply(host);
            return value.isZero();
        };
    }
    public default BooleanAccessPrimitive isNegative() {
        return host -> {
            val value = apply(host);
            return value.isNegative();
        };
    }
    
    @SuppressWarnings("unchecked")
    public default ChronoPeriodAccess plus(TemporalAmount amountToAdd) {
        return host -> {
            val value = apply(host);
            return (CHRONO_PERIOD) value.plus(amountToAdd);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoPeriodAccess minus(TemporalAmount amountToAdd) {
        return host -> {
            val value = apply(host);
            return (CHRONO_PERIOD) value.minus(amountToAdd);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoPeriodAccess multipliedBy(int scalar) {
        return host -> {
            val value = apply(host);
            return (CHRONO_PERIOD) value.multipliedBy(scalar);
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoPeriodAccess negated() {
        return host -> {
            val value = apply(host);
            return (CHRONO_PERIOD) value.negated();
        };
    }
    @SuppressWarnings("unchecked")
    public default ChronoPeriodAccess normalized() {
        return host -> {
            val value = apply(host);
            return (CHRONO_PERIOD) value.normalized();
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy