|
@@ -3,41 +3,66 @@ package com.zipcodewilmington.generic.group;
|
3
|
3
|
import com.zipcodewilmington.generic.identifiables.IdentifiableInterface;
|
4
|
4
|
|
5
|
5
|
import java.io.Serializable;
|
|
6
|
+import java.util.ArrayList;
|
|
7
|
+import java.util.Iterator;
|
6
|
8
|
import java.util.List;
|
7
|
9
|
import java.util.function.Predicate;
|
|
10
|
+import java.util.function.Supplier;
|
8
|
11
|
|
9
|
12
|
/**
|
10
|
13
|
* @author leon on 06/12/2018.
|
11
|
14
|
*/
|
12
|
|
-public class Group<ChangeThisTypeRespectively,ChangeThisOneToo> extends AbstractGroup{
|
|
15
|
+public class Group<TypeOfId extends Serializable ,TypeOfEntity extends IdentifiableInterface<TypeOfId>>
|
|
16
|
+ extends AbstractGroup<TypeOfId, TypeOfEntity>{
|
|
17
|
+
|
|
18
|
+ public Group() {
|
|
19
|
+ this.list = new ArrayList<>();
|
|
20
|
+ this.aClass = list.getClass();
|
|
21
|
+ }
|
|
22
|
+
|
|
23
|
+ private ArrayList<TypeOfEntity> list;
|
|
24
|
+ private Class aClass;
|
|
25
|
+
|
13
|
26
|
@Override
|
14
|
27
|
public Integer count() {
|
15
|
|
- return null;
|
|
28
|
+ return list.size();
|
16
|
29
|
}
|
17
|
30
|
|
18
|
31
|
@Override
|
19
|
|
- public void insert(IdentifiableInterface object) {
|
20
|
|
-
|
|
32
|
+ public void insert(TypeOfEntity object) {
|
|
33
|
+ list.add(object);
|
21
|
34
|
}
|
22
|
35
|
|
23
|
36
|
@Override
|
24
|
|
- public void delete(IdentifiableInterface object) {
|
25
|
|
-
|
|
37
|
+ public void delete(TypeOfEntity object) {
|
|
38
|
+ list.remove(object);
|
26
|
39
|
}
|
27
|
40
|
|
28
|
41
|
@Override
|
29
|
|
- public void delete(Serializable serializable) {
|
30
|
|
-
|
|
42
|
+ public void delete(TypeOfId serializable) {
|
|
43
|
+ Iterator iterator = list.iterator();
|
|
44
|
+ while (iterator.hasNext()){
|
|
45
|
+ IdentifiableInterface next = (IdentifiableInterface) iterator.next();
|
|
46
|
+ if(next.getIdentity().equals(serializable)) list.remove(next);
|
|
47
|
+ }
|
31
|
48
|
}
|
32
|
49
|
|
33
|
50
|
@Override
|
34
|
|
- public Boolean has(IdentifiableInterface object) {
|
35
|
|
- return null;
|
|
51
|
+ public Boolean has(TypeOfEntity object) {
|
|
52
|
+ for (IdentifiableInterface id : list) {
|
|
53
|
+ if (list.contains(id)) return true;
|
|
54
|
+ }
|
|
55
|
+ return false;
|
36
|
56
|
}
|
37
|
57
|
|
38
|
58
|
@Override
|
39
|
|
- public Boolean has(Serializable serializable) {
|
40
|
|
- return null;
|
|
59
|
+ public Boolean has(TypeOfId serializable) {
|
|
60
|
+ Iterator iterator = list.iterator();
|
|
61
|
+ while (iterator.hasNext()){
|
|
62
|
+ IdentifiableInterface next = (IdentifiableInterface) iterator.next();
|
|
63
|
+ if(next.getIdentity().equals(serializable)) return true;
|
|
64
|
+ }
|
|
65
|
+ return false;
|
41
|
66
|
}
|
42
|
67
|
|
43
|
68
|
@Override
|
|
@@ -47,7 +72,7 @@ public class Group<ChangeThisTypeRespectively,ChangeThisOneToo> extends Abstract
|
47
|
72
|
|
48
|
73
|
@Override
|
49
|
74
|
public Class getIdentityType() {
|
50
|
|
- return null;
|
|
75
|
+ return list.getClass();
|
51
|
76
|
}
|
52
|
77
|
|
53
|
78
|
@Override
|