1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.objects; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Map; |
27 |
|
|
28 |
|
import org.hibernate.HibernateException; |
29 |
|
import org.hibernate.collection.PersistentCollection; |
30 |
|
import org.hibernate.engine.SessionImplementor; |
31 |
|
import org.hibernate.persister.collection.CollectionPersister; |
32 |
|
import org.hibernate.usertype.UserCollectionType; |
33 |
|
|
34 |
|
import com.xpn.xwiki.objects.ListProperty.NotifyList; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@since |
40 |
|
@version |
41 |
|
|
|
|
| 30.8% |
Uncovered Elements: 18 (26) |
Complexity: 9 |
Complexity Density: 0.6 |
|
42 |
|
public class ListPropertyCollectionType implements UserCollectionType |
43 |
|
{ |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
358 |
@Override... |
46 |
|
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) |
47 |
|
throws HibernateException |
48 |
|
{ |
49 |
358 |
return new ListPropertyPersistentList(session); |
50 |
|
} |
51 |
|
|
|
|
| 33.3% |
Uncovered Elements: 6 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
52 |
249 |
@Override... |
53 |
|
@SuppressWarnings("unchecked") |
54 |
|
public PersistentCollection wrap(SessionImplementor session, Object collection) |
55 |
|
{ |
56 |
249 |
if (collection instanceof NotifyList) { |
57 |
249 |
return new ListPropertyPersistentList(session, (NotifyList) collection); |
58 |
0 |
} else if (collection instanceof NotifyList) { |
59 |
0 |
return new ListPropertyPersistentList(session, new NotifyList((List<String>) collection)); |
60 |
|
} else { |
61 |
0 |
throw new IllegalArgumentException("Can only wrap ListProperty.NotifyList."); |
62 |
|
} |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
@Override... |
66 |
|
@SuppressWarnings("unchecked") |
67 |
|
public Iterator getElementsIterator(Object collection) |
68 |
|
{ |
69 |
0 |
return ((Collection<?>) collection).iterator(); |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0 |
@Override... |
73 |
|
@SuppressWarnings("unchecked") |
74 |
|
public boolean contains(Object collection, Object entity) |
75 |
|
{ |
76 |
0 |
return ((Collection<?>) collection).contains(entity); |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
@Override... |
80 |
|
@SuppressWarnings("unchecked") |
81 |
|
public Object indexOf(Object collection, Object entity) |
82 |
|
{ |
83 |
0 |
return ((List) collection).indexOf(entity); |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
86 |
0 |
@Override... |
87 |
|
@SuppressWarnings("unchecked") |
88 |
|
public Object replaceElements( |
89 |
|
Object original, |
90 |
|
Object target, |
91 |
|
CollectionPersister persister, |
92 |
|
Object owner, |
93 |
|
Map copyCache, |
94 |
|
SessionImplementor session) |
95 |
|
throws HibernateException |
96 |
|
{ |
97 |
0 |
Collection cTarget = (Collection) target; |
98 |
0 |
Collection cOriginal = (Collection) original; |
99 |
|
|
100 |
0 |
cTarget.clear(); |
101 |
0 |
cTarget.addAll(cOriginal); |
102 |
|
|
103 |
0 |
return cTarget; |
104 |
|
} |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
358 |
@Override... |
107 |
|
public Object instantiate(int anticipatedSize) |
108 |
|
{ |
109 |
358 |
return new NotifyList(new ArrayList<String>()); |
110 |
|
} |
111 |
|
} |