Removes rarely used InternalPreconditions.format.
PiperOrigin-RevId: 332589853
Change-Id: I620de918f78287c40ca2ac3285ed0b3aea169031
diff --git a/user/super/com/google/gwt/emul/java/lang/Enum.java b/user/super/com/google/gwt/emul/java/lang/Enum.java
index 43a00b9..13d0114 100644
--- a/user/super/com/google/gwt/emul/java/lang/Enum.java
+++ b/user/super/com/google/gwt/emul/java/lang/Enum.java
@@ -19,9 +19,7 @@
import static javaemul.internal.InternalPreconditions.checkNotNull;
import com.google.gwt.core.client.JavaScriptObject;
-
import java.io.Serializable;
-
import jsinterop.annotations.JsIgnore;
import jsinterop.annotations.JsNonNull;
import jsinterop.annotations.JsType;
@@ -55,7 +53,7 @@
checkNotNull(name);
T result = Enum.<T> get0(map, ":" + name);
- checkCriticalArgument(result != null, "Enum constant undefined: %s", name);
+ checkCriticalArgument(result != null, "Enum constant undefined: " + name);
return result;
}
diff --git a/user/super/com/google/gwt/emul/java/util/Arrays.java b/user/super/com/google/gwt/emul/java/util/Arrays.java
index 7af525f..3ddb92a 100644
--- a/user/super/com/google/gwt/emul/java/util/Arrays.java
+++ b/user/super/com/google/gwt/emul/java/util/Arrays.java
@@ -606,7 +606,7 @@
}
private static void checkCopyOfRange(Object original, int from, int to) {
- checkArgument(from <= to, "%s > %s", from, to);
+ checkArgument(from <= to, from + " > " + to);
int len = ArrayHelper.getLength(original);
checkCriticalArrayBounds(from, from, len);
}
diff --git a/user/super/com/google/gwt/emul/java/util/EnumSet.java b/user/super/com/google/gwt/emul/java/util/EnumSet.java
index 7399e3a..e3594ef 100644
--- a/user/super/com/google/gwt/emul/java/util/EnumSet.java
+++ b/user/super/com/google/gwt/emul/java/util/EnumSet.java
@@ -232,7 +232,7 @@
}
public static <E extends Enum<E>> EnumSet<E> range(E from, E to) {
- checkArgument(from.compareTo(to) <= 0, "%s > %s", from, to);
+ checkArgument(from.compareTo(to) <= 0, from + " > " + to);
E[] all = from.getDeclaringClass().getEnumConstants();
E[] set = ArrayHelper.createFrom(all, all.length);
diff --git a/user/super/com/google/gwt/emul/javaemul/internal/InternalPreconditions.java b/user/super/com/google/gwt/emul/javaemul/internal/InternalPreconditions.java
index a66c330..f41d857 100644
--- a/user/super/com/google/gwt/emul/javaemul/internal/InternalPreconditions.java
+++ b/user/super/com/google/gwt/emul/javaemul/internal/InternalPreconditions.java
@@ -324,35 +324,6 @@
}
/**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- */
- public static void checkArgument(boolean expression, String errorMessageTemplate,
- Object... errorMessageArgs) {
- if (IS_API_CHECKED) {
- checkCriticalArgument(expression, errorMessageTemplate, errorMessageArgs);
- } else if (IS_ASSERTED) {
- try {
- checkCriticalArgument(expression, errorMessageTemplate, errorMessageArgs);
- } catch (Exception e) {
- throw new AssertionError(e);
- }
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- * <p>
- * For cases where failing fast is pretty important and not failing early could cause bugs that
- * are much harder to debug.
- */
- public static void checkCriticalArgument(boolean expression, String errorMessageTemplate,
- Object... errorMessageArgs) {
- if (!expression) {
- throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
- }
- }
-
- /**
* Ensures the truth of an expression involving the state of the calling instance, but not
* involving any parameters to the calling method.
*
@@ -615,44 +586,6 @@
}
}
- /**
- * Substitutes each {@code %s} in {@code template} with an argument. These are matched by
- * position: the first {@code %s} gets {@code args[0]}, etc. If there are more arguments than
- * placeholders, the unmatched arguments will be appended to the end of the formatted message in
- * square braces.
- */
- private static String format(String template, Object... args) {
- template = String.valueOf(template); // null -> "null"
-
- // start substituting the arguments into the '%s' placeholders
- StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
- int templateStart = 0;
- int i = 0;
- while (i < args.length) {
- int placeholderStart = template.indexOf("%s", templateStart);
- if (placeholderStart == -1) {
- break;
- }
- builder.append(template.substring(templateStart, placeholderStart));
- builder.append(args[i++]);
- templateStart = placeholderStart + 2;
- }
- builder.append(template.substring(templateStart));
-
- // if we run out of placeholders, append the extra args in square braces
- if (i < args.length) {
- builder.append(" [");
- builder.append(args[i++]);
- while (i < args.length) {
- builder.append(", ");
- builder.append(args[i++]);
- }
- builder.append(']');
- }
-
- return builder.toString();
- }
-
// Hides the constructor for this static utility class.
private InternalPreconditions() { }
}