public class ModelUtil
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
ModelUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areDifferent(java.lang.Object o1,
java.lang.Object o2)
This is a utility method that compares two objects when one or
both of the objects might be
null . |
static boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
This is a utility method that compares two objects when one or
both of the objects might be
null The result of
this method is determined as follows:
If o1 and o2 are the same object
according to the == operator, return
true . |
static <T> T |
as(java.lang.Object o,
java.lang.Class<T> clazz)
Casts the object to the given class, if it is an instance, or returns null otherwise.
|
static java.lang.String |
concat(java.lang.String[] strs)
Returns a single string that is the concatenation of all the
strings in the specified string array.
|
static java.lang.String |
concat(java.lang.String[] strs,
java.lang.String delim)
Returns a single string that is the concatenation of all the
strings in the specified string array.
|
static void |
deepCopy(java.util.List src,
java.util.List dst)
Copies list contents from
src to dst . |
static void |
deepCopy(java.util.List src,
java.util.List dst,
boolean eliminateDuplicates)
Copies list contents from
src to dst . |
static void |
deepCopy(java.util.Map src,
java.util.Map dst)
Copies key-value mappings from
src to
dst . |
static int |
hashCodeFor(java.lang.Object o)
Returns the hash code for the specified object, or 0 if it is null.
|
static boolean |
hasLength(java.lang.CharSequence cs)
Returns
true if the specified String is not
null and has a length greater than zero. |
static boolean |
hasLength(java.lang.String s) |
static boolean |
hasNonNullElement(java.lang.Object[] array)
Returns
true if the specified array is not null
and contains a non-null element. |
static java.lang.String |
nullifyIfEmpty(java.lang.String s)
Returns
null if the specified string is empty or
null . |
public static final boolean areEqual(java.lang.Object o1, java.lang.Object o2)
null
The result of
this method is determined as follows:
o1
and o2
are the same object
according to the ==
operator, return
true
.
o1
or o2
is
null
, return false
.
o1.equals(o2)
.
areDifferent(Object, Object)
method.
For array types, one of the equals
methods in
Arrays
should be used instead of this method.
Note that arrays with more than one dimension will require some
custom code in order to implement equals
properly.
public static final boolean areDifferent(java.lang.Object o1, java.lang.Object o2)
null
. The result
returned by this method is determined as follows:
o1
and o2
are the same object
according to the ==
operator, return
false
.
o1
or o2
is
null
, return true
.
!o1.equals(o2)
.
areEqual(Object, Object)
method.
For array types, one of the equals
methods in
Arrays
should be used instead of this method.
Note that arrays with more than one dimension will require some
custom code in order to implement equals
properly.
public static final boolean hasNonNullElement(java.lang.Object[] array)
true
if the specified array is not null
and contains a non-null element. Returns false
if the array is null or if all the array elements are null.public static final java.lang.String concat(java.lang.String[] strs)
public static final java.lang.String concat(java.lang.String[] strs, java.lang.String delim)
public static final boolean hasLength(java.lang.String s)
hasLength(CharSequence)
public static int hashCodeFor(java.lang.Object o)
o
- an object, which may be null.public static final boolean hasLength(java.lang.CharSequence cs)
true
if the specified String
is not
null
and has a length greater than zero. This is
a very frequently occurring check.public static final java.lang.String nullifyIfEmpty(java.lang.String s)
null
if the specified string is empty or
null
. Otherwise the string itself is returned.public static final void deepCopy(java.util.Map src, java.util.Map dst)
src
to
dst
. Any pre-existing mappings in dst
are not deleted. However, any mappings in
src
that also exist in dst
will result
in the dst
mappings being overwritten, if and only
if the value objects have exactly the same type; otherwise, a
new value object is created and the old value object is discarded.
The key objects are not copied, so the keys that end up in
dst
will be references to the exact same objects
as the keys in src
. Values, however, are copied
if the value objects implement Copyable
. Value objects
that do not implement Copyable
are put directly into the
dst
Map
.public static final void deepCopy(java.util.List src, java.util.List dst, boolean eliminateDuplicates)
src
to dst
.
If the dst
list is not empty it will add the
elements from src
. If eliminateDuplicates
is true, src
elements that already exist in dst
are not copied.public static final void deepCopy(java.util.List src, java.util.List dst)
src
to dst
.
If the dst
list is not empty it will add the
elements from src
. If a src
element already
exists in dst
, it isn't copied.public static <T> T as(java.lang.Object o, java.lang.Class<T> clazz)