package mightypork.gamecore.util; import java.lang.annotation.Annotation; /** * Assorted utils * * @author MightyPork */ public final class Utils { public static Thread runAsThread(Runnable r) { final Thread t = new Thread(r); t.start(); return t; } public static boolean hasAnnotation(Object tested, Class annotation) { return tested.getClass().isAnnotationPresent(annotation); } public static T getAnnotation(Object tested, Class annotation) { return tested.getClass().getAnnotation(annotation); } /** * Pick first non-null option * * @param options options * @return the selected option */ public static Object fallback(Object... options) { for (final Object o : options) { if (o != null) return o; } return null; // all null } }