Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

org.alfresco.util
Class EqualsHelper
java.lang.Object
  org.alfresco.util.EqualsHelper

@org.alfresco.api.AlfrescoPublicApi
public class EqualsHelper
extends Object
Utility class providing helper methods for various types of equals functionality
Author:
Derek Hulley

Constructor Summary
EqualsHelper()
Method Summary
static boolean
binaryStreamEquals(InputStream left, InputStream right)
          Performs a byte-level comparison between two streams.
static <K,V> Map<K,org.alfresco.util.EqualsHelper.MapValueComparison>
getMapComparison(Map<K,V> left, Map<K,V> right)
          Compare two maps.
static String
getMapDifferenceReport(Map<?,?> actual, Map<?,?> expected)
          Compare two maps and generate a difference report between the actual and expected values.
static boolean
nullSafeEquals(Object left, Object right)
          Performs an equality check left.equals(right) after checking for null values
static boolean
nullSafeEquals(String left, String right, boolean ignoreCase)
          Performs an case-sensitive or case-insensitive equality check after checking for null values
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
EqualsHelper
public EqualsHelper()
Method Detail
nullSafeEquals
public static boolean nullSafeEquals(Object left,
                                     Object right)
Performs an equality check left.equals(right) after checking for null values
Parameters:
left - the Object appearing in the left side of an equals statement
right - the Object appearing in the right side of an equals statement
Returns:
Return true or false even if one or both of the objects are null

nullSafeEquals
public static boolean nullSafeEquals(String left,
                                     String right,
                                     boolean ignoreCase)
Performs an case-sensitive or case-insensitive equality check after checking for null values
Parameters:
ignoreCase - true to ignore case

binaryStreamEquals
public static boolean binaryStreamEquals(InputStream left,
                                         InputStream right)
                                  throws IOException
Performs a byte-level comparison between two streams.
Parameters:
left - the left stream. This is closed at the end of the operation.
right - an right stream. This is closed at the end of the operation.
Returns:
Returns true if the streams are identical to the last byte
Throws:
IOException

getMapDifferenceReport
public static String getMapDifferenceReport(Map<?,?> actual,
                                            Map<?,?> expected)
Compare two maps and generate a difference report between the actual and expected values. This method is particularly useful during unit tests as the result (if not null) can be appended to a failure message.
Parameters:
actual - the map in hand
expected - the map expected
Returns:
Returns a difference report or null if there were no differences. The message starts with a new line and is neatly formatted.

getMapComparison
public static <K,V> Map<K,org.alfresco.util.EqualsHelper.MapValueComparison> getMapComparison(Map<K,V> left,
                                                                                              Map<K,V> right)
Compare two maps.

The return codes that accompany the keys are:

  • EqualsHelper.MapValueComparison.LEFT_ONLY
  • EqualsHelper.MapValueComparison.RIGHT_ONLY
  • EqualsHelper.MapValueComparison.EQUAL
  • EqualsHelper.MapValueComparison.NOT_EQUAL
Type Parameters:
K - the map key type
V - the map value type
Parameters:
left - the left side of the comparison
right - the right side of the comparison
Returns:
Returns a map whose keys are a union of the two maps' keys, along with the value comparison result

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2018 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.