net.sf.sfac.utils
Class Comparison

java.lang.Object
  extended by net.sf.sfac.utils.Comparison

public class Comparison
extends Object


Constructor Summary
Comparison()
           
 
Method Summary
static int compareStrings(String str1, String str2)
          Compare the two Strings taking care of null values.
static
<T extends Comparable<T>>
int
compareTo(List<T> lst1, List<T> lst2)
          Compare the two lists of comparable objects taking care of null values.
static
<T extends Comparable<T>>
int
compareTo(T obj1, T obj2)
          Compare the two Comparable objects (using compareTo(..)) taking care of null values.
static
<T extends Enum<T>>
int
compareTo(T obj1, T obj2)
          Compare the two enum objects (using ordinal()) taking care of null values.
static boolean equals(Object obj1, Object obj2)
          Compare the two objects (using equals(..)) taking care of null values.
static boolean isDefined(List<?> lst)
          A list is defined if it is not null and it contains at least one element.
static boolean isDefined(String str)
          A string is defined if it is not null and don't contains only whitespace characters (space, tabs, returns, ...).
static boolean isEmpty(List<?> lst)
          A string is empty if it is null or contains only whitespace characters (space, tabs, returns, ...).
static boolean isEmpty(String str)
          A string is empty if it is null or contains only whitespace characters (space, tabs, returns, ...).
static
<T> boolean
listEquals(List<T> lst1, List<T> lst2)
          Compare if the two lists of comparable objects are equals (taking care of null values).
static boolean startsWithIgnoreCase(String checkedString, String start)
           
static boolean stringEquals(Object obj1, Object obj2)
          Comparison of strings where a null string is considered as equivalent to an empty string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Comparison

public Comparison()
Method Detail

equals

public static boolean equals(Object obj1,
                             Object obj2)
Compare the two objects (using equals(..)) taking care of null values.


stringEquals

public static boolean stringEquals(Object obj1,
                                   Object obj2)
Comparison of strings where a null string is considered as equivalent to an empty string. The two given ovjects are converted to string and trimmed.


listEquals

public static <T> boolean listEquals(List<T> lst1,
                                     List<T> lst2)
Compare if the two lists of comparable objects are equals (taking care of null values).


compareTo

public static <T extends Comparable<T>> int compareTo(T obj1,
                                                      T obj2)
Compare the two Comparable objects (using compareTo(..)) taking care of null values.


compareStrings

public static int compareStrings(String str1,
                                 String str2)
Compare the two Strings taking care of null values.
Note: this method uses a Collator instead of the simple String.compareTo.


compareTo

public static <T extends Enum<T>> int compareTo(T obj1,
                                                T obj2)
Compare the two enum objects (using ordinal()) taking care of null values.


compareTo

public static <T extends Comparable<T>> int compareTo(List<T> lst1,
                                                      List<T> lst2)
Compare the two lists of comparable objects taking care of null values.


isEmpty

public static boolean isEmpty(String str)
A string is empty if it is null or contains only whitespace characters (space, tabs, returns, ...).


isEmpty

public static boolean isEmpty(List<?> lst)
A string is empty if it is null or contains only whitespace characters (space, tabs, returns, ...).


isDefined

public static boolean isDefined(String str)
A string is defined if it is not null and don't contains only whitespace characters (space, tabs, returns, ...).
isEmpty(x) = !isDefined(x)


isDefined

public static boolean isDefined(List<?> lst)
A list is defined if it is not null and it contains at least one element.
isEmpty(lst) = !isDefined(lst)


startsWithIgnoreCase

public static boolean startsWithIgnoreCase(String checkedString,
                                           String start)


Copyright © 2012. All Rights Reserved.