|
@@ -8,6 +8,7 @@ import java.util.Iterator;
|
8
|
8
|
import java.util.List;
|
9
|
9
|
import java.util.function.Predicate;
|
10
|
10
|
import java.util.function.Supplier;
|
|
11
|
+import java.util.stream.Collectors;
|
11
|
12
|
|
12
|
13
|
/**
|
13
|
14
|
* @author leon on 06/12/2018.
|
|
@@ -17,11 +18,10 @@ public class Group<TypeOfId extends Serializable ,TypeOfEntity extends Identifia
|
17
|
18
|
|
18
|
19
|
public Group() {
|
19
|
20
|
this.list = new ArrayList<>();
|
20
|
|
- this.aClass = list.getClass();
|
21
|
21
|
}
|
22
|
22
|
|
23
|
23
|
private ArrayList<TypeOfEntity> list;
|
24
|
|
- private Class aClass;
|
|
24
|
+
|
25
|
25
|
|
26
|
26
|
@Override
|
27
|
27
|
public Integer count() {
|
|
@@ -43,7 +43,7 @@ public class Group<TypeOfId extends Serializable ,TypeOfEntity extends Identifia
|
43
|
43
|
Iterator iterator = list.iterator();
|
44
|
44
|
while (iterator.hasNext()){
|
45
|
45
|
IdentifiableInterface next = (IdentifiableInterface) iterator.next();
|
46
|
|
- if(next.getIdentity().equals(serializable)) list.remove(next);
|
|
46
|
+ if(next.getIdentity().equals(serializable)) iterator.remove();
|
47
|
47
|
}
|
48
|
48
|
}
|
49
|
49
|
|
|
@@ -67,7 +67,9 @@ public class Group<TypeOfId extends Serializable ,TypeOfEntity extends Identifia
|
67
|
67
|
|
68
|
68
|
@Override
|
69
|
69
|
public List filter(Predicate predicate) {
|
70
|
|
- return null;
|
|
70
|
+ return (ArrayList<TypeOfEntity>)list.stream()
|
|
71
|
+ .filter(predicate)
|
|
72
|
+ .collect(Collectors.toList());
|
71
|
73
|
}
|
72
|
74
|
|
73
|
75
|
@Override
|
|
@@ -77,7 +79,9 @@ public class Group<TypeOfId extends Serializable ,TypeOfEntity extends Identifia
|
77
|
79
|
|
78
|
80
|
@Override
|
79
|
81
|
public Class getIdentifiableType() {
|
80
|
|
- return null;
|
|
82
|
+
|
|
83
|
+ return this.getClass().getEnclosingClass();
|
81
|
84
|
}
|
82
|
85
|
|
|
86
|
+
|
83
|
87
|
}
|