This commit is contained in:
Magnus Ulf 2019-03-03 21:02:50 +01:00
parent 3575de589b
commit 1589ed92d7

View File

@ -76,6 +76,8 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.regex.Pattern;
public class MUtil
@ -1747,6 +1749,18 @@ public class MUtil
{
return equalsishNumber(number1, number2);
}
// -------------------------------------------- //
// SET IF DIFFERENT
// -------------------------------------------- //
public static <T> boolean setIfDifferent(T value, Supplier<T> getter, Consumer<T> setter)
{
T currentVal = getter.get();
if (currentVal == value) return false;
setter.accept(value);
return true;
}
// -------------------------------------------- //
// SORTING