functionalj.lens.lenses.java.time.TimeDefinitionAccess Maven / Gradle / Ivy
package functionalj.lens.lenses.java.time;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
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 lombok.val;
@FunctionalInterface
public interface TimeDefinitionAccess
extends AnyAccess
, ConcreteAccess> {
public static TimeDefinitionAccess of(Function func) {
return func::apply;
}
public default TimeDefinitionAccess newAccess(Function accessToValue) {
return host -> accessToValue.apply(host);
}
public default BooleanAccess isUtc() {
return host -> {
val value = apply(host);
return value == TimeDefinition.UTC;
};
}
public default BooleanAccess isWall() {
return host -> {
val value = apply(host);
return value == TimeDefinition.WALL;
};
}
public default BooleanAccess isStandard() {
return host -> {
val value = apply(host);
return value == TimeDefinition.STANDARD;
};
}
public default LocalDateTimeAccess createDateTime(LocalDateTime dateTime, ZoneOffset standardOffset, ZoneOffset wallOffset) {
return host -> {
val value = apply(host);
return value.createDateTime(dateTime, standardOffset, wallOffset);
};
}
public default IntegerAccess compareTo(TimeDefinition other) {
return host -> {
val value = apply(host);
return value.compareTo(other);
};
}
public default BooleanAccess thatGreaterThan(TimeDefinition anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) > 0);
}
public default BooleanAccess thatLessThan(TimeDefinition anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) < 0);
}
public default BooleanAccess thatGreaterThanOrEqualsTo(TimeDefinition anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) >= 0);
}
public default BooleanAccess thatLessThanOrEqualsTo(TimeDefinition anotherValue) {
return booleanAccess(false, any -> any.compareTo(anotherValue) <= 0);
}
}