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

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

package functionalj.lens.lenses.java.time;

import java.time.Duration;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalUnit;
import java.util.function.Function;

import functionalj.lens.lenses.AnyAccess;
import functionalj.lens.lenses.BooleanAccess;
import functionalj.lens.lenses.ConcreteAccess;
import functionalj.lens.lenses.IntegerAccess;
import functionalj.lens.lenses.LongAccess;
import lombok.val;

@FunctionalInterface
public interface DurationAccess
                    extends AnyAccess           
                    ,       TemporalAmountAccess
                    ,       ConcreteAccess      > {
    
    public static  DurationAccess of(Function func) {
        return func::apply;
    }
    
    public default DurationAccess newAccess(Function accessToValue) {
        return accessToValue::apply;
    }
    
    public default BooleanAccess isZero() {
        return host -> {
            val value = apply(host);
            return value.isZero();
        };
    }
    public default BooleanAccess isNegative() {
        return host -> {
            val value = apply(host);
            return value.isNegative();
        };
    }
    public default LongAccess getSeconds() {
        return host -> {
            val value = apply(host);
            return value.getSeconds();
        };
    }
    public default IntegerAccess getNano() {
        return host -> {
            val value = apply(host);
            return value.getNano();
        };
    }
    public default DurationAccess withSeconds(long seconds) {
        return host -> {
            val value = apply(host);
            return value.withSeconds(seconds);
        };
    }
    public default DurationAccess withNanos(int nanoOfSecond) {
        return host -> {
            val value = apply(host);
            return value.withNanos(nanoOfSecond);
        };
    }
    public default DurationAccess plus(Duration duration) {
        return host -> {
            val value = apply(host);
            return value.plus(duration);
        };
     }
    public default DurationAccess plus(long amountToAdd, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return value.plus(amountToAdd, unit);
        };
    }
    public default DurationAccess plusDays(long daysToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusDays(daysToAdd);
        };
    }
    public default DurationAccess plusHours(long hoursToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusHours(hoursToAdd);
        };
    }
    public default DurationAccess plusMinutes(long minutesToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusMinutes(minutesToAdd);
        };
    }
    public default DurationAccess plusSeconds(long secondsToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusSeconds(secondsToAdd);
        };
    }
    public default DurationAccess plusMillis(long millisToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusMillis(millisToAdd);
        };
    }
    public default DurationAccess plusNanos(long nanosToAdd) {
        return host -> {
            val value = apply(host);
            return value.plusNanos(nanosToAdd);
        };
    }
    public default DurationAccess minus(Duration duration) {
        return host -> {
            val value = apply(host);
            return value.minus(duration);
        };
     }
    public default DurationAccess minus(long amountToSubtract, TemporalUnit unit) {
        return host -> {
            val value = apply(host);
            return value.minus(amountToSubtract, unit);
        };
    }
    public default DurationAccess minusDays(long daysToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusDays(daysToSubtract);
        };
    }
    public default DurationAccess minusHours(long hoursToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusHours(hoursToSubtract);
        };
    }
    public default DurationAccess minusMinutes(long minutesToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusMinutes(minutesToSubtract);
        };
    }
    public default DurationAccess minusSeconds(long secondsToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusSeconds(secondsToSubtract);
        };
    }
    public default DurationAccess minusMillis(long millisToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusMillis(millisToSubtract);
        };
    }
    public default DurationAccess minusNanos(long nanosToSubtract) {
        return host -> {
            val value = apply(host);
            return value.minusNanos(nanosToSubtract);
        };
    }
    public default DurationAccess multipliedBy(long multiplicand) {
        return host -> {
            val value = apply(host);
            return value.multipliedBy(multiplicand);
        };
     }
    public default DurationAccess dividedBy(long divisor) {
        return host -> {
            val value = apply(host);
            return value.dividedBy(divisor);
        };
     }
    public default DurationAccess negated() {
        return host -> {
            val value = apply(host);
            return value.negated();
        };
    }
    public default DurationAccess abs() {
        return host -> {
            val value = apply(host);
            return value.abs();
        };
    }
    public default TemporalAccess addTo(Temporal temporal) {
        return host -> {
            val value = apply(host);
            return value.addTo(temporal);
        };
    }
    public default TemporalAccess subtractFrom(Temporal temporal) {
        return host -> {
            val value = apply(host);
            return value.subtractFrom(temporal);
        };
    }
    public default LongAccess toDays() {
        return host -> {
            val value = apply(host);
            return value.toDays();
        };
    }
    public default LongAccess toHours() {
        return host -> {
            val value = apply(host);
            return value.toHours();
        };
    }
    public default LongAccess toMinutes() {
        return host -> {
            val value = apply(host);
            return value.toMinutes();
        };
    }
    public default LongAccess toMillis() {
        return host -> {
            val value = apply(host);
            return value.toMillis();
        };
    }
    public default LongAccess toNanos() {
        return host -> {
            val value = apply(host);
            return value.toNanos();
        };
    }
    
    public default IntegerAccess compareTo(Duration other) {
        return host -> {
            val value = apply(host);
            return value.compareTo(other);
        };
    }
    public default BooleanAccess thatGreaterThan(Duration anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
    }
    public default BooleanAccess thatLessThan(Duration anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
    }
    public default BooleanAccess thatGreaterThanOrEqualsTo(Duration anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
    }
    public default BooleanAccess thatLessThanOrEqualsTo(Duration anotherValue) {
        return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy