3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.remoting
.cache
;
12 import java
.util
.ArrayList
;
13 import java
.util
.HashMap
;
14 import java
.util
.HashSet
;
15 import java
.util
.List
;
18 import java
.util
.TreeMap
;
19 import java
.util
.TreeSet
;
21 import org
.hibernate
.collection
.internal
.PersistentList
;
22 import org
.hibernate
.collection
.internal
.PersistentMap
;
23 import org
.hibernate
.collection
.internal
.PersistentSet
;
24 import org
.hibernate
.collection
.internal
.PersistentSortedMap
;
25 import org
.hibernate
.collection
.internal
.PersistentSortedSet
;
26 import org
.hibernate
.collection
.spi
.PersistentCollection
;
28 import eu
.etaxonomy
.cdm
.model
.common
.PersistentMultiLanguageText
;
29 import eu
.etaxonomy
.taxeditor
.remoting
.CdmRemotingException
;
36 public class ProxyUtils
{
38 public static Object
getObject(PersistentCollection pc
) {
40 if(pc
instanceof PersistentSet
) {
41 return new HashSet((Set
)pc
);
43 if(pc
instanceof PersistentSortedSet
) {
44 return new TreeSet((Set
)pc
);
46 if(pc
instanceof PersistentList
) {
47 return new ArrayList((List
)pc
);
49 if(pc
instanceof PersistentMap
|| pc
instanceof PersistentMultiLanguageText
) {
50 return new HashMap((Map
)pc
);
52 if(pc
instanceof PersistentSortedMap
) {
53 return new TreeMap((Map
)pc
);
55 throw new CdmRemotingException("Cannot get Collection field for type " + pc
.getClass().getName());