Nick Satinover 6 лет назад
Родитель
Сommit
057eeb58c6

+ 14
- 5
src/main/java/com/zipcodewilmington/generic/group/Group.java Просмотреть файл

@@ -3,31 +3,40 @@ 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;
6 7
 import java.util.List;
7 8
 import java.util.function.Predicate;
8 9
 
9 10
 /**
10 11
  * @author leon on 06/12/2018.
11 12
  */
12
-public class Group<ChangeThisTypeRespectively,ChangeThisOneToo> extends AbstractGroup{
13
+public class Group<TypeOfId extends Serializable,
14
+        TypeOfEntity extends IdentifiableInterface<TypeOfId>> extends AbstractGroup<TypeOfId, TypeOfEntity>{
15
+
16
+    List<TypeOfEntity> group;
17
+
18
+    Group(){
19
+        group = new ArrayList<>();
20
+    }
21
+
13 22
     @Override
14 23
     public Integer count() {
15
-        return null;
24
+        return group.size();
16 25
     }
17 26
 
18 27
     @Override
19 28
     public void insert(IdentifiableInterface object) {
20
-
29
+        group.add((TypeOfEntity) object);
21 30
     }
22 31
 
23 32
     @Override
24 33
     public void delete(IdentifiableInterface object) {
25
-
34
+        group.remove(object);
26 35
     }
27 36
 
28 37
     @Override
29 38
     public void delete(Serializable serializable) {
30
-
39
+        group.remove(serializable);
31 40
     }
32 41
 
33 42
     @Override

+ 13
- 5
src/main/java/com/zipcodewilmington/generic/identifiables/ActionFigure.java Просмотреть файл

@@ -5,14 +5,22 @@ import java.io.Serializable;
5 5
 /**
6 6
  * @author leon on 05/12/2018.
7 7
  */
8
-public class ActionFigure implements IdentifiableInterface {
8
+public class ActionFigure<TypeofId extends Serializable> implements IdentifiableInterface<TypeofId> {
9
+    private TypeofId id;
9 10
 
10
-    @Override
11
-    public Serializable getIdentity() {
12
-        return null;
11
+
12
+    public void setId(TypeofId id) {
13
+        this.id = id;
13 14
     }
14 15
 
15
-    public Class getIdentityType() {
16
+    public TypeofId getIdentity() {
16 17
         return null;
17 18
     }
19
+
20
+
21
+    public Class<? extends Serializable> getIdentityType() {
22
+        return id.getClass();
23
+    }
24
+
25
+
18 26
 }

+ 1
- 1
src/main/java/com/zipcodewilmington/generic/identifiables/IdentifiableInterface.java Просмотреть файл

@@ -8,5 +8,5 @@ import java.io.Serializable;
8 8
  */
9 9
 public interface IdentifiableInterface<TypeOfId extends Serializable> {
10 10
     TypeOfId getIdentity();
11
-    Class<? extends TypeOfId> getIdentityType();
11
+    Class<? extends Serializable> getIdentityType();
12 12
 }

+ 8
- 3
src/main/java/com/zipcodewilmington/generic/identifiables/Person.java Просмотреть файл

@@ -5,14 +5,19 @@ import java.io.Serializable;
5 5
 /**
6 6
  * @author leon on 05/12/2018.
7 7
  */
8
-public class Person implements IdentifiableInterface {
8
+public class Person<TypeofId extends Serializable> implements IdentifiableInterface<TypeofId> {
9
+    private TypeofId id;
10
+
11
+    public void setId(TypeofId id){
12
+
13
+    }
9 14
 
10 15
     @Override
11
-    public Serializable getIdentity() {
16
+    public TypeofId getIdentity() {
12 17
         return null;
13 18
     }
14 19
 
15 20
     public Class getIdentityType() {
16
-        return null;
21
+        return id.getClass();
17 22
     }
18 23
 }

+ 2
- 2
src/test/java/com/zipcodewilmington/generic/group/TestParameterization.java Просмотреть файл

@@ -12,7 +12,7 @@ import org.junit.Test;
12 12
 public class TestParameterization {
13 13
     @Test
14 14
     public void testStringAndPersonParameterization() {
15
-        Group<String, Person> personGroup = new Group<>();
15
+        Group<String, Person<String>> personGroup = new Group<>();
16 16
         String expectedIdentityType = "java.io.Serializable";
17 17
         String expectedIdentifiableType = "com.zipcodewilmington.generic.identifiables.IdentifiableInterface";
18 18
 
@@ -26,7 +26,7 @@ public class TestParameterization {
26 26
 
27 27
     @Test
28 28
     public void testLongAndActionFigureParameterization() {
29
-        Group<Long, ActionFigure> group = new Group<>();
29
+        Group<Long, ActionFigure<Long>> group = new Group<>();
30 30
         String expectedIdentityType = "java.io.Serializable";
31 31
         String expectedIdentifiableType = "com.zipcodewilmington.generic.identifiables.IdentifiableInterface";
32 32