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

org.ebay.datameta.dom.DataMetaSame Maven / Gradle / Ivy

Go to download

Classes needed for DataMeta DOM functionality in JVM; with Java, Scala, Clojure, JRuby and other platforms running on a JVM.

The newest version!
package org.ebay.datameta.dom;

import java.util.Comparator;
import java.util.List;

/**
 * Adds the flexible equality trait to DataMeta classes. This interface is made different from:
 * 
    *
  • {@link Object#equals(Object)} - not hard-wired to the class, you can have as many * equality definition as you need and it is generically typed. You don't need to redefine * the {@link Object#equals(Object)}, but you can make it use this interface if needed
  • *
  • {@link Comparable} - not hard-wired to the class, can be decoupled and diversified, not burdened with * greater-than nor lesser-than logic.
  • *
  • {@link Comparator} not burdened with greater-than nor lesser-than logic.
  • *
* @author Michael Bergens */ public interface DataMetaSame { /** * Leverages the {@link Object#equals(Object)} (re)defined on the class. * The {@link #isSame(Object, Object)} method returns true if * both instances are null or one is not null and it equals the * another. */ DataMetaSame EQ = (one, another) -> one == another || (one != null && one.equals(another)); /** * Equality of {@link Mapping} instances, by {@link Mapping#getKey()}. * As usual, nulls are equals, reference to the same object equals too. */ DataMetaSame> MAP_EQ = (one, another) -> one == another || ( one != null && another != null && one.getKey().equals(another.getKey())); /** * Evaluates if both of the arguments are the same in certain applicable sense. */ boolean isSame(T one, T another); }