/** Converts a Matcher to a boolean (false means matches()). */ @GwtIncompatible @Pure @Inline("(($1 == null) || !$1.matches())") public static boolean operator_not(final Matcher value) { return (value == null) || !value.matches(); }
/** Converts a Buffer to a boolean (false means hasRemaining()). */ @GwtIncompatible @Pure @Inline("(($1 == null) || !$1.hasRemaining())") public static boolean operator_not(final Buffer value) { return (value == null) || !value.hasRemaining(); }
/** * Converts a fuzzy logic value to a "tri-state" value * (TRUE/likely, null/undecided, FALSE/unlikely) */ @Pure @Inline("(($1 <= 1.0f/3.0f) ? Boolean.FALSE : ($1 >= 2.0f/3.0f ? Boolean.TRUE : null))") public static Boolean triState(final float value) { return (value <= 1.0f / 3.0f) ? Boolean.FALSE : (value >= 2.0f / 3.0f ? Boolean.TRUE : null); }
/** * Calls some code safely. * Never throws an Exception. * @return * @return null if the code fails, otherwise the return value of call(). */ @Inline("com.blockwithme.util.xtend.SafeCallExtension.attempt($1, $2, $3, $4, $5, $6, null)") public static <R, E1, E2, E3, E4, E5, E6> R attempt( final Function6<E1, E2, E3, E4, E5, E6, R> code, final E1 p1, final E2 p2, final E3 p3, final E4 p4, final E5 p5, final E6 p6) { return attempt(code, p1, p2, p3, p4, p5, p6, null); }
/** Normalize an integer value to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp((float) (($1 - $2) / ($3 - $2 + 1.0)))") public static float normalize(final int value, final int minInclusive, final int maxInclusive) { // We count in double, to prevent issues with overflows if the entire int range is used // Clamps value, just in case. return clamp((float) ((value - minInclusive) / (maxInclusive - minInclusive + 1.0))); }
/** Normalize a long value to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp((float) (($1 - $2) / ($3 - $2 + 1.0)))") public static float normalize(final long value, final long minInclusive, final long maxInclusive) { // We count in double, to prevent issues with overflows if the entire long range is used // Clamps value, just in case. return clamp((float) ((value - minInclusive) / (maxInclusive - minInclusive + 1.0))); }
/** Normalize a float value to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp(($1 - $2) / ($3 - $2))") public static float normalize(final float value, final float minInclusive, final float maxInclusive) { // Clamps value, just in case. return clamp((value - minInclusive) / (maxInclusive - minInclusive)); }
/** Normalize a double value to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp((float) (($1 - $2) / ($3 - $2)))") public static float normalize(final double value, final double minInclusive, final double maxInclusive) { // Clamps value, just in case. return clamp((float) ((value - minInclusive) / (maxInclusive - minInclusive))); }
/** Normalize an integer value starting at 0 to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp((float) ($1 / ($2 + 1.0)))") public static float onormalize(final int value, final int maxInclusive) { // We count in double, to prevent issues with overflows if the entire int range is used // Clamps value, just in case. return clamp((float) (value / (maxInclusive + 1.0))); }
/** Normalize a long value starting at 0 to the fuzzy logic range. */ @Pure @Inline("com.blockwithme.util.xtend.FuzzyExtension.clamp((float) ($1 / ($2 + 1.0)))") public static float onormalize(final long value, final long maxInclusive) { // We count in double, to prevent issues with overflows if the entire long range is used // Clamps value, just in case. return clamp((float) (value / (maxInclusive + 1.0))); }
/** Converts a Dictionary to an int (null == 0, otherwise size). */ @GwtIncompatible @Pure @Inline("(($1 == null) ? 0 : $1.size())") public static int operator_plus(final Dictionary<?, ?> value) { return (value == null) ? 0 : value.size(); }
public JvmAnnotationReference findInlineAnnotation(final JvmIdentifiableElement feature) { if (feature instanceof JvmAnnotationTarget) { return findAnnotation((JvmAnnotationTarget) feature, Inline.class.getName()); } return null; }
@Inline(value = "1", constantExpression = true) public int getValue() { return 1; }
@Inline(value = "1", constantExpression = false) public int getValue2() { return 1; }
@Inline(value = "assert $1", statementExpression = false) public static void assertIt(final boolean condition) { throw new UnsupportedOperationException(); }
@Inline(value = "assert $1 != null", statementExpression = false) public static void assertNotNull(final Object object) { throw new UnsupportedOperationException(); }
@Inline("new $3[$1]") public static <T> T[] createArray(final int size) { throw new UnsupportedOperationException(); }
@Inline("new $4[$1][$2]") public static <T> T[][] createArray(final int outerSize, final int innerSize) { throw new UnsupportedOperationException(); }
@Inline("new int[$1][$2]") public static int[][] intArray(final int outerSize, final int innerSize) { throw new UnsupportedOperationException(); }
@Inline("new float[$1]") public static float[] floatArray(final int outerSize) { throw new UnsupportedOperationException(); }
@Inline(value = "if($1) return;", statementExpression = false) public static void returnif(final boolean condition) { throw new UnsupportedOperationException(); }
@Inline(value = "if(!$1) return;", statementExpression = false) public static void returnifNot(final boolean condition) { throw new UnsupportedOperationException(); }
@Inline(value = "if($1) break;", statementExpression = false) public static void breakif(final boolean condition) { throw new UnsupportedOperationException(); }
@Inline(value = "if($1) continue;", statementExpression = false) public static void continueif(final boolean condition) { throw new UnsupportedOperationException(); }
@Pure @Inline("new com.blockwithme.util.xtend.TBBO<E2>($1,$2,$3)") public static <E2> TBBO<E2> $(final boolean p0, final boolean p1, final E2 p2) { return new TBBO<E2>(p0, p1, p2); }
/** * Log a DEBUG message. * @param error The error */ @Inline("$1.log(com.blockwithme.util.xtend.JavaUtilLoggingExtension.JUL_DEBUG, String.valueOf($2), $2)") public static void debug(final Logger log, final Throwable error) { log.log(JUL_DEBUG, String.valueOf(error), error); }
/** * Log a DEBUG message. * @param msg The message */ @Inline("$1.log(com.blockwithme.util.xtend.JavaUtilLoggingExtension.JUL_DEBUG, String.valueOf($2))") public static void debug(final Logger log, final Object msg) { log.log(JUL_DEBUG, String.valueOf(msg)); }
/** * Log a DEBUG message. * @param msg The message * @param error The error */ @Inline("$1.log(com.blockwithme.util.xtend.JavaUtilLoggingExtension.JUL_DEBUG, $2, $3)") public static void debug(final Logger log, final String msg, final Throwable error) { log.log(JUL_DEBUG, msg, error); }
/** * Log a DEBUG message. * @param msg The message * @param error The error */ @Inline("$1.log(com.blockwithme.util.xtend.JavaUtilLoggingExtension.JUL_DEBUG, String.valueOf($2), $3)") public static void debug(final Logger log, final Object msg, final Throwable error) { log.log(JUL_DEBUG, String.valueOf(msg), error); }
/** * Log an INFO message. * @param error The error */ @Inline("$1.log(java.util.logging.Level.INFO, String.valueOf($2), $2)") public static void info(final Logger log, final Throwable error) { log.log(Level.INFO, String.valueOf(error), error); }
@Pure @Inline("new com.blockwithme.util.xtend.TOOB<E0,E1>($1,$2,$3)") public static <E0, E1> TOOB<E0, E1> $(final E0 p0, final E1 p1, final boolean p2) { return new TOOB<E0, E1>(p0, p1, p2); }
/** * Log an INFO message. * @param msg The message * @param error The error */ @Inline("$1.log(java.util.logging.Level.INFO, $2, $3)") public static void info(final Logger log, final String msg, final Throwable error) { log.log(Level.INFO, msg, error); }
/** * Log an INFO message. * @param msg The message * @param error The error */ @Inline("$1.log(java.util.logging.Level.INFO, String.valueOf($2), $3)") public static void info(final Logger log, final Object msg, final Throwable error) { log.log(Level.INFO, String.valueOf(msg), error); }
@Pure @Inline("new com.blockwithme.util.xtend.TDOD($1,$2,$3)") public static <E1> TDOD<E1> $(final double p0, final E1 p1, final double p2) { return new TDOD<E1>(p0, p1, p2); }
/** * Log a WARNING message. * @param error The error */ @Inline("$1.log(java.util.logging.Level.WARNING, String.valueOf($2), $2)") public static void warn(final Logger log, final Throwable error) { log.log(Level.WARNING, String.valueOf(error), error); }
/** * Log a WARNING message. * @param msg The message */ @Inline("$1.log(java.util.logging.Level.WARNING, String.valueOf($2))") public static void warn(final Logger log, final Object msg) { log.log(Level.WARNING, String.valueOf(msg)); }
@Pure @Inline("new com.blockwithme.util.xtend.TDBD($1,$2,$3)") public static TDBD $(final double p0, final boolean p1, final double p2) { return new TDBD(p0, p1, p2); }
/** * Log a WARNING message. * @param msg The message * @param error The error */ @Inline("$1.log(java.util.logging.Level.WARNING, String.valueOf($2), $3)") public static void warn(final Logger log, final Object msg, final Throwable error) { log.log(Level.WARNING, String.valueOf(msg), error); }
/** * Log an ERROR message. * @param msg The message */ @Inline("$1.log(java.util.logging.Level.SEVERE, $2)") public static void error(final Logger log, final String msg) { log.log(Level.SEVERE, msg); }
/** * Log an ERROR message. * @param msg The message */ @Inline("$1.log(java.util.logging.Level.SEVERE, String.valueOf($2))") public static void error(final Logger log, final Object msg) { log.log(Level.SEVERE, String.valueOf(msg)); }