All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.yangtools.util.EvenMoreObjects Maven / Gradle / Ivy

There is a newer version: 14.0.4
Show newest version
/*
 * 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() { } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy