Skip to content
Permalink
Browse files

Improved: Rewrite ‘UtilGenerics#toList’ and ‘UtilGenerics#toMap’

(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 7618a51f6849183c7728367746a487681e1cafa0
Showing with 4 additions and 12 deletions.
  1. +4 −12 framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java
@@ -89,22 +89,14 @@ private UtilGenerics() {}
/** 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.
You can’t perform that action at this time.