T firstNonNull(@Nullable T first, @Nullable T second) {
- return first != null ? first : checkNotNull(second);
- }
-
- /**
- * Creates an instance of {@link ToStringHelper}.
- *
- * This is helpful for implementing {@link Object#toString()}.
- * Specification by example:
{@code
- * // Returns "ClassName{}"
- * MoreObjects.toStringHelper(this)
- * .toString();
- *
- * // Returns "ClassName{x=1}"
- * MoreObjects.toStringHelper(this)
- * .add("x", 1)
- * .toString();
- *
- * // Returns "MyObject{x=1}"
- * MoreObjects.toStringHelper("MyObject")
- * .add("x", 1)
- * .toString();
- *
- * // Returns "ClassName{x=1, y=foo}"
- * MoreObjects.toStringHelper(this)
- * .add("x", 1)
- * .add("y", "foo")
- * .toString();
- *
- * // Returns "ClassName{x=1}"
- * MoreObjects.toStringHelper(this)
- * .omitNullValues()
- * .add("x", 1)
- * .add("y", null)
- * .toString();
- * }}
- *
- * Note that in GWT, class names are often obfuscated.
- *
- * @param self the object to generate the string for (typically {@code this}), used only for its
- * class name
- * @since 18.0 (since 2.0 as {@code Objects.toStringHelper()}).
- */
- @CheckReturnValue
- public static ToStringHelper toStringHelper(Object self) {
- return new ToStringHelper(self.getClass().getSimpleName());
- }
-
- /**
- * Creates an instance of {@link ToStringHelper} in the same manner as {@link
- * #toStringHelper(Object)}, but using the simple name of {@code clazz} instead of using an
- * instance's {@link Object#getClass()}.
- *
- *
Note that in GWT, class names are often obfuscated.
- *
- * @param clazz the {@link Class} of the instance
- * @since 18.0 (since 7.0 as {@code Objects.toStringHelper()}).
- */
- @CheckReturnValue
- public static ToStringHelper toStringHelper(Class> clazz) {
- return new ToStringHelper(clazz.getSimpleName());
- }
-
- /**
- * Creates an instance of {@link ToStringHelper} in the same manner as {@link
- * #toStringHelper(Object)}, but using {@code className} instead of using an instance's {@link
- * Object#getClass()}.
- *
- * @param className the name of the instance type
- * @since 18.0 (since 7.0 as {@code Objects.toStringHelper()}).
- */
- @CheckReturnValue
- public static ToStringHelper toStringHelper(String className) {
- return new ToStringHelper(className);
- }
-
- /**
- * Support class for {@link MoreObjects#toStringHelper}.
- *
- * @author Jason Lee
- * @since 18.0 (since 2.0 as {@code Objects.ToStringHelper}).
- */
- public static final class ToStringHelper {
- private final String className;
- private ValueHolder holderHead = new ValueHolder();
- private ValueHolder holderTail = holderHead;
- private boolean omitNullValues = false;
-
- /**
- * Use {@link MoreObjects#toStringHelper(Object)} to create an instance.
- */
- private ToStringHelper(String className) {
- this.className = checkNotNull(className);
- }
-
- /**
- * Configures the {@link ToStringHelper} so {@link #toString()} will ignore
- * properties with null value. The order of calling this method, relative
- * to the {@code add()}/{@code addValue()} methods, is not significant.
- *
- * @since 18.0 (since 12.0 as {@code Objects.ToStringHelper.omitNullValues()}).
- */
- public ToStringHelper omitNullValues() {
- omitNullValues = true;
- return this;
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format. If {@code value} is {@code null}, the string {@code "null"}
- * is used, unless {@link #omitNullValues()} is called, in which case this
- * name/value pair will not be added.
- */
- public ToStringHelper add(String name, @Nullable Object value) {
- return addHolder(name, value);
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, boolean value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, char value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, double value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, float value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, int value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
- */
- public ToStringHelper add(String name, long value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, Object)} instead
- * and give value a readable name.
- */
- public ToStringHelper addValue(@Nullable Object value) {
- return addHolder(value);
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, boolean)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(boolean value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, char)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(char value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, double)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(double value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, float)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(float value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, int)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(int value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, long)} instead
- * and give value a readable name.
- *
- * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.addValue()}).
- */
- public ToStringHelper addValue(long value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Returns a string in the format specified by
- * {@link MoreObjects#toStringHelper(Object)}.
- *
- *
After calling this method, you can keep adding more properties to later
- * call toString() again and get a more complete representation of the
- * same object; but properties cannot be removed, so this only allows
- * limited reuse of the helper instance. The helper allows duplication of
- * properties (multiple name/value pairs with the same name can be added).
- */
- @CheckReturnValue
- @Override
- public String toString() {
- // create a copy to keep it consistent in case value changes
- boolean omitNullValuesSnapshot = omitNullValues;
- String nextSeparator = "";
- StringBuilder builder = new StringBuilder(32).append(className).append('{');
- for (ValueHolder valueHolder = holderHead.next;
- valueHolder != null;
- valueHolder = valueHolder.next) {
- Object value = valueHolder.value;
- if (!omitNullValuesSnapshot || value != null) {
- builder.append(nextSeparator);
- nextSeparator = ", ";
-
- if (valueHolder.name != null) {
- builder.append(valueHolder.name).append('=');
- }
- if (value != null && value.getClass().isArray()) {
- Object[] objectArray = {value};
- String arrayString = Arrays.deepToString(objectArray);
- builder.append(arrayString.substring(1, arrayString.length() - 1));
- } else {
- builder.append(value);
- }
- }
- }
- return builder.append('}').toString();
- }
-
- private ValueHolder addHolder() {
- ValueHolder valueHolder = new ValueHolder();
- holderTail = holderTail.next = valueHolder;
- return valueHolder;
- }
-
- private ToStringHelper addHolder(@Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- return this;
- }
-
- private ToStringHelper addHolder(String name, @Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- valueHolder.name = checkNotNull(name);
- return this;
- }
-
- private static final class ValueHolder {
- String name;
- Object value;
- ValueHolder next;
- }
- }
-
- private MoreObjects() {}
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Objects.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Objects.java
deleted file mode 100644
index 62817dacdffa..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Objects.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright (C) 2007 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.GwtCompatible;
-
-import java.util.Arrays;
-
-import javax.annotation.CheckReturnValue;
-import javax.annotation.Nullable;
-
-/**
- * Helper functions that can operate on any {@code Object}.
- *
- *
See the Guava User Guide on writing
- * {@code Object} methods with {@code Objects}.
- *
- * @author Laurence Gonsalves
- * @since 2.0
- */
-@GwtCompatible
-public final class Objects {
- private Objects() {}
-
- /**
- * Determines whether two possibly-null objects are equal. Returns:
- *
- *
- * - {@code true} if {@code a} and {@code b} are both null.
- *
- {@code true} if {@code a} and {@code b} are both non-null and they are
- * equal according to {@link Object#equals(Object)}.
- *
- {@code false} in all other situations.
- *
- *
- * This assumes that any non-null objects passed to this function conform
- * to the {@code equals()} contract.
- *
- *
Note for Java 7 and later: This method should be treated as
- * deprecated; use {@link java.util.Objects#equals} instead.
- */
- @CheckReturnValue
- public static boolean equal(@Nullable Object a, @Nullable Object b) {
- return a == b || (a != null && a.equals(b));
- }
-
- /**
- * Generates a hash code for multiple values. The hash code is generated by
- * calling {@link Arrays#hashCode(Object[])}. Note that array arguments to
- * this method, with the exception of a single Object array, do not get any
- * special handling; their hash codes are based on identity and not contents.
- *
- *
This is useful for implementing {@link Object#hashCode()}. For example,
- * in an object that has three properties, {@code x}, {@code y}, and
- * {@code z}, one could write:
- *
{@code
- * public int hashCode() {
- * return Objects.hashCode(getX(), getY(), getZ());
- * }}
- *
- * Warning: When a single object is supplied, the returned hash code
- * does not equal the hash code of that object.
- *
- *
Note for Java 7 and later: This method should be treated as
- * deprecated; use {@link java.util.Objects#hash} instead.
- */
- @CheckReturnValue
- public static int hashCode(@Nullable Object... objects) {
- return Arrays.hashCode(objects);
- }
-
- /**
- * Creates an instance of {@link ToStringHelper}.
- *
- *
This is helpful for implementing {@link Object#toString()}.
- * Specification by example:
{@code
- * // Returns "ClassName{}"
- * Objects.toStringHelper(this)
- * .toString();
- *
- * // Returns "ClassName{x=1}"
- * Objects.toStringHelper(this)
- * .add("x", 1)
- * .toString();
- *
- * // Returns "MyObject{x=1}"
- * Objects.toStringHelper("MyObject")
- * .add("x", 1)
- * .toString();
- *
- * // Returns "ClassName{x=1, y=foo}"
- * Objects.toStringHelper(this)
- * .add("x", 1)
- * .add("y", "foo")
- * .toString();
- *
- * // Returns "ClassName{x=1}"
- * Objects.toStringHelper(this)
- * .omitNullValues()
- * .add("x", 1)
- * .add("y", null)
- * .toString();
- * }}
- *
- * Note that in GWT, class names are often obfuscated.
- *
- * @param self the object to generate the string for (typically {@code this}),
- * used only for its class name
- * @since 2.0
- * @deprecated Use {@link MoreObjects#toStringHelper(Object)} instead. This
- * method is scheduled for removal in June 2016.
- */
- @CheckReturnValue
- @Deprecated
- public static ToStringHelper toStringHelper(Object self) {
- return new ToStringHelper(self.getClass().getSimpleName());
- }
-
- /**
- * Creates an instance of {@link ToStringHelper} in the same manner as
- * {@link Objects#toStringHelper(Object)}, but using the name of {@code clazz}
- * instead of using an instance's {@link Object#getClass()}.
- *
- *
Note that in GWT, class names are often obfuscated.
- *
- * @param clazz the {@link Class} of the instance
- * @since 7.0 (source-compatible since 2.0)
- * @deprecated Use {@link MoreObjects#toStringHelper(Class)} instead. This
- * method is scheduled for removal in June 2016.
- */
- @CheckReturnValue
- @Deprecated
- public static ToStringHelper toStringHelper(Class> clazz) {
- return new ToStringHelper(clazz.getSimpleName());
- }
-
- /**
- * Creates an instance of {@link ToStringHelper} in the same manner as
- * {@link Objects#toStringHelper(Object)}, but using {@code className} instead
- * of using an instance's {@link Object#getClass()}.
- *
- * @param className the name of the instance type
- * @since 7.0 (source-compatible since 2.0)
- * @deprecated Use {@link MoreObjects#toStringHelper(String)} instead. This
- * method is scheduled for removal in June 2016.
- */
- @CheckReturnValue
- @Deprecated
- public static ToStringHelper toStringHelper(String className) {
- return new ToStringHelper(className);
- }
-
- /**
- * Returns the first of two given parameters that is not {@code null}, if
- * either is, or otherwise throws a {@link NullPointerException}.
- *
- *
Note: if {@code first} is represented as an {@link Optional},
- * this can be accomplished with
- * {@linkplain Optional#or(Object) first.or(second)}.
- * That approach also allows for lazy evaluation of the fallback instance,
- * using {@linkplain Optional#or(Supplier) first.or(Supplier)}.
- *
- * @return {@code first} if {@code first} is not {@code null}, or
- * {@code second} if {@code first} is {@code null} and {@code second} is
- * not {@code null}
- * @throws NullPointerException if both {@code first} and {@code second} were
- * {@code null}
- * @since 3.0
- * @deprecated Use {@link MoreObjects#firstNonNull} instead. This method is
- * scheduled for removal in June 2016.
- */
- @CheckReturnValue
- @Deprecated
- public static T firstNonNull(@Nullable T first, @Nullable T second) {
- return MoreObjects.firstNonNull(first, second);
- }
-
- /**
- * Support class for {@link Objects#toStringHelper}.
- *
- * @author Jason Lee
- * @since 2.0
- * @deprecated Use {@link MoreObjects.ToStringHelper} instead. This class is
- * scheduled for removal in June 2016.
- */
- @Deprecated
- public static final class ToStringHelper {
- private final String className;
- private ValueHolder holderHead = new ValueHolder();
- private ValueHolder holderTail = holderHead;
- private boolean omitNullValues = false;
-
- /**
- * Use {@link Objects#toStringHelper(Object)} to create an instance.
- */
- private ToStringHelper(String className) {
- this.className = checkNotNull(className);
- }
-
- /**
- * Configures the {@link ToStringHelper} so {@link #toString()} will ignore
- * properties with null value. The order of calling this method, relative
- * to the {@code add()}/{@code addValue()} methods, is not significant.
- *
- * @since 12.0
- */
- public ToStringHelper omitNullValues() {
- omitNullValues = true;
- return this;
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format. If {@code value} is {@code null}, the string {@code "null"}
- * is used, unless {@link #omitNullValues()} is called, in which case this
- * name/value pair will not be added.
- */
- public ToStringHelper add(String name, @Nullable Object value) {
- return addHolder(name, value);
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, boolean value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, char value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, double value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, float value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, int value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds a name/value pair to the formatted output in {@code name=value}
- * format.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper add(String name, long value) {
- return addHolder(name, String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, Object)} instead
- * and give value a readable name.
- */
- public ToStringHelper addValue(@Nullable Object value) {
- return addHolder(value);
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, boolean)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(boolean value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, char)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(char value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, double)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(double value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, float)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(float value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, int)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(int value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- *
It is strongly encouraged to use {@link #add(String, long)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(long value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Returns a string in the format specified by {@link
- * Objects#toStringHelper(Object)}.
- *
- *
After calling this method, you can keep adding more properties to later
- * call toString() again and get a more complete representation of the
- * same object; but properties cannot be removed, so this only allows
- * limited reuse of the helper instance. The helper allows duplication of
- * properties (multiple name/value pairs with the same name can be added).
- */
- @Override
- public String toString() {
- // create a copy to keep it consistent in case value changes
- boolean omitNullValuesSnapshot = omitNullValues;
- String nextSeparator = "";
- StringBuilder builder = new StringBuilder(32).append(className).append('{');
- for (ValueHolder valueHolder = holderHead.next;
- valueHolder != null;
- valueHolder = valueHolder.next) {
- if (!omitNullValuesSnapshot || valueHolder.value != null) {
- builder.append(nextSeparator);
- nextSeparator = ", ";
-
- if (valueHolder.name != null) {
- builder.append(valueHolder.name).append('=');
- }
- builder.append(valueHolder.value);
- }
- }
- return builder.append('}').toString();
- }
-
- private ValueHolder addHolder() {
- ValueHolder valueHolder = new ValueHolder();
- holderTail = holderTail.next = valueHolder;
- return valueHolder;
- }
-
- private ToStringHelper addHolder(@Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- return this;
- }
-
- private ToStringHelper addHolder(String name, @Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- valueHolder.name = checkNotNull(name);
- return this;
- }
-
- private static final class ValueHolder {
- String name;
- Object value;
- ValueHolder next;
- }
- }
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Optional.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Optional.java
deleted file mode 100644
index 6c4724b75d03..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Optional.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (C) 2011 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.annotations.GwtCompatible;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.annotation.CheckReturnValue;
-import javax.annotation.Nullable;
-
-/**
- * An immutable object that may contain a non-null reference to another object. Each
- * instance of this type either contains a non-null reference, or contains nothing (in
- * which case we say that the reference is "absent"); it is never said to "contain {@code
- * null}".
- *
- *
A non-null {@code Optional} reference can be used as a replacement for a nullable
- * {@code T} reference. It allows you to represent "a {@code T} that must be present" and
- * a "a {@code T} that might be absent" as two distinct types in your program, which can
- * aid clarity.
- *
- * Some uses of this class include
- *
- *
- * - As a method return type, as an alternative to returning {@code null} to indicate
- * that no value was available
- *
- To distinguish between "unknown" (for example, not present in a map) and "known to
- * have no value" (present in the map, with value {@code Optional.absent()})
- *
- To wrap nullable references for storage in a collection that does not support
- * {@code null} (though there are
- *
- * several other approaches to this that should be considered first)
- *
- *
- * A common alternative to using this class is to find or create a suitable
- * null object for the
- * type in question.
- *
- *
This class is not intended as a direct analogue of any existing "option" or "maybe"
- * construct from other programming environments, though it may bear some similarities.
- *
- *
Comparison to {@code java.util.Optional} (JDK 8 and higher): A new {@code Optional}
- * class was added for Java 8. The two classes are extremely similar, but incompatible (they cannot
- * share a common supertype). All known differences are listed either here or with the
- * relevant methods below.
- *
- *
- * - This class is serializable; {@code java.util.Optional} is not.
- *
- {@code java.util.Optional} has the additional methods {@code ifPresent}, {@code filter},
- * {@code flatMap}, and {@code orElseThrow}.
- *
- {@code java.util} offers the primitive-specialized versions {@code OptionalInt}, {@code
- * OptionalLong} and {@code OptionalDouble}, the use of which is recommended; Guava does not
- * have these.
- *
- *
- * There are no plans to deprecate this class in the foreseeable future. However, we do
- * gently recommend that you prefer the new, standard Java class whenever possible.
- *
- *
See the Guava User Guide article on
- * using {@code Optional}.
- *
- * @param the type of instance that can be contained. {@code Optional} is naturally
- * covariant on this type, so it is safe to cast an {@code Optional} to {@code
- * Optional} for any supertype {@code S} of {@code T}.
- * @author Kurt Alfred Kluever
- * @author Kevin Bourrillion
- * @since 10.0
- */
-@CheckReturnValue
-@GwtCompatible(serializable = true)
-public abstract class Optional implements Serializable {
- /**
- * Returns an {@code Optional} instance with no contained reference.
- *
- * Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's
- * {@code Optional.empty}.
- */
- public static Optional absent() {
- return Absent.withType();
- }
-
- /**
- * Returns an {@code Optional} instance containing the given non-null reference. To have {@code
- * null} treated as {@link #absent}, use {@link #fromNullable} instead.
- *
- * Comparison to {@code java.util.Optional}: no differences.
- *
- * @throws NullPointerException if {@code reference} is null
- */
- public static Optional of(T reference) {
- return new Present(checkNotNull(reference));
- }
-
- /**
- * If {@code nullableReference} is non-null, returns an {@code Optional} instance containing that
- * reference; otherwise returns {@link Optional#absent}.
- *
- * Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's
- * {@code Optional.ofNullable}.
- */
- public static Optional fromNullable(@Nullable T nullableReference) {
- return (nullableReference == null)
- ? Optional.absent()
- : new Present(nullableReference);
- }
-
- Optional() {}
-
- /**
- * Returns {@code true} if this holder contains a (non-null) instance.
- *
- * Comparison to {@code java.util.Optional}: no differences.
- */
- public abstract boolean isPresent();
-
- /**
- * Returns the contained instance, which must be present. If the instance might be
- * absent, use {@link #or(Object)} or {@link #orNull} instead.
- *
- *
Comparison to {@code java.util.Optional}: when the value is absent, this method
- * throws {@link IllegalStateException}, whereas the Java 8 counterpart throws {@link
- * NoSuchElementException}.
- *
- * @throws IllegalStateException if the instance is absent ({@link #isPresent} returns
- * {@code false}); depending on this specific exception type (over the more general
- * {@link RuntimeException}) is discouraged
- */
- public abstract T get();
-
- /**
- * Returns the contained instance if it is present; {@code defaultValue} otherwise. If
- * no default value should be required because the instance is known to be present, use
- * {@link #get()} instead. For a default value of {@code null}, use {@link #orNull}.
- *
- *
Note about generics: The signature {@code public T or(T defaultValue)} is overly
- * restrictive. However, the ideal signature, {@code public S or(S)}, is not legal
- * Java. As a result, some sensible operations involving subtypes are compile errors:
- * {@code
- *
- * Optional optionalInt = getSomeOptionalInt();
- * Number value = optionalInt.or(0.5); // error
- *
- * FluentIterable extends Number> numbers = getSomeNumbers();
- * Optional extends Number> first = numbers.first();
- * Number value = first.or(0.5); // error}
- *
- *
As a workaround, it is always safe to cast an {@code Optional extends T>} to {@code
- * Optional}. Casting either of the above example {@code Optional} instances to {@code
- * Optional} (where {@code Number} is the desired output type) solves the problem:
- * {@code
- *
- * Optional optionalInt = (Optional) getSomeOptionalInt();
- * Number value = optionalInt.or(0.5); // fine
- *
- * FluentIterable extends Number> numbers = getSomeNumbers();
- * Optional first = (Optional) numbers.first();
- * Number value = first.or(0.5); // fine}
- *
- * Comparison to {@code java.util.Optional}: this method is similar to Java 8's
- * {@code Optional.orElse}, but will not accept {@code null} as a {@code defaultValue} ({@link
- * #orNull} must be used instead). As a result, the value returned by this method is guaranteed
- * non-null, which is not the case for the {@code java.util} equivalent.
- */
- public abstract T or(T defaultValue);
-
- /**
- * Returns this {@code Optional} if it has a value present; {@code secondChoice}
- * otherwise.
- *
- *
Comparison to {@code java.util.Optional}: this method has no equivalent in Java 8's
- * {@code Optional} class; write {@code thisOptional.isPresent() ? thisOptional : secondChoice}
- * instead.
- */
- public abstract Optional or(Optional extends T> secondChoice);
-
- /**
- * Returns the contained instance if it is present; {@code supplier.get()} otherwise.
- *
- * Comparison to {@code java.util.Optional}: this method is similar to Java 8's
- * {@code Optional.orElseGet}, except when {@code supplier} returns {@code null}. In this case
- * this method throws an exception, whereas the Java 8 method returns the {@code null} to the
- * caller.
- *
- * @throws NullPointerException if this optional's value is absent and the supplier returns
- * {@code null}
- */
- @Beta
- public abstract T or(Supplier extends T> supplier);
-
- /**
- * Returns the contained instance if it is present; {@code null} otherwise. If the
- * instance is known to be present, use {@link #get()} instead.
- *
- *
Comparison to {@code java.util.Optional}: this method is equivalent to Java 8's
- * {@code Optional.orElse(null)}.
- */
- @Nullable
- public abstract T orNull();
-
- /**
- * Returns an immutable singleton {@link Set} whose only element is the contained instance
- * if it is present; an empty immutable {@link Set} otherwise.
- *
- *
Comparison to {@code java.util.Optional}: this method has no equivalent in Java 8's
- * {@code Optional} class. However, this common usage:
{@code
- *
- * for (Foo foo : possibleFoo.asSet()) {
- * doSomethingWith(foo);
- * }}
- *
- * ... can be replaced with: {@code
- *
- * possibleFoo.ifPresent(foo -> doSomethingWith(foo));}
- *
- * @since 11.0
- */
- public abstract Set asSet();
-
- /**
- * If the instance is present, it is transformed with the given {@link Function}; otherwise,
- * {@link Optional#absent} is returned.
- *
- * Comparison to {@code java.util.Optional}: this method is similar to Java 8's
- * {@code Optional.map}, except when {@code function} returns {@code null}. In this case this
- * method throws an exception, whereas the Java 8 method returns {@code Optional.absent()}.
- *
- * @throws NullPointerException if the function returns {@code null}
- * @since 12.0
- */
- public abstract Optional transform(Function super T, V> function);
-
- /**
- * Returns {@code true} if {@code object} is an {@code Optional} instance, and either
- * the contained references are {@linkplain Object#equals equal} to each other or both
- * are absent. Note that {@code Optional} instances of differing parameterized types can
- * be equal.
- *
- * Comparison to {@code java.util.Optional}: no differences.
- */
- @Override
- public abstract boolean equals(@Nullable Object object);
-
- /**
- * Returns a hash code for this instance.
- *
- *
Comparison to {@code java.util.Optional}: this class leaves the specific choice of
- * hash code unspecified, unlike the Java 8 equivalent.
- */
- @Override
- public abstract int hashCode();
-
- /**
- * Returns a string representation for this instance.
- *
- *
Comparison to {@code java.util.Optional}: this class leaves the specific string
- * representation unspecified, unlike the Java 8 equivalent.
- */
- @Override
- public abstract String toString();
-
- /**
- * Returns the value of each present instance from the supplied {@code optionals}, in order,
- * skipping over occurrences of {@link Optional#absent}. Iterators are unmodifiable and are
- * evaluated lazily.
- *
- *
Comparison to {@code java.util.Optional}: this method has no equivalent in Java 8's
- * {@code Optional} class; use
- * {@code optionals.stream().filter(Optional::isPresent).map(Optional::get)} instead.
- *
- * @since 11.0 (generics widened in 13.0)
- */
- @Beta
- public static Iterable presentInstances(
- final Iterable extends Optional extends T>> optionals) {
- checkNotNull(optionals);
- return new Iterable() {
- @Override
- public Iterator iterator() {
- return new AbstractIterator() {
- private final Iterator extends Optional extends T>> iterator =
- checkNotNull(optionals.iterator());
-
- @Override
- protected T computeNext() {
- while (iterator.hasNext()) {
- Optional extends T> optional = iterator.next();
- if (optional.isPresent()) {
- return optional.get();
- }
- }
- return endOfData();
- }
- };
- }
- };
- }
-
- private static final long serialVersionUID = 0;
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/PairwiseEquivalence.java b/thirdparty/google-guava/src/main/java/com/google/common/base/PairwiseEquivalence.java
deleted file mode 100644
index d409d2451b72..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/PairwiseEquivalence.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2011 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-import javax.annotation.Nullable;
-
-@GwtCompatible(serializable = true)
-final class PairwiseEquivalence extends Equivalence> implements Serializable {
-
- final Equivalence super T> elementEquivalence;
-
- PairwiseEquivalence(Equivalence super T> elementEquivalence) {
- this.elementEquivalence = Preconditions.checkNotNull(elementEquivalence);
- }
-
- @Override
- protected boolean doEquivalent(Iterable iterableA, Iterable iterableB) {
- Iterator iteratorA = iterableA.iterator();
- Iterator iteratorB = iterableB.iterator();
-
- while (iteratorA.hasNext() && iteratorB.hasNext()) {
- if (!elementEquivalence.equivalent(iteratorA.next(), iteratorB.next())) {
- return false;
- }
- }
-
- return !iteratorA.hasNext() && !iteratorB.hasNext();
- }
-
- @Override
- protected int doHash(Iterable iterable) {
- int hash = 78721;
- for (T element : iterable) {
- hash = hash * 24943 + elementEquivalence.hash(element);
- }
- return hash;
- }
-
- @Override
- public boolean equals(@Nullable Object object) {
- if (object instanceof PairwiseEquivalence) {
- PairwiseEquivalence> that = (PairwiseEquivalence>) object;
- return this.elementEquivalence.equals(that.elementEquivalence);
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- return elementEquivalence.hashCode() ^ 0x46a3eb07;
- }
-
- @Override
- public String toString() {
- return elementEquivalence + ".pairwise()";
- }
-
- private static final long serialVersionUID = 1;
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Platform.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Platform.java
deleted file mode 100644
index 8debd9199b04..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Platform.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-
-import java.lang.ref.WeakReference;
-
-/**
- * Methods factored out so that they can be emulated differently in GWT.
- *
- * @author Jesse Wilson
- */
-@GwtCompatible(emulated = true)
-final class Platform {
- private Platform() {}
-
- /** Calls {@link System#nanoTime()}. */
- static long systemNanoTime() {
- return System.nanoTime();
- }
-
- static CharMatcher precomputeCharMatcher(CharMatcher matcher) {
- return matcher.precomputedInternal();
- }
-
- static > Optional getEnumIfPresent(Class enumClass, String value) {
- WeakReference extends Enum>> ref = Enums.getEnumConstants(enumClass).get(value);
- return ref == null
- ? Optional.absent()
- : Optional.of(enumClass.cast(ref.get()));
- }
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Preconditions.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Preconditions.java
deleted file mode 100644
index a27205fc43c6..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Preconditions.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Copyright (C) 2007 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-
-import javax.annotation.Nullable;
-
-/**
- * Static convenience methods that help a method or constructor check whether it was invoked
- * correctly (whether its preconditions have been met). These methods generally accept a
- * {@code boolean} expression which is expected to be {@code true} (or in the case of {@code
- * checkNotNull}, an object reference which is expected to be non-null). When {@code false} (or
- * {@code null}) is passed instead, the {@code Preconditions} method throws an unchecked exception,
- * which helps the calling method communicate to its caller that that caller has made
- * a mistake. Example: {@code
- *
- * /**
- * * Returns the positive square root of the given value.
- * *
- * * @throws IllegalArgumentException if the value is negative
- * *}{@code /
- * public static double sqrt(double value) {
- * Preconditions.checkArgument(value >= 0.0, "negative value: %s", value);
- * // calculate the square root
- * }
- *
- * void exampleBadCaller() {
- * double d = sqrt(-1.0);
- * }}
- *
- * In this example, {@code checkArgument} throws an {@code IllegalArgumentException} to indicate
- * that {@code exampleBadCaller} made an error in its call to {@code sqrt}.
- *
- * Warning about performance
- *
- * The goal of this class is to improve readability of code, but in some circumstances this may
- * come at a significant performance cost. Remember that parameter values for message construction
- * must all be computed eagerly, and autoboxing and varargs array creation may happen as well, even
- * when the precondition check then succeeds (as it should almost always do in production). In some
- * circumstances these wasted CPU cycles and allocations can add up to a real problem.
- * Performance-sensitive precondition checks can always be converted to the customary form:
- *
{@code
- *
- * if (value < 0.0) {
- * throw new IllegalArgumentException("negative value: " + value);
- * }}
- *
- * Other types of preconditions
- *
- * Not every type of precondition failure is supported by these methods. Continue to throw
- * standard JDK exceptions such as {@link java.util.NoSuchElementException} or {@link
- * UnsupportedOperationException} in the situations they are intended for.
- *
- *
Non-preconditions
- *
- * It is of course possible to use the methods of this class to check for invalid conditions
- * which are not the caller's fault. Doing so is not recommended because it is
- * misleading to future readers of the code and of stack traces. See
- * Conditional
- * failures explained in the Guava User Guide for more advice.
- *
- *
{@code java.util.Objects.requireNonNull()}
- *
- * Projects which use {@code com.google.common} should generally avoid the use of {@link
- * java.util.Objects#requireNonNull(Object)}. Instead, use whichever of {@link
- * #checkNotNull(Object)} or {@link Verify#verifyNotNull(Object)} is appropriate to the situation.
- * (The same goes for the message-accepting overloads.)
- *
- *
Only {@code %s} is supported
- *
- * In {@code Preconditions} error message template strings, only the {@code "%s"} specifier is
- * supported, not the full range of {@link java.util.Formatter} specifiers.
- *
- *
More information
- *
- * See the Guava User Guide on
- * using {@code
- * Preconditions}.
- *
- * @author Kevin Bourrillion
- * @since 2.0
- */
-@GwtCompatible
-public final class Preconditions {
- private Preconditions() {}
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * @param expression a boolean expression
- * @throws IllegalArgumentException if {@code expression} is false
- */
- public static void checkArgument(boolean expression) {
- if (!expression) {
- throw new IllegalArgumentException();
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * @param expression a boolean expression
- * @param errorMessage the exception message to use if the check fails; will be converted to a
- * string using {@link String#valueOf(Object)}
- * @throws IllegalArgumentException if {@code expression} is false
- */
- public static void checkArgument(boolean expression, @Nullable Object errorMessage) {
- if (!expression) {
- throw new IllegalArgumentException(String.valueOf(errorMessage));
- }
- }
-
- /**
- * Ensures the truth of an expression involving one or more parameters to the calling method.
- *
- * @param expression a boolean expression
- * @param errorMessageTemplate a template for the exception message should the check fail. The
- * message is formed by replacing each {@code %s} placeholder in the template with an
- * argument. These are matched by position - the first {@code %s} gets {@code
- * errorMessageArgs[0]}, etc. Unmatched arguments will be appended to the formatted message
- * in square braces. Unmatched placeholders will be left as-is.
- * @param errorMessageArgs the arguments to be substituted into the message template. Arguments
- * are converted to strings using {@link String#valueOf(Object)}.
- * @throws IllegalArgumentException if {@code expression} is false
- * @throws NullPointerException if the check fails and either {@code errorMessageTemplate} or
- * {@code errorMessageArgs} is null (don't let this happen)
- */
- public static void checkArgument(
- boolean expression,
- @Nullable String errorMessageTemplate,
- @Nullable 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.
- *
- * @param expression a boolean expression
- * @throws IllegalStateException if {@code expression} is false
- */
- public static void checkState(boolean expression) {
- if (!expression) {
- throw new IllegalStateException();
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * @param expression a boolean expression
- * @param errorMessage the exception message to use if the check fails; will be converted to a
- * string using {@link String#valueOf(Object)}
- * @throws IllegalStateException if {@code expression} is false
- */
- public static void checkState(boolean expression, @Nullable Object errorMessage) {
- if (!expression) {
- throw new IllegalStateException(String.valueOf(errorMessage));
- }
- }
-
- /**
- * Ensures the truth of an expression involving the state of the calling instance, but not
- * involving any parameters to the calling method.
- *
- * @param expression a boolean expression
- * @param errorMessageTemplate a template for the exception message should the check fail. The
- * message is formed by replacing each {@code %s} placeholder in the template with an
- * argument. These are matched by position - the first {@code %s} gets {@code
- * errorMessageArgs[0]}, etc. Unmatched arguments will be appended to the formatted message
- * in square braces. Unmatched placeholders will be left as-is.
- * @param errorMessageArgs the arguments to be substituted into the message template. Arguments
- * are converted to strings using {@link String#valueOf(Object)}.
- * @throws IllegalStateException if {@code expression} is false
- * @throws NullPointerException if the check fails and either {@code errorMessageTemplate} or
- * {@code errorMessageArgs} is null (don't let this happen)
- */
- public static void checkState(
- boolean expression,
- @Nullable String errorMessageTemplate,
- @Nullable Object... errorMessageArgs) {
- if (!expression) {
- throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));
- }
- }
-
- /**
- * Ensures that an object reference passed as a parameter to the calling method is not null.
- *
- * @param reference an object reference
- * @return the non-null reference that was validated
- * @throws NullPointerException if {@code reference} is null
- */
- public static T checkNotNull(T reference) {
- if (reference == null) {
- throw new NullPointerException();
- }
- return reference;
- }
-
- /**
- * Ensures that an object reference passed as a parameter to the calling method is not null.
- *
- * @param reference an object reference
- * @param errorMessage the exception message to use if the check fails; will be converted to a
- * string using {@link String#valueOf(Object)}
- * @return the non-null reference that was validated
- * @throws NullPointerException if {@code reference} is null
- */
- public static T checkNotNull(T reference, @Nullable Object errorMessage) {
- if (reference == null) {
- throw new NullPointerException(String.valueOf(errorMessage));
- }
- return reference;
- }
-
- /**
- * Ensures that an object reference passed as a parameter to the calling method is not null.
- *
- * @param reference an object reference
- * @param errorMessageTemplate a template for the exception message should the check fail. The
- * message is formed by replacing each {@code %s} placeholder in the template with an
- * argument. These are matched by position - the first {@code %s} gets {@code
- * errorMessageArgs[0]}, etc. Unmatched arguments will be appended to the formatted message
- * in square braces. Unmatched placeholders will be left as-is.
- * @param errorMessageArgs the arguments to be substituted into the message template. Arguments
- * are converted to strings using {@link String#valueOf(Object)}.
- * @return the non-null reference that was validated
- * @throws NullPointerException if {@code reference} is null
- */
- public static T checkNotNull(
- T reference, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) {
- if (reference == null) {
- // If either of these parameters is null, the right thing happens anyway
- throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));
- }
- return reference;
- }
-
- /*
- * All recent hotspots (as of 2009) *really* like to have the natural code
- *
- * if (guardExpression) {
- * throw new BadException(messageExpression);
- * }
- *
- * refactored so that messageExpression is moved to a separate String-returning method.
- *
- * if (guardExpression) {
- * throw new BadException(badMsg(...));
- * }
- *
- * The alternative natural refactorings into void or Exception-returning methods are much slower.
- * This is a big deal - we're talking factors of 2-8 in microbenchmarks, not just 10-20%. (This
- * is a hotspot optimizer bug, which should be fixed, but that's a separate, big project).
- *
- * The coding pattern above is heavily used in java.util, e.g. in ArrayList. There is a
- * RangeCheckMicroBenchmark in the JDK that was used to test this.
- *
- * But the methods in this class want to throw different exceptions, depending on the args, so it
- * appears that this pattern is not directly applicable. But we can use the ridiculous, devious
- * trick of throwing an exception in the middle of the construction of another exception. Hotspot
- * is fine with that.
- */
-
- /**
- * Ensures that {@code index} specifies a valid element in an array, list or string of size
- * {@code size}. An element index may range from zero, inclusive, to {@code size}, exclusive.
- *
- * @param index a user-supplied index identifying an element of an array, list or string
- * @param size the size of that array, list or string
- * @return the value of {@code index}
- * @throws IndexOutOfBoundsException if {@code index} is negative or is not less than {@code size}
- * @throws IllegalArgumentException if {@code size} is negative
- */
- public static int checkElementIndex(int index, int size) {
- return checkElementIndex(index, size, "index");
- }
-
- /**
- * Ensures that {@code index} specifies a valid element in an array, list or string of size
- * {@code size}. An element index may range from zero, inclusive, to {@code size}, exclusive.
- *
- * @param index a user-supplied index identifying an element of an array, list or string
- * @param size the size of that array, list or string
- * @param desc the text to use to describe this index in an error message
- * @return the value of {@code index}
- * @throws IndexOutOfBoundsException if {@code index} is negative or is not less than {@code size}
- * @throws IllegalArgumentException if {@code size} is negative
- */
- public static int checkElementIndex(int index, int size, @Nullable String desc) {
- // Carefully optimized for execution by hotspot (explanatory comment above)
- if (index < 0 || index >= size) {
- throw new IndexOutOfBoundsException(badElementIndex(index, size, desc));
- }
- return index;
- }
-
- private static String badElementIndex(int index, int size, String desc) {
- if (index < 0) {
- return format("%s (%s) must not be negative", desc, index);
- } else if (size < 0) {
- throw new IllegalArgumentException("negative size: " + size);
- } else { // index >= size
- return format("%s (%s) must be less than size (%s)", desc, index, size);
- }
- }
-
- /**
- * Ensures that {@code index} specifies a valid position in an array, list or string of
- * size {@code size}. A position index may range from zero to {@code size}, inclusive.
- *
- * @param index a user-supplied index identifying a position in an array, list or string
- * @param size the size of that array, list or string
- * @return the value of {@code index}
- * @throws IndexOutOfBoundsException if {@code index} is negative or is greater than {@code size}
- * @throws IllegalArgumentException if {@code size} is negative
- */
- public static int checkPositionIndex(int index, int size) {
- return checkPositionIndex(index, size, "index");
- }
-
- /**
- * Ensures that {@code index} specifies a valid position in an array, list or string of
- * size {@code size}. A position index may range from zero to {@code size}, inclusive.
- *
- * @param index a user-supplied index identifying a position in an array, list or string
- * @param size the size of that array, list or string
- * @param desc the text to use to describe this index in an error message
- * @return the value of {@code index}
- * @throws IndexOutOfBoundsException if {@code index} is negative or is greater than {@code size}
- * @throws IllegalArgumentException if {@code size} is negative
- */
- public static int checkPositionIndex(int index, int size, @Nullable String desc) {
- // Carefully optimized for execution by hotspot (explanatory comment above)
- if (index < 0 || index > size) {
- throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc));
- }
- return index;
- }
-
- private static String badPositionIndex(int index, int size, String desc) {
- if (index < 0) {
- return format("%s (%s) must not be negative", desc, index);
- } else if (size < 0) {
- throw new IllegalArgumentException("negative size: " + size);
- } else { // index > size
- return format("%s (%s) must not be greater than size (%s)", desc, index, size);
- }
- }
-
- /**
- * Ensures that {@code start} and {@code end} specify a valid positions in an array, list
- * or string of size {@code size}, and are in order. A position index may range from zero to
- * {@code size}, inclusive.
- *
- * @param start a user-supplied index identifying a starting position in an array, list or string
- * @param end a user-supplied index identifying a ending position in an array, list or string
- * @param size the size of that array, list or string
- * @throws IndexOutOfBoundsException if either index is negative or is greater than {@code size},
- * or if {@code end} is less than {@code start}
- * @throws IllegalArgumentException if {@code size} is negative
- */
- public static void checkPositionIndexes(int start, int end, int size) {
- // Carefully optimized for execution by hotspot (explanatory comment above)
- if (start < 0 || end < start || end > size) {
- throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
- }
- }
-
- private static String badPositionIndexes(int start, int end, int size) {
- if (start < 0 || start > size) {
- return badPositionIndex(start, size, "start index");
- }
- if (end < 0 || end > size) {
- return badPositionIndex(end, size, "end index");
- }
- // end < start
- return format("end index (%s) must not be less than start index (%s)", end, start);
- }
-
- /**
- * 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.
- *
- * @param template a non-null string containing 0 or more {@code %s} placeholders.
- * @param args the arguments to be substituted into the message template. Arguments are converted
- * to strings using {@link String#valueOf(Object)}. Arguments can be null.
- */
- // Note that this is somewhat-improperly used from Verify.java as well.
- static String format(String template, @Nullable 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();
- }
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Predicate.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Predicate.java
deleted file mode 100644
index 43defb85342d..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Predicate.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.common.annotations.GwtCompatible;
-
-import javax.annotation.Nullable;
-
-/**
- * Determines a true or false value for a given input.
- *
- * The {@link Predicates} class provides common predicates and related utilities.
- *
- *
See the Guava User Guide article on the use of {@code
- * Predicate}.
- *
- * @author Kevin Bourrillion
- * @since 2.0
- */
-@GwtCompatible
-public interface Predicate {
- /**
- * Returns the result of applying this predicate to {@code input}. This method is generally
- * expected, but not absolutely required, to have the following properties:
- *
- *
- * - Its execution does not cause any observable side effects.
- *
- The computation is consistent with equals; that is, {@link Objects#equal
- * Objects.equal}{@code (a, b)} implies that {@code predicate.apply(a) ==
- * predicate.apply(b))}.
- *
- *
- * @throws NullPointerException if {@code input} is null and this predicate does not accept null
- * arguments
- */
- boolean apply(@Nullable T input);
-
- /**
- * Indicates whether another object is equal to this predicate.
- *
- * Most implementations will have no reason to override the behavior of {@link Object#equals}.
- * However, an implementation may also choose to return {@code true} whenever {@code object} is a
- * {@link Predicate} that it considers interchangeable with this one. "Interchangeable"
- * typically means that {@code this.apply(t) == that.apply(t)} for all {@code t} of type
- * {@code T}). Note that a {@code false} result from this method does not imply that the
- * predicates are known not to be interchangeable.
- */
- @Override
- boolean equals(@Nullable Object object);
-}
diff --git a/thirdparty/google-guava/src/main/java/com/google/common/base/Predicates.java b/thirdparty/google-guava/src/main/java/com/google/common/base/Predicates.java
deleted file mode 100644
index 67c04cf97c9e..000000000000
--- a/thirdparty/google-guava/src/main/java/com/google/common/base/Predicates.java
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- * Copyright (C) 2007 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import javax.annotation.CheckReturnValue;
-import javax.annotation.Nullable;
-
-/**
- * Static utility methods pertaining to {@code Predicate} instances.
- *
- *
All methods returns serializable predicates as long as they're given
- * serializable parameters.
- *
- *
See the Guava User Guide article on the
- * use of {@code Predicate}.
- *
- * @author Kevin Bourrillion
- * @since 2.0
- */
-@CheckReturnValue
-@GwtCompatible(emulated = true)
-public final class Predicates {
- private Predicates() {}
-
- // TODO(kevinb): considering having these implement a VisitablePredicate
- // interface which specifies an accept(PredicateVisitor) method.
-
- /**
- * Returns a predicate that always evaluates to {@code true}.
- */
- @GwtCompatible(serializable = true)
- public static Predicate alwaysTrue() {
- return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
- }
-
- /**
- * Returns a predicate that always evaluates to {@code false}.
- */
- @GwtCompatible(serializable = true)
- public static Predicate alwaysFalse() {
- return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
- }
-
- /**
- * Returns a predicate that evaluates to {@code true} if the object reference
- * being tested is null.
- */
- @GwtCompatible(serializable = true)
- public static Predicate isNull() {
- return ObjectPredicate.IS_NULL.withNarrowedType();
- }
-
- /**
- * Returns a predicate that evaluates to {@code true} if the object reference
- * being tested is not null.
- */
- @GwtCompatible(serializable = true)
- public static Predicate notNull() {
- return ObjectPredicate.NOT_NULL.withNarrowedType();
- }
-
- /**
- * Returns a predicate that evaluates to {@code true} if the given predicate
- * evaluates to {@code false}.
- */
- public static Predicate not(Predicate predicate) {
- return new NotPredicate