From e8af0ea6fa10ff619ea3840033f7922717236c17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20M=C3=BCller?= Date: Tue, 31 May 2016 13:41:34 +0200 Subject: [PATCH] Cleanup ProxyUtils --- .../taxeditor/remoting/cache/ProxyUtils.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java index 8cffe58e3..03bb2520b 100644 --- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java +++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/ProxyUtils.java @@ -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()) { -- 2.34.1