Class EqualsUtil


  • public final class EqualsUtil
    extends Object
    Convenience methods related to object equality.
    Author:
    Pascal Essiembre
    • Method Detail

      • equalsAny

        public static boolean equalsAny​(Object source,
                                        Object... targets)
        Whether a source object equals ANY of the target objects.
        Parameters:
        source - object being tested for equality with targets
        targets - one or more objects to be tested with source for equality
        Returns:
        true if any of the target objects are equal
      • equalsAnyIgnoreCase

        public static boolean equalsAnyIgnoreCase​(CharSequence source,
                                                  CharSequence... targets)
        Whether a source string equals ANY of the target string.
        Parameters:
        source - string being tested for equality with target strings
        targets - one or more strings to be tested with source string for equality
        Returns:
        true if any of the target strings are equal
      • equalsAll

        public static boolean equalsAll​(Object source,
                                        Object... targets)
        Whether a source object equals ALL of the target objects
        Parameters:
        source - object being tested for equality with targets
        targets - one or more objects to be tested with source for equality
        Returns:
        true if all of the target objects are equal
      • equalsAllIgnoreCase

        public static boolean equalsAllIgnoreCase​(CharSequence source,
                                                  CharSequence... targets)
        Whether a source string equals ALL of the target string.
        Parameters:
        source - string being tested for equality with target strings
        targets - one or more strings to be tested with source string for equality
        Returns:
        true if all of the target strings are equal
      • equalsNone

        public static boolean equalsNone​(Object source,
                                         Object... targets)
        Whether a source object equals NONE of the target objects
        Parameters:
        source - object being tested for equality with targets
        targets - one or more objects to be tested with source for equality
        Returns:
        true if none of the target objects are equal
      • equalsNoneIgnoreCase

        public static boolean equalsNoneIgnoreCase​(String source,
                                                   String... targets)
        Whether a source string equals NONE of the target string.
        Parameters:
        source - string being tested for equality with target strings
        targets - one or more strings to be tested with source string for equality
        Returns:
        true if none of the target strings are equal
      • equalsMap

        public static boolean equalsMap​(Map<?,​?> map1,
                                        Map<?,​?> map2)
        Compares that two maps are equals, regardless of entry orders. It does so by making sure the two maps are the same size and the first map contains all entries of the other one. Map elements should implement equals.
        Parameters:
        map1 - first map
        map2 - second map
        Returns:
        true if the two maps are equal
        Since:
        1.14.0