Skip to content

Commit

Permalink
Improved: Rewrite ‘UtilGenerics#toList’ and ‘UtilGenerics#toMap’
Browse files Browse the repository at this point in the history
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863496 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jul 20, 2019
1 parent 95430bd commit 7618a51
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,14 @@ public static <T> Set<T> checkSet(Object object) {
/** Returns the Object argument as a parameterized List if the Object argument
* is an instance of List. Otherwise returns null.
*/
@SuppressWarnings("unchecked")
public static <T> List<T> toList(Object object) {
if (object != null && !(object instanceof List)) {
return null;
}
return (List<T>) object;
public static <T> List<T> toList(Object obj) {
return (obj instanceof List) ? cast(obj) : null;
}

/** Returns the Object argument as a parameterized Map if the Object argument
* is an instance of Map. Otherwise returns null.
*/
@SuppressWarnings("unchecked")
public static <K, V> Map<K, V> toMap(Object object) {
if (object != null && !(object instanceof Map)) {
return null;
}
return (Map<K, V>) object;
public static <K, V> Map<K, V> toMap(Object obj) {
return (obj instanceof Map) ? cast(obj) : null;
}
}

0 comments on commit 7618a51

Please sign in to comment.