diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/EnumUtil.java b/src/main/java/xyz/zhouxy/plusone/commons/util/EnumUtil.java index 1d3091f..1d250df 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/EnumUtil.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/EnumUtil.java @@ -46,7 +46,7 @@ public final class EnumUtil { public static > E valueOf(Class clazz, int ordinal) { Preconditions.checkNotNull(clazz, "Clazz must not be null."); E[] values = clazz.getEnumConstants(); - PreconditionsExt.isTrue((ordinal >= 0 && ordinal < values.length), + PreconditionsExt.check((ordinal >= 0 && ordinal < values.length), () -> new EnumConstantNotPresentException(clazz, Integer.toString(ordinal))); return values[ordinal]; } diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java b/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java index 6726233..909dfbb 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/PreconditionsExt.java @@ -18,9 +18,16 @@ package xyz.zhouxy.plusone.commons.util; import java.util.function.Supplier; +/** + * Guava Preconditions 的扩展。 + * + * @author ZhouXY + * + * @see com.google.common.base.Preconditions + */ public class PreconditionsExt { - public static void isTrue(boolean condition, Supplier e) throws E { + public static void check(boolean condition, Supplier e) throws E { if (!condition) { throw e.get(); }