1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.impl;
20
21 import java.io.Serializable;
22 import java.util.List;
23
24 import javax.persistence.metamodel.SingularAttribute;
25
26 import com.hack23.cia.service.api.DataContainer;
27 import com.hack23.cia.service.data.api.DataViewer;
28
29
30
31
32
33
34
35
36
37 final class GenericDataContainer<T extends Serializable, I extends Serializable> implements
38 DataContainer<T, I> {
39
40
41
42
43 private final DataViewer dataProxy;
44
45
46 private final Class<T> clazz;
47
48
49
50
51
52
53
54
55
56 GenericDataContainer(final Class<T> clazz, final DataViewer dataViewer) {
57 this.clazz = clazz;
58 dataProxy = dataViewer;
59 }
60
61 @Override
62 public <T, V> T findByQueryProperty(final Class<T> clazz,
63 final SingularAttribute<T, ? extends Object> property,
64 final Class<V> clazz2,
65 final SingularAttribute<V, ? extends Object> property2, final Object value) {
66 return dataProxy.findByQueryProperty(clazz, property, clazz2, property2, value);
67 }
68
69 @Override
70 public <T, V> List<T> findListByEmbeddedProperty(final Class<T> clazz,
71 final SingularAttribute<T, V> property,
72 final Class<V> clazz2,
73 final SingularAttribute<V, ? extends Object> property2, final Object value) {
74 return dataProxy.findListByEmbeddedProperty(clazz, property, clazz2, property2, value);
75 }
76
77
78
79 @Override
80 public List<T> findListByProperty(final Object[] values,
81 final SingularAttribute<T, ? extends Object>... properties) {
82 return dataProxy.findListByProperty(clazz, values, properties);
83 }
84
85 @Override
86 public <T, V> List<T> findOrderedByPropertyListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
87 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
88 final SingularAttribute<T, ? extends Object> orderByProperty) {
89 return dataProxy.findOrderedByPropertyListByEmbeddedProperty(clazz,property,clazz2,property2,value,orderByProperty);
90 }
91
92 @Override
93 public <T, V> List<T> findOrderedListByEmbeddedProperty(final Class<T> clazz, final SingularAttribute<T, V> property,
94 final Class<V> clazz2, final SingularAttribute<V, ? extends Object> property2, final Object value,
95 final SingularAttribute<V, ? extends Object> orderByProperty) {
96 return dataProxy.findOrderedListByEmbeddedProperty(clazz,property,clazz2,property2,value,orderByProperty);
97 }
98
99 @Override
100 public List<T> findOrderedListByProperty(final SingularAttribute<T, ? extends Object> property, final Object value,
101 final SingularAttribute<T, ? extends Object> orderByProperty) {
102 return dataProxy.findOrderedListByProperty(clazz,property,value,orderByProperty);
103 }
104
105 @Override
106 public List<T> findOrderedListByProperty(final SingularAttribute<T, ? extends Object> orderByProperty, final Object[] values,
107 final SingularAttribute<T, ? extends Object>... properties) {
108 return dataProxy.findOrderedListByProperty(clazz,orderByProperty,values, properties);
109 }
110
111 @Override
112 public List<T> getAll() {
113 return dataProxy.getAll(clazz);
114 }
115
116 @Override
117 public List<T> getAllBy(
118 final SingularAttribute<T, ? extends Object> property,
119 final Object value) {
120 return dataProxy.findListByProperty(clazz, property, value);
121 }
122
123 @Override
124 public List<T> getAllOrderBy(final SingularAttribute<T, ? extends Object> property) {
125 return dataProxy.getAllOrderBy(clazz,property);
126 }
127
128 @Override
129 public T load(final I id) {
130 return dataProxy.load(clazz, id);
131
132 }
133
134 @Override
135 public List<T> getPage(final int pageNr, final int resultPerPage) {
136 return dataProxy.getPage(clazz,pageNr, resultPerPage);
137 }
138
139 @Override
140 public List<T> getPageOrderBy(final int pageNr, final int resultPerPage, final SingularAttribute<T, ? extends Object> orderBy) {
141 return dataProxy.getPageOrderBy(clazz,pageNr, resultPerPage, orderBy);
142 }
143
144 @Override
145 public Long getSize() {
146 return dataProxy.getSize(clazz);
147 }
148
149 }