Add first part of a persistent map implementation.
This commit is contained in:
32
pdb-utils/src/main/java/org/lucares/utils/Preconditions.java
Normal file
32
pdb-utils/src/main/java/org/lucares/utils/Preconditions.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package org.lucares.utils;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Preconditions {
|
||||
public static void checkEven(final long value, final String message) {
|
||||
if (value % 2 != 0) {
|
||||
throw new IllegalStateException(message + ". Was: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param message formatted with {@link MessageFormat}
|
||||
* @param args
|
||||
*/
|
||||
public static void checkGreater(final long a, final long b, final String message, final Object... args) {
|
||||
|
||||
if (a <= b) {
|
||||
throw new IllegalStateException(MessageFormat.format(message, args) + " Expected: " + a + " > " + b);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkEqual(final Object actual, final Object expected) {
|
||||
if (!Objects.equals(actual, expected)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user