/** Derives the name of the {@code i}th parameter of a method. */ public static String getParameterName(Method method, int i) { for (Annotation annotation : method.getParameterAnnotations()[i]) { if (annotation.annotationType() == Parameter.class) { return ((Parameter) annotation).name(); } } return method.getParameters()[i].getName(); }
/** Derives whether the {@code i}th parameter of a method is optional. */ public static boolean isParameterOptional(Method method, int i) { for (Annotation annotation : method.getParameterAnnotations()[i]) { if (annotation.annotationType() == Parameter.class) { return ((Parameter) annotation).optional(); } } return false; }
/** Derives the name of the {@code i}th parameter of a method. */ public static String getParameterName(Method method, int i) { for (Annotation annotation : method.getParameterAnnotations()[i]) { if (annotation.annotationType() == Parameter.class) { return ((Parameter) annotation).name(); } } return method.getParameters()[i].getName(); }
/** Derives whether the {@code i}th parameter of a method is optional. */ public static boolean isParameterOptional(Method method, int i) { for (Annotation annotation : method.getParameterAnnotations()[i]) { if (annotation.annotationType() == Parameter.class) { return ((Parameter) annotation).optional(); } } return false; }
/** Implements the {@code RAND(seed)} SQL function. */ public double randSeed(@Parameter(name = "seed") int seed) { if (random == null) { random = new Random(seed ^ (seed << 16)); } return random.nextDouble(); }
/** Implements the {@code RAND_INTEGER(bound)} SQL function. */ public int randInteger(@Parameter(name = "bound") int bound) { if (random == null) { random = new Random(); } return random.nextInt(bound); }
/** Implements the {@code RAND(seed)} SQL function. */ public double randSeed(@Parameter(name = "seed") int seed) { if (random == null) { random = new Random(seed ^ (seed << 16)); } return random.nextDouble(); }
/** Implements the {@code RAND_INTEGER(bound)} SQL function. */ public int randInteger(@Parameter(name = "bound") int bound) { if (random == null) { random = new Random(); } return random.nextInt(bound); }
public String eval(@Parameter(name = "A", optional = false) Integer a, @Parameter(name = "B", optional = true) Integer b, @Parameter(name = "C", optional = false) Integer c, @Parameter(name = "D", optional = true) Integer d, @Parameter(name = "E", optional = true) Integer e) { return "{a: " + a + ", b: " + b + ", c: " + c + ", d: " + d + ", e: " + e + "}"; } }
public String eval(@Parameter(name = "A", optional = false) Integer a, @Parameter(name = "B", optional = true) Integer b, @Parameter(name = "C", optional = false) Integer c, @Parameter(name = "D", optional = true) Integer d, @Parameter(name = "E", optional = true) Integer e) { return "{a: " + a + ", b: " + b + ", c: " + c + ", d: " + d + ", e: " + e + "}"; } }