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

panda.std.Case Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2021 dzikoysk
 *
 * 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 panda.std;

import java.util.function.Function;
import java.util.function.Predicate;

/**
 * Represents a conditional entry
 *
 * @param  type of value to process
 * @param  type of result value
 */
public class Case {

    private final Predicate condition;
    private final Function value;

    private Case(Predicate condition, Function value) {
        this.condition = condition;
        this.value = value;
    }

    public Predicate getCondition() {
        return condition;
    }

    public Function getValue() {
        return value;
    }

    public static  Case of(Predicate predicate, Function function) {
        return new Case<>(predicate, function);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy