functionalj.lens.lenses.java.time.ZoneRulesAccess 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.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.zone.ZoneOffsetTransition;
import java.time.zone.ZoneOffsetTransitionRule;
import java.time.zone.ZoneRules;
import java.util.function.Function;
import functionalj.lens.lenses.AnyAccess;
import functionalj.lens.lenses.BooleanAccessPrimitive;
import functionalj.lens.lenses.ConcreteAccess;
import functionalj.lens.lenses.ListAccess;
import lombok.val;
@FunctionalInterface
public interface ZoneRulesAccess
extends AnyAccess
, ConcreteAccess> {
public static ZoneRulesAccess of(Function func) {
return func::apply;
}
public default ZoneRulesAccess newAccess(Function accessToValue) {
return accessToValue::apply;
}
public default BooleanAccessPrimitive isFixedOffset() {
return host -> {
val value = apply(host);
return value.isFixedOffset();
};
}
public default ZoneOffsetAccess getOffset(Instant instant) {
return host -> {
val value = apply(host);
return value.getOffset(instant);
};
}
public default ZoneOffsetAccess getOffset(LocalDateTime localDateTime) {
return host -> {
val value = apply(host);
return value.getOffset(localDateTime);
};
}
public default ListAccess> getValidOffsets(LocalDateTime localDateTime) {
return ListAccess.of(
(HOST host) -> ZoneRulesAccess.this.apply(host).getValidOffsets(localDateTime),
ZoneOffsetAccess::of);
}
public default ZoneOffsetTransitionAccess getTransition(LocalDateTime localDateTime) {
return host -> {
val value = apply(host);
return value.getTransition(localDateTime);
};
}
public default ZoneOffsetAccess getStandardOffset(Instant instant) {
return host -> {
val value = apply(host);
return value.getStandardOffset(instant);
};
}
public default DurationAccess getDaylightSavings(Instant instant) {
return host -> {
val value = apply(host);
return value.getDaylightSavings(instant);
};
}
public default BooleanAccessPrimitive isDaylightSavings(Instant instant) {
return host -> {
val value = apply(host);
return value.isDaylightSavings(instant);
};
}
public default BooleanAccessPrimitive isValidOffset(LocalDateTime localDateTime, ZoneOffset offset) {
return host -> {
val value = apply(host);
return value.isValidOffset(localDateTime, offset);
};
}
public default ZoneOffsetTransitionAccess nextTransition(Instant instant) {
return host -> {
val value = apply(host);
return value.nextTransition(instant);
};
}
public default ZoneOffsetTransitionAccess previousTransition(Instant instant) {
return host -> {
val value = apply(host);
return value.previousTransition(instant);
};
}
public default ListAccess> getTransitions() {
return ListAccess.of(
(HOST host) -> ZoneRulesAccess.this.apply(host).getTransitions(),
ZoneOffsetTransitionAccess::of);
}
public default ListAccess> getTransitionRules() {
return ListAccess.of(
(HOST host) -> ZoneRulesAccess.this.apply(host).getTransitionRules(),
ZoneOffsetTransitionRuleAccess::of);
}
}