package speiger.src.coreengine.utils.functions;

import java.util.function.Consumer;
import java.util.function.Predicate;

public class Functions
{
	static final Predicate<Object> ALWAYS_TRUE = _ -> true;
	static final Consumer<Object> EMPTY_CONSUMER = _ -> {};
	public static final Predicate<String> NUMBERS_ONLY = T -> {
		if(T.isEmpty() || T.equals("#") || T.equals("0x")) return true;
		try { return Long.decode(T) != null; }
		catch(Exception e){ return false; }
	};
	
	@SuppressWarnings("unchecked")
	public static <T> Predicate<T> getAlwaysTrue() {
		return (Predicate<T>)ALWAYS_TRUE;
	}
	
	@SuppressWarnings("unchecked")
	public static <T> Consumer<T> getVoidConsumer() {
		return (Consumer<T>)EMPTY_CONSUMER;
	}
}
