forked from plusone/plusone-commons
添加重载方法;修改参数名。
parent
1c5d5d4129
commit
625dd01e63
|
@ -11,39 +11,51 @@ import com.google.common.base.Strings;
|
||||||
public class Assert {
|
public class Assert {
|
||||||
|
|
||||||
// isTrue
|
// isTrue
|
||||||
public static <E extends Throwable> void isTrue(@Nullable Boolean conditions, Supplier<E> e) throws E {
|
public static <E extends Throwable> void isTrue(@Nullable Boolean condition, Supplier<E> e) throws E {
|
||||||
if (!Boolean.TRUE.equals(conditions)) {
|
if (!Boolean.TRUE.equals(condition)) {
|
||||||
throw e.get();
|
throw e.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isTrue(@Nullable Boolean conditions, String errorMessage) {
|
public static void isTrue(@Nullable Boolean condition) {
|
||||||
if (!Boolean.TRUE.equals(conditions)) {
|
if (!Boolean.TRUE.equals(condition)) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isTrue(@Nullable Boolean condition, String errorMessage) {
|
||||||
|
if (!Boolean.TRUE.equals(condition)) {
|
||||||
throw new IllegalArgumentException(errorMessage);
|
throw new IllegalArgumentException(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isTrue(@Nullable Boolean conditions, String errorMessageTemplate, Object... args) {
|
public static void isTrue(@Nullable Boolean condition, String errorMessageTemplate, Object... args) {
|
||||||
if (!Boolean.TRUE.equals(conditions)) {
|
if (!Boolean.TRUE.equals(condition)) {
|
||||||
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// isFalse
|
// isFalse
|
||||||
public static <E extends Throwable> void isFalse(@Nullable Boolean conditions, Supplier<E> e) throws E {
|
public static <E extends Throwable> void isFalse(@Nullable Boolean condition, Supplier<E> e) throws E {
|
||||||
if (!Boolean.FALSE.equals(conditions)) {
|
if (!Boolean.FALSE.equals(condition)) {
|
||||||
throw e.get();
|
throw e.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isFalse(@Nullable Boolean conditions, String errorMessage) {
|
public static void isFalse(@Nullable Boolean condition) {
|
||||||
if (!Boolean.FALSE.equals(conditions)) {
|
if (!Boolean.FALSE.equals(condition)) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void isFalse(@Nullable Boolean condition, String errorMessage) {
|
||||||
|
if (!Boolean.FALSE.equals(condition)) {
|
||||||
throw new IllegalArgumentException(errorMessage);
|
throw new IllegalArgumentException(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void isFalse(@Nullable Boolean conditions, String errorMessageTemplate, Object... args) {
|
public static void isFalse(@Nullable Boolean condition, String errorMessageTemplate, Object... args) {
|
||||||
if (!Boolean.FALSE.equals(conditions)) {
|
if (!Boolean.FALSE.equals(condition)) {
|
||||||
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
throw new IllegalArgumentException(String.format(errorMessageTemplate, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue