package io.github.xxyy.common.util;

import org.apache.commons.lang.math.RandomUtils;

/**
 * A class providing some miscellaneous static utilities.
 * 
 * @author <a href="http://xxyy.github.io/">xxyy</a>
 */
public abstract class MiscHelper
{
    /**
     * @return a semi-random element from {@code clazz}.
     */
    public static <T extends Enum<?>> T randomEnumElement(Class<T> clazz){
        T[] values = clazz.getEnumConstants();//each call copies an array!
        return values[RandomUtils.nextInt(values.length)];
    }
}

@@ -525,11 +525,455 @@
 %5D;%0A    %7D
+%0A%0A    /**%0A     * Inverts a comparator result, i.e. if the value passed is positive, -1 will be returned and if it's negative,%0A     * +1 will be returned. 0 values will be returned directly.%0A     * @param i the comparator result to invert%0A     * @return the inverted comparator result of the parameter%0A     */%0A    public static int invertCompare(int i) %7B%0A        if(i == 0) %7B%0A            return i;%0A        %7D%0A%0A        return i %3E 0 ? -1 : 1;%0A    %7D
 %0A%7D%0A

Add MiscHelper#invertCompare(int)