You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2015/11/20 22:29:13 UTC
[2/4] incubator-geode git commit: GEODE-584: Removes ObjectUtils class
GEODE-584: Removes ObjectUtils class
Replaces use of .../cli/util/spring/ObjectUtils to spring-core library.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e6e1466c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e6e1466c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e6e1466c
Branch: refs/heads/feature/GEODE-584
Commit: e6e1466c18316edfcee91b947ad7ce54abe2b91c
Parents: 0d47dd1
Author: Anthony Baker <ab...@pivotal.io>
Authored: Fri Nov 20 13:19:21 2015 -0800
Committer: Anthony Baker <ab...@pivotal.io>
Committed: Fri Nov 20 13:19:21 2015 -0800
----------------------------------------------------------------------
.../internal/cli/parser/GfshMethodTarget.java | 4 +-
.../internal/cli/util/spring/ObjectUtils.java | 300 -------------------
2 files changed, 2 insertions(+), 302 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e6e1466c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/GfshMethodTarget.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/GfshMethodTarget.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/GfshMethodTarget.java
index 87b9569..1d8df03 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/GfshMethodTarget.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/GfshMethodTarget.java
@@ -19,8 +19,8 @@ package com.gemstone.gemfire.management.internal.cli.parser;
import java.lang.reflect.Method;
import org.springframework.util.Assert;
+import org.springframework.util.ObjectUtils;
-import com.gemstone.gemfire.management.internal.cli.util.spring.ObjectUtils;
import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
/**
@@ -102,7 +102,7 @@ public class GfshMethodTarget {
@Override
public int hashCode() {
- return ObjectUtils.nullSafeHashCode(method, target);
+ return ObjectUtils.nullSafeHashCode(new Object[] { method, target });
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e6e1466c/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ObjectUtils.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ObjectUtils.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ObjectUtils.java
deleted file mode 100644
index 8209b3c..0000000
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/util/spring/ObjectUtils.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-/*
- * Copyright 2011-2012 the original author or 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.gemstone.gemfire.management.internal.cli.util.spring;
-
-/**
- * Replaces org.springframework.shell.support.util.ObjectUtils which
- * is now removed from SPring Shell & the same class is referred from Spring
- * Core. With this we can avoid GemFire member's runtime dependency on Spring
- * Core.
- */
-/*
- * Code selectively taken from the original org.springframework.shell.support.util.ObjectUtils
- */
-public class ObjectUtils {
- // Constants
- private static final int INITIAL_HASH = 7;
- private static final int MULTIPLIER = 31;
-
- /**
- * Return as hash code for the given object; typically the value of
- * <code>{@link Object#hashCode()}</code>. If the object is an array,
- * this method will delegate to any of the <code>nullSafeHashCode</code>
- * methods for arrays in this class. If the object is <code>null</code>,
- * this method returns 0.
- *
- * @see #nullSafeHashCode(Object[])
- * @see #nullSafeHashCode(boolean[])
- * @see #nullSafeHashCode(byte[])
- * @see #nullSafeHashCode(char[])
- * @see #nullSafeHashCode(double[])
- * @see #nullSafeHashCode(float[])
- * @see #nullSafeHashCode(int[])
- * @see #nullSafeHashCode(long[])
- * @see #nullSafeHashCode(short[])
- */
- public static int nullSafeHashCode(final Object obj) {
- if (obj == null) {
- return 0;
- }
- if (obj.getClass().isArray()) {
- if (obj instanceof Object[]) {
- return nullSafeHashCode((Object[]) obj);
- }
- if (obj instanceof boolean[]) {
- return nullSafeHashCode((boolean[]) obj);
- }
- if (obj instanceof byte[]) {
- return nullSafeHashCode((byte[]) obj);
- }
- if (obj instanceof char[]) {
- return nullSafeHashCode((char[]) obj);
- }
- if (obj instanceof double[]) {
- return nullSafeHashCode((double[]) obj);
- }
- if (obj instanceof float[]) {
- return nullSafeHashCode((float[]) obj);
- }
- if (obj instanceof int[]) {
- return nullSafeHashCode((int[]) obj);
- }
- if (obj instanceof long[]) {
- return nullSafeHashCode((long[]) obj);
- }
- if (obj instanceof short[]) {
- return nullSafeHashCode((short[]) obj);
- }
- }
- return obj.hashCode();
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array the array from whose elements to calculate the hash code (can be <code>null</code>)
- * @return 0 if the array is <code>null</code>
- */
- public static int nullSafeHashCode(final Object... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- for (final Object element : array) {
- hash = MULTIPLIER * hash + nullSafeHashCode(element);
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final boolean... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + hashCode(array[i]);
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final byte... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + array[i];
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final char... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + array[i];
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final double... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + hashCode(array[i]);
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final float... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + hashCode(array[i]);
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final int... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + array[i];
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final long... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + hashCode(array[i]);
- }
- return hash;
- }
-
- /**
- * Return a hash code based on the contents of the specified array.
- *
- * @param array can be <code>null</code>
- * @return 0 if <code>array</code> is <code>null</code>
- */
- public static int nullSafeHashCode(final short... array) {
- if (array == null) {
- return 0;
- }
- int hash = INITIAL_HASH;
- int arraySize = array.length;
- for (int i = 0; i < arraySize; i++) {
- hash = MULTIPLIER * hash + array[i];
- }
- return hash;
- }
-
- /**
- * Returns the hash code of the given boolean value.
- *
- * @param bool the boolean for which to return the hash code
- * @return see {@link Boolean#hashCode()}
- */
- public static int hashCode(final boolean bool) {
- return Boolean.valueOf(bool).hashCode();
- }
-
- /**
- * Return the same value as <code>{@link Double#hashCode()}</code>.
- *
- * @see Double#hashCode()
- */
- public static int hashCode(final double dbl) {
- long bits = Double.doubleToLongBits(dbl);
- return hashCode(bits);
- }
-
- /**
- * Return the same value as <code>{@link Float#hashCode()}</code>.
- *
- * @see Float#hashCode()
- */
- public static int hashCode(final float flt) {
- return Float.floatToIntBits(flt);
- }
-
- /**
- * Return the same value as <code>{@link Long#hashCode()}</code>.
- *
- * @see Long#hashCode()
- */
- public static int hashCode(final long lng) {
- return (int) (lng ^ (lng >>> 32));
- }
-
-}