Browse Source

added methods and testing for `GroupInterface.getIdentityType()` and `GroupInterface.getIdentifiableType()`

Leon 6 years ago
parent
commit
4aa89c5ce4

+ 1
- 1
pom.xml View File

@@ -5,7 +5,7 @@
5 5
     <modelVersion>4.0.0</modelVersion>
6 6
 
7 7
     <groupId>com.zipcodewilmington</groupId>
8
-    <artifactId>quiz2</artifactId>
8
+    <artifactId>genericslab</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10 10
 
11 11
     <properties>

+ 0
- 1
src/main/java/com/zipcodewilmington/generic/group/AbstractGroup.java View File

@@ -11,5 +11,4 @@ abstract public class AbstractGroup<
11 11
         TypeOfId extends Serializable,
12 12
         TypeOfEntity extends IdentifiableInterface<TypeOfId>>
13 13
         implements GroupInterface<TypeOfId, TypeOfEntity> {
14
-
15 14
 }

+ 11
- 0
src/main/java/com/zipcodewilmington/generic/group/Group.java View File

@@ -44,4 +44,15 @@ public class Group<ChangeThisTypeRespectively,ChangeThisOneToo> extends Abstract
44 44
     public List filter(Predicate predicate) {
45 45
         return null;
46 46
     }
47
+
48
+    @Override
49
+    public Class getIdentityType() {
50
+        return null;
51
+    }
52
+
53
+    @Override
54
+    public Class getIdentifiableType() {
55
+        return null;
56
+    }
57
+
47 58
 }

+ 12
- 8
src/main/java/com/zipcodewilmington/generic/group/GroupInterface.java View File

@@ -14,17 +14,21 @@ public interface GroupInterface<
14 14
         TypeOfId extends Serializable,
15 15
         TypeOfEntity extends IdentifiableInterface<TypeOfId>> {
16 16
 
17
-   Integer count();
17
+    Integer count();
18 18
 
19
-   void insert(TypeOfEntity object);
20
-    
21
-   void delete(TypeOfEntity object);
19
+    void insert(TypeOfEntity object);
22 20
 
23
-   void delete(TypeOfId id);
21
+    void delete(TypeOfEntity object);
24 22
 
25
-   Boolean has(TypeOfEntity object);
23
+    void delete(TypeOfId id);
26 24
 
27
-   Boolean has(TypeOfId id);
25
+    Boolean has(TypeOfEntity object);
28 26
 
29
-   List<TypeOfEntity> filter(Predicate<TypeOfEntity> predicate);
27
+    Boolean has(TypeOfId id);
28
+
29
+    List<TypeOfEntity> filter(Predicate<TypeOfEntity> predicate);
30
+
31
+    Class<? extends TypeOfId> getIdentityType();
32
+
33
+    Class<? extends TypeOfEntity> getIdentifiableType();
30 34
 }

+ 28
- 0
src/test/java/com/zipcodewilmington/generic/group/GetIdentityTypeTest.java View File

@@ -0,0 +1,28 @@
1
+package com.zipcodewilmington.generic.group;
2
+
3
+import com.zipcodewilmington.generic.identifiables.ActionFigure;
4
+import com.zipcodewilmington.generic.identifiables.Person;
5
+import org.junit.Assert;
6
+import org.junit.Test;
7
+
8
+/**
9
+ * @author leon on 06/12/2018.
10
+ * there is meaning to the madness
11
+ * ( ͡☉ ͜ʖ ͡☉)
12
+ */
13
+public class GetIdentityTypeTest {
14
+    private Group<String, Person> personGroup = new Group<>();
15
+    private Group<Long, ActionFigure> actionFigureGroup = new Group<>();
16
+
17
+    @Test
18
+    public void testGetIdentityType() { // ༼∵༽ ༼⍨༽ ༼⍢༽ ༼⍤༽
19
+        Assert.assertEquals(personGroup.getIdentityType(), String.class);
20
+        Assert.assertEquals(actionFigureGroup.getIdentityType(), Long.class);
21
+    }
22
+
23
+    @Test
24
+    public void testGetIdentifiableType() { // ヽ༼ ಠ益ಠ ༽ノ
25
+        Assert.assertEquals(personGroup.getIdentifiableType(), Person.class);
26
+        Assert.assertEquals(actionFigureGroup.getIdentifiableType(), ActionFigure.class);
27
+    }
28
+}