From 6e64b530a8bb8304319df00ae742a089d79d08d1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 5 Oct 2023 17:02:40 +0200 Subject: [PATCH] Remove EvenMoreObjects This class is completely unused and deprecated for removal. Remove it as part of this major version bump. Change-Id: Ic1daa590d19595d78f07884c5f5af4d2b992e82e Signed-off-by: Robert Varga --- .../yangtools/util/EvenMoreObjects.java | 55 ----------------- .../yangtools/util/EvenMoreObjectsTest.java | 60 ------------------- 2 files changed, 115 deletions(-) delete mode 100644 common/util/src/main/java/org/opendaylight/yangtools/util/EvenMoreObjects.java delete mode 100644 common/util/src/test/java/org/opendaylight/yangtools/util/EvenMoreObjectsTest.java diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/EvenMoreObjects.java b/common/util/src/main/java/org/opendaylight/yangtools/util/EvenMoreObjects.java deleted file mode 100644 index a9fbcac45f..0000000000 --- a/common/util/src/main/java/org/opendaylight/yangtools/util/EvenMoreObjects.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.util; - -import com.google.common.base.MoreObjects; -import java.util.function.BiFunction; - -/** - * Utility helping to implement readable equals() methods. - * - *

Usage: - *

- *{@literal @}Override
- * public boolean equals(Object obj) {
- *     return EvenMoreObjects.equalsHelper(this, obj,
- *        (one, another) -> Objects.equals(one.name, another.name) && Objects.equals(one.age, another.age));
- * }
- * 
- * - *

See Guava issue proposing contributing this. - * - * @see MoreObjects - * - * @author Michael Vorburger, Red Hat - */ -@Deprecated(since = "11.0.0", forRemoval = true) -public final class EvenMoreObjects { - - @SuppressWarnings("unchecked") - public static boolean equalsHelper(final T self, final Object other, final BooleanEqualsFunction equals) { - if (other == self) { - return true; - } - if (other == null) { - return false; - } - if (self.getClass() != other.getClass()) { - return false; - } - return equals.apply(self, (T) other); - } - - @FunctionalInterface - public interface BooleanEqualsFunction extends BiFunction { } - - private EvenMoreObjects() { - - } -} - diff --git a/common/util/src/test/java/org/opendaylight/yangtools/util/EvenMoreObjectsTest.java b/common/util/src/test/java/org/opendaylight/yangtools/util/EvenMoreObjectsTest.java deleted file mode 100644 index 3847907e02..0000000000 --- a/common/util/src/test/java/org/opendaylight/yangtools/util/EvenMoreObjectsTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.util; - -import static org.junit.Assert.assertTrue; - -import com.google.common.base.MoreObjects; -import com.google.common.testing.EqualsTester; -import java.util.Objects; -import org.junit.Test; - -@Deprecated(since = "11.0.0", forRemoval = true) -public class EvenMoreObjectsTest { - - @Test - public void thingPassesEqualsTester() { - new EqualsTester() - .addEqualityGroup(new Thing("hello", 123), new Thing("hello", 123)) - .addEqualityGroup(new Thing("hoi", 123), new Thing("hoi", 123)) - .addEqualityGroup(new Thing("hoi", null)) - .addEqualityGroup(new Thing(null, null)) - .testEquals(); - } - - @Test - public void nullEqualsNull() { - assertTrue(EvenMoreObjects.equalsHelper(null, null, (one, another) -> Boolean.TRUE)); - } - - private static class Thing { - String name; - Integer age; - - @Override - public boolean equals(final Object obj) { - return EvenMoreObjects.equalsHelper(this, obj, - (one, another) -> Objects.equals(one.name, another.name) && Objects.equals(one.age, another.age)); - } - - @Override - public int hashCode() { - return Objects.hash(name, age); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this).add("name", name).add("age", age).toString(); - } - - Thing(final String name, final Integer age) { - this.name = name; - this.age = age; - } - } -} -- 2.36.6