/*
 * Copyright (c) 2009 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 *
 */

package com.jscape.util.functor.adapters;

import com.jscape.util.functor.UnaryFunction;
import com.jscape.util.functor.UnaryPredicate;

/**
 * @author Alex Usun
 */
public class UnaryFunctionPredicate<V>
        extends UnaryPredicate<V> {

    private UnaryFunction<? super V, Boolean> base;

    /**
     * @param base base
     * @param <V>
     *
     * @return
     */
    public static <V> UnaryPredicate<V> adapt(UnaryFunction<? super V, Boolean> base) {
        return new UnaryFunctionPredicate<V>(base);
    }

    /**
     * @param base base
     */
    public UnaryFunctionPredicate(UnaryFunction<? super V, Boolean> base) {
        this.base = base;
    }

    /**
     * @param value value
     *
     * @return boolean value
     */
    public boolean evaluate(V value) {
        return this.base.evaluate(value);
    }
}