Cleanup ProxyUtils
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 31 May 2016 11:41:34 +0000 (13:41 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 31 May 2016 11:41:34 +0000 (13:41 +0200)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java

index 8cffe58e306554283371eb681a154eb5b4bb2485..03bb2520b375258c3f662f63ec4650c3b6da4110 100644 (file)
@@ -80,19 +80,19 @@ public class ProxyUtils {
     public static Object getObject(PersistentCollection pc) {
         if(pc != null) {
             if(pc instanceof PersistentSet) {
-                return new HashSet((Set)pc);
+                return new HashSet<>((Set<?>)pc);
             }
             if(pc instanceof PersistentSortedSet) {
-                return new TreeSet((Set)pc);
+                return new TreeSet<>((Set<?>)pc);
             }
             if(pc instanceof PersistentList || pc instanceof PersistentBag) {
-                return new ArrayList((List)pc);
+                return new ArrayList<>((List<?>)pc);
             }
             if(pc instanceof PersistentMap || pc instanceof PersistentMultiLanguageText) {
-                return new HashMap((Map)pc);
+                return new HashMap<>((Map<?,?>)pc);
             }
             if(pc instanceof PersistentSortedMap) {
-                return new TreeMap((Map)pc);
+                return new TreeMap<>((Map<?,?>)pc);
             }
             throw new CdmRemotingException("Cannot get Collection field for type " + pc.getClass().getName());
         }
@@ -102,19 +102,19 @@ public class ProxyUtils {
     public static CollectionField getCollectionField(PersistentCollection pc) {
         if(pc != null) {
             if(pc instanceof PersistentSet) {
-                return new CollectionField(new HashSet((Set)pc), CollectionType.SET);
+                return new CollectionField(new HashSet<>((Set<?>)pc), CollectionType.SET);
             }
             if(pc instanceof PersistentSortedSet) {
-                return new CollectionField(new TreeSet((Set)pc), CollectionType.SET);
+                return new CollectionField(new TreeSet<>((Set<?>)pc), CollectionType.SET);
             }
             if(pc instanceof PersistentList) {
-                return new CollectionField(new ArrayList((List)pc), CollectionType.LIST);
+                return new CollectionField(new ArrayList<>((List<?>)pc), CollectionType.LIST);
             }
             if(pc instanceof PersistentMap || pc instanceof PersistentMultiLanguageText) {
-                return new CollectionField(new HashMap((Map)pc), CollectionType.MAP);
+                return new CollectionField(new HashMap<>((Map<?,?>)pc), CollectionType.MAP);
             }
             if(pc instanceof PersistentSortedMap) {
-                return new CollectionField(new TreeMap((Map)pc), CollectionType.MAP);
+                return new CollectionField(new TreeMap<>((Map<?,?>)pc), CollectionType.MAP);
             }
             throw new CdmRemotingException("Cannot get Collection field for type " + pc.getClass().getName());
         }
@@ -176,7 +176,8 @@ public class ProxyUtils {
         return false;
     }
 
-    public static Object remoteLoadPersistentCollectionIfProxy(Object o, UUID ownerUuid, String fieldName) throws ClassNotFoundException {
+    @SuppressWarnings("unchecked")
+       public static Object remoteLoadPersistentCollectionIfProxy(Object o, UUID ownerUuid, String fieldName) throws ClassNotFoundException {
         if(o != null && o instanceof HibernateProxy) {
             LazyInitializer hli = ((HibernateProxy)o).getHibernateLazyInitializer();
             if(hli.isUninitialized()) {