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

functionalj.function.Traced Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
// ============================================================================
// Copyright (c) 2017-2021 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;

import functionalj.supportive.CallerId;
import lombok.val;


public interface Traced {
    
    /**
     * Returns the location. 
     * 
     * @return the location.
     **/
    public String getLocation();
    
    
    public static String extractLocationString(StackTraceElement caller) {
        return caller.getClassName() + "#" + caller.getLineNumber();
    }
    
    /**
     * 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) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Predicate(name, location, check);
    }
    public static  Annotated.Predicate predicate(java.util.function.Predicate check) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Predicate(null, location, check);
    }
    
    /** Add name to the given predicate. */
    public static  Annotated.Predicate Predicate(String name, java.util.function.Predicate check) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Predicate(name, location, check);
    }
    /** Add name to the given predicate. */
    public static  Annotated.Predicate Predicate(java.util.function.Predicate check) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Predicate(null, location, check);
    }
    
    /** Add name to the given supplier. */
    public static  Annotated.Supplier supplier(String name, java.util.function.Supplier supplier) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Supplier(name, location, supplier);
    }
    /** Add name to the given supplier. */
    public static  Annotated.Supplier supplier(java.util.function.Supplier supplier) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Supplier(null, location, supplier);
    }
    
    /** Add name to the given supplier. */
    public static  Annotated.Supplier Supplier(String name, java.util.function.Supplier supplier) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Supplier(name, location, supplier);
    }
    /** Add name to the given supplier. */
    public static  Annotated.Supplier Supplier(java.util.function.Supplier supplier) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Supplier(null, location, supplier);
    }
    
    /** Add name to the given runnable. */
    public static Annotated.Runnable runnable(String name, java.lang.Runnable runnable) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Runnable(name, location, runnable);
    }
    /** Add name to the given runnable. */
    public static Annotated.Runnable runnable(java.lang.Runnable runnable) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Runnable(null, location, runnable);
    }
    
    /** Add name to the given runnable. */
    public static Annotated.Runnable Runnable(String name, java.lang.Runnable runnable) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Runnable(name, location, runnable);
    }
    /** Add name to the given runnable. */
    public static Annotated.Runnable Runnable(java.lang.Runnable runnable) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Runnable(null, location, runnable);
    }
    
    /** Add name to the given consumer. */
    public static  Annotated.Consumer consumer(String name, java.util.function.Consumer consumer) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Consumer(name, location, consumer);
    }
    /** Add name to the given consumer. */
    public static  Annotated.Consumer consumer(java.util.function.Consumer consumer) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Consumer(null, location, consumer);
    }
    
    /** Add name to the given consumer. */
    public static  Annotated.Consumer Consumer(String name, java.util.function.Consumer consumer) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Consumer(name, location, consumer);
    }
    /** Add name to the given consumer. */
    public static  Annotated.Consumer Consumer(java.util.function.Consumer consumer) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Consumer(null, location, consumer);
    }
    
    public static  Annotated.Func0 func0(String name, Func0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func0(name, location, func);
    }
    public static  Annotated.Func0 func0(Func0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func0(null, location, func);
    }
    public static  Annotated.Func0 Func0(String name, Func0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func0(name, location, func);
    }
    public static  Annotated.Func0 Func0(Func0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func0(null, location, func);
    }
    
    public static  Annotated.Func1 func1(String name, Func1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func1(name, location, func);
    }
    public static  Annotated.Func1 func1(Func1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func1(null, location, func);
    }
    public static  Annotated.Func1 Func1(String name, Func1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func1(name, location, func);
    }
    public static  Annotated.Func1 Func1(Func1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func1(null, location, func);
    }
    
    public static  Annotated.Func2 func2(String name, Func2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func2(name, location, func);
    }
    public static  Annotated.Func2 func2(Func2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func2(null, location, func);
    }
    public static  Annotated.Func2 Func2(String name, Func2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func2(name, location, func);
    }
    public static  Annotated.Func2 Func2(Func2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func2(null, location, func);
    }
    
    public static  Annotated.Func3 func3(String name, Func3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func3(name, location, func);
    }
    public static  Annotated.Func3 func3(Func3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func3(null, location, func);
    }
    public static  Annotated.Func3 Func3(String name, Func3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func3(name, location, func);
    }
    public static  Annotated.Func3 Func3(Func3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func3(null, location, func);
    }
    
    public static  Annotated.Func4 func4(String name, Func4 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func4(name, location, func);
    }
    public static  Annotated.Func4 func4(Func4 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func4(null, location, func);
    }
    public static  Annotated.Func4 Func4(String name, Func4 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func4(name, location, func);
    }
    public static  Annotated.Func4 Func4(Func4 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func4(null, location, func);
    }
    
    public static  Annotated.Func5 func5(String name, Func5 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func5(name, location, func);
    }
    public static  Annotated.Func5 func5(Func5 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func5(null, location, func);
    }
    public static  Annotated.Func5 Func5(String name, Func5 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func5(name, location, func);
    }
    public static  Annotated.Func5 Func5(Func5 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func5(null, location, func);
    }
    
    public static  Annotated.Func6 func5(String name, Func6 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func6(name, location, func);
    }
    public static  Annotated.Func6 func5(Func6 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func6(null, location, func);
    }
    public static  Annotated.Func6 Func6(String name, Func6 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func6(name, location, func);
    }
    public static  Annotated.Func6 Func6(Func6 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.Func6(null, location, func);
    }
    
    public static  Annotated.FuncUnit0 funcUnit0(String name, FuncUnit0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit0(name, location, func);
    }
    public static  Annotated.FuncUnit0 funcUnit0(FuncUnit0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit0(null, location, func);
    }
    public static  Annotated.FuncUnit0 FuncUnit0(String name, FuncUnit0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit0(name, location, func);
    }
    public static  Annotated.FuncUnit0 FuncUnit0(FuncUnit0 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit0(null, location, func);
    }
    
    public static  Annotated.FuncUnit1 funcUnit1(String name, FuncUnit1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit1(name, location, func);
    }
    public static  Annotated.FuncUnit1 funcUnit1(FuncUnit1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit1(null, location, func);
    }
    public static  Annotated.FuncUnit1 FuncUnit1(String name, FuncUnit1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit1(name, location, func);
    }
    public static  Annotated.FuncUnit1 FuncUnit1(FuncUnit1 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit1(null, location, func);
    }
    
    public static  Annotated.FuncUnit2 funcUnit2(String name, FuncUnit2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit2(name, location, func);
    }
    public static  Annotated.FuncUnit2 funcUnit2(FuncUnit2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit2(null, location, func);
    }
    public static  Annotated.FuncUnit2 FuncUnit2(String name, FuncUnit2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit2(name, location, func);
    }
    public static  Annotated.FuncUnit2 FuncUnit2(FuncUnit2 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit2(null, location, func);
    }
    
    public static  Annotated.FuncUnit3 funcUnit3(String name, FuncUnit3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit3(name, location, func);
    }
    public static  Annotated.FuncUnit3 funcUnit3(FuncUnit3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit3(null, location, func);
    }
    public static  Annotated.FuncUnit3 FuncUnit3(String name, FuncUnit3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit3(name, location, func);
    }
    public static  Annotated.FuncUnit3 FuncUnit3(FuncUnit3 func) {
        val location = CallerId.instance.trace(Traced::extractLocationString);
        return new Annotated.FuncUnit3(null, location, func);
    }
    
}