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

functionalj.function.Named Maven / Gradle / Ivy

// ============================================================================
// Copyright (c) 2017-2019 Nawapunth Manusitthipol (NawaMan - http://nawaman.net).
// ----------------------------------------------------------------------------
// MIT License
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// ============================================================================
package functionalj.function;

/**
 * This class offer a way to make it easy to debug lambda by adding name to them.
 * 
 * @author NawaMan
 **/
// https://stackoverflow.com/questions/42876840/namingtostring-lambda-expressions-for-debugging-purpose/42876841#42876841
// https://stackoverflow.com/questions/23704355/creating-string-representation-of-lambda-expression/23705160#23705160
@SuppressWarnings("javadoc")
public interface Named {
    
    /**
     * Returns the name. 
     * 
     * @return the name.
     **/
    public String getName();
    
    /**
     * Add name to the given predicate. 
     * 
     * @param name 
     * @param check 
     * @return the named predicate.
     **/
    public static  Annotated.Predicate predicate(String name, java.util.function.Predicate check) {
        return new Annotated.Predicate(name, check);
    }
    
    /** Add name to the given predicate. */
    public static  Annotated.Predicate Predicate(String name, java.util.function.Predicate check) {
        return new Annotated.Predicate(name, check);
    }
    
    /**
     * Add name to the given bipredicate. 
     * 
     * @param name 
     * @param check 
     * @return the named predicate.
     **/
    public static  Annotated.BiPredicate biPredicate(String name, java.util.function.BiPredicate check) {
        return new Annotated.BiPredicate(name, check);
    }
    
    /** Add name to the given bipredicate. */
    public static  Annotated.BiPredicate BiPredicate(String name, java.util.function.BiPredicate check) {
        return new Annotated.BiPredicate(name, check);
    }
    
    /** Add name to the given supplier. */
    public static  Annotated.Supplier supplier(String name, java.util.function.Supplier supplier) {
        return new Annotated.Supplier(name, supplier);
    }
    
    /** Add name to the given supplier. */
    public static  Annotated.Supplier Supplier(String name, java.util.function.Supplier supplier) {
        return new Annotated.Supplier(name, supplier);
    }
    
    /** Add name to the given runnable. */
    public static Annotated.Runnable runnable(String name, java.lang.Runnable runnable) {
        return new Annotated.Runnable(name, runnable);
    }
    
    /** Add name to the given runnable. */
    public static Annotated.Runnable Runnable(String name, java.lang.Runnable runnable) {
        return new Annotated.Runnable(name, runnable);
    }
    
    /** Add name to the given consumer. */
    public static  Annotated.Consumer consumer(String name, java.util.function.Consumer consumer) {
        return new Annotated.Consumer(name, consumer);
    }
    
    /** Add name to the given consumer. */
    public static  Annotated.Consumer Consumer(String name, java.util.function.Consumer consumer) {
        return new Annotated.Consumer(name, consumer);
    }
    
    public static  Annotated.Func0 func0(String name, Func0 func) {
        return new Annotated.Func0(name, func);
    }
    public static  Annotated.Func0 Func0(String name, Func0 func) {
        return new Annotated.Func0(name, func);
    }
    
    public static  Annotated.Func1 func1(String name, Func1 func) {
        return new Annotated.Func1(name, func);
    }
    public static  Annotated.Func1 Func1(String name, Func1 func) {
        return new Annotated.Func1(name, func);
    }
    
    public static  Annotated.Func2 func2(String name, Func2 func) {
        return new Annotated.Func2(name, func);
    }
    public static  Annotated.Func2 Func2(String name, Func2 func) {
        return new Annotated.Func2(name, func);
    }
    
    public static  Annotated.Func3 func3(String name, Func3 func) {
        return new Annotated.Func3(name, func);
    }
    public static  Annotated.Func3 Func3(String name, Func3 func) {
        return new Annotated.Func3(name, func);
    }
    
    public static  Annotated.Func4 func4(String name, Func4 func) {
        return new Annotated.Func4(name, func);
    }
    public static  Annotated.Func4 Func4(String name, Func4 func) {
        return new Annotated.Func4(name, func);
    }
    
    public static  Annotated.Func5 func5(String name, Func5 func) {
        return new Annotated.Func5(name, func);
    }
    public static  Annotated.Func5 Func5(String name, Func5 func) {
        return new Annotated.Func5(name, func);
    }
    
    public static  Annotated.Func6 func6(String name, Func6 func) {
        return new Annotated.Func6(name, func);
    }
    public static  Annotated.Func6 Func6(String name, Func6 func) {
        return new Annotated.Func6(name, func);
    }
    
    public static  Annotated.FuncUnit0 funcUnit0(String name, FuncUnit0 func) {
        return new Annotated.FuncUnit0(name, func);
    }
    public static  Annotated.FuncUnit0 FuncUnit0(String name, FuncUnit0 func) {
        return new Annotated.FuncUnit0(name, func);
    }
    
    public static  Annotated.FuncUnit1 funcUnit1(String name, FuncUnit1 func) {
        return new Annotated.FuncUnit1(name, func);
    }
    public static  Annotated.FuncUnit1 FuncUnit1(String name, FuncUnit1 func) {
        return new Annotated.FuncUnit1(name, func);
    }
    
    public static  Annotated.FuncUnit2 funcUnit2(String name, FuncUnit2 func) {
        return new Annotated.FuncUnit2(name, func);
    }
    public static  Annotated.FuncUnit2 FuncUnit2(String name, FuncUnit2 func) {
        return new Annotated.FuncUnit2(name, func);
    }
    
    public static  Annotated.FuncUnit3 funcUnit3(String name, FuncUnit3 func) {
        return new Annotated.FuncUnit3(name, func);
    }
    public static  Annotated.FuncUnit3 FuncUnit3(String name, FuncUnit3 func) {
        return new Annotated.FuncUnit3(name, func);
    }
    
}