functionalj.lens.lenses.java.time.PeriodAccess 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.Period;
import java.time.temporal.TemporalAmount;
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.ListAccess;
import functionalj.lens.lenses.LongAccess;
import lombok.val;
@FunctionalInterface
public interface PeriodAccess
extends AnyAccess
, ChronoPeriodAccess
, ConcreteAccess> {
public static PeriodAccess of(Function func) {
return func::apply;
}
public default PeriodAccess newAccess(Function accessToValue) {
return host -> accessToValue.apply(host);
}
public default LongAccess get(TemporalUnit unit) {
return host -> {
val value = apply(host);
return value.get(unit);
};
}
public default ListAccess> getUnits() {
return ListAccess.of(this.then(TemporalAmount::getUnits), TemporalUnitAccess::of);
}
public default IsoChronologyAccess getChronology() {
return host -> {
val value = apply(host);
return value.getChronology();
};
}
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 IntegerAccess getYears() {
return host -> {
val value = apply(host);
return value.getYears();
};
}
public default IntegerAccess getMonths() {
return host -> {
val value = apply(host);
return value.getMonths();
};
}
public default IntegerAccess getDays() {
return host -> {
val value = apply(host);
return value.getDays();
};
}
public default PeriodAccess withYears(int years) {
return host -> {
val value = apply(host);
return value.withYears(years);
};
}
public default PeriodAccess withMonths(int months) {
return host -> {
val value = apply(host);
return value.withMonths(months);
};
}
public default PeriodAccess withDays(int days) {
return host -> {
val value = apply(host);
return value.withDays(days);
};
}
public default PeriodAccess plus(TemporalAmount amountToAdd) {
return host -> {
val value = apply(host);
return value.plus(amountToAdd);
};
}
public default PeriodAccess plusYears(long yearsToAdd) {
return host -> {
val value = apply(host);
return value.plusYears(yearsToAdd);
};
}
public default PeriodAccess plusMonths(long monthsToAdd) {
return host -> {
val value = apply(host);
return value.plusMonths(monthsToAdd);
};
}
public default PeriodAccess plusDays(long daysToAdd) {
return host -> {
val value = apply(host);
return value.plusDays(daysToAdd);
};
}
public default PeriodAccess minus(TemporalAmount amountToSubtract) {
return host -> {
val value = apply(host);
return value.minus(amountToSubtract);
};
}
public default PeriodAccess minusYears(long yearsToSubtract) {
return host -> {
val value = apply(host);
return value.minusYears(yearsToSubtract);
};
}
public default PeriodAccess minusMonths(long monthsToSubtract) {
return host -> {
val value = apply(host);
return value.minusMonths(monthsToSubtract);
};
}
public default PeriodAccess minusDays(long daysToSubtract) {
return host -> {
val value = apply(host);
return value.minusDays(daysToSubtract);
};
}
public default PeriodAccess multipliedBy(int scalar) {
return host -> {
val value = apply(host);
return value.multipliedBy(scalar);
};
}
public default PeriodAccess negated() {
return host -> {
val value = apply(host);
return value.negated();
};
}
public default PeriodAccess normalized() {
return host -> {
val value = apply(host);
return value.normalized();
};
}
public default LongAccess toTotalMonths() {
return host -> {
val value = apply(host);
return value.toTotalMonths();
};
}
}