From 2df6b4b0ead790a0968d8726d2d2133496385448 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 28 Sep 2012 14:03:41 +0200 Subject: [PATCH] more guice to use Objects from guava --- .../common/inject/internal/MoreTypes.java | 1 + .../common/inject/internal/Objects.java | 65 ------------------- .../common/inject/spi/Dependency.java | 2 +- .../common/inject/spi/Message.java | 2 +- 4 files changed, 3 insertions(+), 67 deletions(-) delete mode 100644 src/main/java/org/elasticsearch/common/inject/internal/Objects.java diff --git a/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java b/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java index 7843c283c3a..6b283e164ee 100644 --- a/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java +++ b/src/main/java/org/elasticsearch/common/inject/internal/MoreTypes.java @@ -17,6 +17,7 @@ package org.elasticsearch.common.inject.internal; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.elasticsearch.common.inject.ConfigurationException; diff --git a/src/main/java/org/elasticsearch/common/inject/internal/Objects.java b/src/main/java/org/elasticsearch/common/inject/internal/Objects.java deleted file mode 100644 index 60a9899f1ad..00000000000 --- a/src/main/java/org/elasticsearch/common/inject/internal/Objects.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 Google Inc. - * - * 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 org.elasticsearch.common.inject.internal; - -import java.util.Arrays; - -/** - * Helper functions that can operate on any {@code Object}. - * - * @author Laurence Gonsalves - */ -public final class Objects { - private Objects() { - } - - /** - * Determines whether two possibly-null objects are equal. Returns: - *

- *

- *

- *

This assumes that any non-null objects passed to this function conform - * to the {@code equals()} contract. - */ - 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[])}. - *

- *

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: - *

-     * 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. - */ - public static int hashCode(Object... objects) { - return Arrays.hashCode(objects); - } -} diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java b/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java index df3a52ddcf5..50e3979d373 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Dependency.java @@ -16,10 +16,10 @@ package org.elasticsearch.common.inject.spi; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import org.elasticsearch.common.inject.Key; -import org.elasticsearch.common.inject.internal.Objects; import java.util.List; import java.util.Set; diff --git a/src/main/java/org/elasticsearch/common/inject/spi/Message.java b/src/main/java/org/elasticsearch/common/inject/spi/Message.java index 16aebcc9b5e..fd088f51e3b 100644 --- a/src/main/java/org/elasticsearch/common/inject/spi/Message.java +++ b/src/main/java/org/elasticsearch/common/inject/spi/Message.java @@ -16,10 +16,10 @@ package org.elasticsearch.common.inject.spi; +import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.internal.Errors; -import org.elasticsearch.common.inject.internal.Objects; import org.elasticsearch.common.inject.internal.SourceProvider; import java.io.ObjectStreamException;