Преглед изворни кода

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

Leon пре 6 година
родитељ
комит
4aa89c5ce4

+ 1
- 1
pom.xml Прегледај датотеку

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

+ 0
- 1
src/main/java/com/zipcodewilmington/generic/group/AbstractGroup.java Прегледај датотеку

11
         TypeOfId extends Serializable,
11
         TypeOfId extends Serializable,
12
         TypeOfEntity extends IdentifiableInterface<TypeOfId>>
12
         TypeOfEntity extends IdentifiableInterface<TypeOfId>>
13
         implements GroupInterface<TypeOfId, TypeOfEntity> {
13
         implements GroupInterface<TypeOfId, TypeOfEntity> {
14
-
15
 }
14
 }

+ 11
- 0
src/main/java/com/zipcodewilmington/generic/group/Group.java Прегледај датотеку

44
     public List filter(Predicate predicate) {
44
     public List filter(Predicate predicate) {
45
         return null;
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 Прегледај датотеку

14
         TypeOfId extends Serializable,
14
         TypeOfId extends Serializable,
15
         TypeOfEntity extends IdentifiableInterface<TypeOfId>> {
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 Прегледај датотеку

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
+}