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

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

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.BooleanAccess;
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 BooleanAccess 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 BooleanAccess isDaylightSavings(Instant instant) {
        return host -> {
            val value = apply(host);
            return value.isDaylightSavings(instant);
        };
    }
    public default BooleanAccess 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy