From: Andreas Müller Date: Tue, 31 May 2016 11:41:34 +0000 (+0200) Subject: Cleanup ProxyUtils X-Git-Tag: 4.1.0^2~1 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/e8af0ea6fa10ff619ea3840033f7922717236c17 Cleanup ProxyUtils --- 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()) {