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

org.codehaus.httpcache4j.mutable.MutableConditionals Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010. The Codehaus. All Rights Reserved.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package org.codehaus.httpcache4j.mutable;

import org.codehaus.httpcache4j.Conditionals;
import org.codehaus.httpcache4j.Tag;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
 * @author Erlend Hamnaberg
 * @version $Revision: $
 */
public class MutableConditionals {
    private Conditionals conditionals;

    public MutableConditionals() {
        this(new Conditionals());
    }

    MutableConditionals(Conditionals conditionals) {
        this.conditionals = Objects.requireNonNull(conditionals, "Conditionals may not be null");
    }

    public void addIfMatch(Tag tag) {
        conditionals = conditionals.addIfMatch(tag);
    }

    public void addIfNoneMatch(Tag tag) {
        conditionals = conditionals.addIfNoneMatch(tag);
    }

    public void ifModifiedSince(LocalDateTime time) {
        conditionals = conditionals.ifModifiedSince(time);
    }

    public void ifUnModifiedSince(LocalDateTime time) {
        conditionals = conditionals.ifUnModifiedSince(time);
    }

    public List getMatch() {
        return conditionals.getMatch();
    }

    public List getNoneMatch() {
        return conditionals.getNoneMatch();
    }

    public LocalDateTime getModifiedSince() {
        return conditionals.getModifiedSince().orElse(null);
    }

    public LocalDateTime getUnModifiedSince() {
        return conditionals.getUnModifiedSince().orElse(null);
    }

    public boolean isUnconditional() {
        return conditionals.isUnconditional();
    }

    public Conditionals toConditionals() {
        return conditionals;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy