Commit c07d86ab4d3421dcbd02d6d1e2f38a74f7c6ae6f
1 parent
b31e88b3
Clarify API: removing set
Showing
4 changed files
with
15 additions
and
12 deletions
Show diff stats
src/main/java/fr/plil/sio/persistence/api/Group.java
@@ -2,8 +2,6 @@ package fr.plil.sio.persistence.api; | @@ -2,8 +2,6 @@ package fr.plil.sio.persistence.api; | ||
2 | 2 | ||
3 | import java.util.LinkedList; | 3 | import java.util.LinkedList; |
4 | import java.util.List; | 4 | import java.util.List; |
5 | -import java.util.Set; | ||
6 | -import java.util.TreeSet; | ||
7 | 5 | ||
8 | public class Group { | 6 | public class Group { |
9 | 7 | ||
@@ -14,7 +12,7 @@ public class Group { | @@ -14,7 +12,7 @@ public class Group { | ||
14 | /** | 12 | /** |
15 | * Users in the group. | 13 | * Users in the group. |
16 | */ | 14 | */ |
17 | - private Set<User> users = new TreeSet<>(); | 15 | + private List<User> users = new LinkedList<>(); |
18 | 16 | ||
19 | /** | 17 | /** |
20 | * List of rights. The list CANNOT contains duplicate rights. | 18 | * List of rights. The list CANNOT contains duplicate rights. |
@@ -45,11 +43,11 @@ public class Group { | @@ -45,11 +43,11 @@ public class Group { | ||
45 | this.name = name; | 43 | this.name = name; |
46 | } | 44 | } |
47 | 45 | ||
48 | - public Set<User> getUsers() { | 46 | + public List<User> getUsers() { |
49 | return users; | 47 | return users; |
50 | } | 48 | } |
51 | 49 | ||
52 | - public void setUsers(Set<User> users) { | 50 | + public void setUsers(List<User> users) { |
53 | this.users = users; | 51 | this.users = users; |
54 | } | 52 | } |
55 | } | 53 | } |
src/main/java/fr/plil/sio/persistence/api/GroupService.java
@@ -23,7 +23,8 @@ public interface GroupService { | @@ -23,7 +23,8 @@ public interface GroupService { | ||
23 | boolean delete(String name); | 23 | boolean delete(String name); |
24 | 24 | ||
25 | /** | 25 | /** |
26 | - * Find a group in the database based on its name. | 26 | + * Find a group in the database based on its name. Only references at one level are available (i.e. the users |
27 | + * who belong to the group). | ||
27 | * | 28 | * |
28 | * @param name the name of the group to search for. | 29 | * @param name the name of the group to search for. |
29 | * @return an instance of the group if found, else null. | 30 | * @return an instance of the group if found, else null. |
@@ -32,7 +33,7 @@ public interface GroupService { | @@ -32,7 +33,7 @@ public interface GroupService { | ||
32 | Group findByName(String name); | 33 | Group findByName(String name); |
33 | 34 | ||
34 | /** | 35 | /** |
35 | - * Add a right in the group. Right is inserted at the end of rights list of the group. | 36 | + * Add a right in the group. |
36 | * | 37 | * |
37 | * @param groupName the name of the group. | 38 | * @param groupName the name of the group. |
38 | * @param right the right to add | 39 | * @param right the right to add |
src/main/java/fr/plil/sio/persistence/api/Right.java
1 | package fr.plil.sio.persistence.api; | 1 | package fr.plil.sio.persistence.api; |
2 | 2 | ||
3 | -import java.util.HashSet; | ||
4 | -import java.util.Set; | 3 | +import java.util.LinkedList; |
4 | +import java.util.List; | ||
5 | 5 | ||
6 | public class Right { | 6 | public class Right { |
7 | 7 | ||
@@ -13,13 +13,13 @@ public class Right { | @@ -13,13 +13,13 @@ public class Right { | ||
13 | private Right parent; | 13 | private Right parent; |
14 | 14 | ||
15 | /// the sibling right(s), eventually empty | 15 | /// the sibling right(s), eventually empty |
16 | - private Set<Right> siblings = new HashSet<>(); | 16 | + private List<Right> siblings = new LinkedList<>(); |
17 | 17 | ||
18 | - public Set<Right> getSiblings() { | 18 | + public List<Right> getSiblings() { |
19 | return siblings; | 19 | return siblings; |
20 | } | 20 | } |
21 | 21 | ||
22 | - public void setSiblings(Set<Right> siblings) { | 22 | + public void setSiblings(List<Right> siblings) { |
23 | this.siblings = siblings; | 23 | this.siblings = siblings; |
24 | } | 24 | } |
25 | 25 |
src/main/java/fr/plil/sio/persistence/api/RightService.java
@@ -16,6 +16,8 @@ public interface RightService { | @@ -16,6 +16,8 @@ public interface RightService { | ||
16 | /** | 16 | /** |
17 | * Create a sibling right attached to a parent right with a specific name in the database. | 17 | * Create a sibling right attached to a parent right with a specific name in the database. |
18 | * It is possible that two rights has the same name. | 18 | * It is possible that two rights has the same name. |
19 | + * Return only the right with the parent in the field parent. | ||
20 | + * | ||
19 | * | 21 | * |
20 | * @param name the name of the right | 22 | * @param name the name of the right |
21 | * @param parent the parent right | 23 | * @param parent the parent right |
@@ -34,6 +36,7 @@ public interface RightService { | @@ -34,6 +36,7 @@ public interface RightService { | ||
34 | 36 | ||
35 | /** | 37 | /** |
36 | * Find a list of rights in the database based on their name. | 38 | * Find a list of rights in the database based on their name. |
39 | + * All dependencies at one-level are loaded, i.e for each right returned the parent and sibling are present. | ||
37 | * | 40 | * |
38 | * @param name the name of the rights to search for. | 41 | * @param name the name of the rights to search for. |
39 | * @return A list of rights, eventually empty. | 42 | * @return A list of rights, eventually empty. |
@@ -43,6 +46,7 @@ public interface RightService { | @@ -43,6 +46,7 @@ public interface RightService { | ||
43 | 46 | ||
44 | /** | 47 | /** |
45 | * Find a right in the database based on its id. | 48 | * Find a right in the database based on its id. |
49 | + * All dependencies at one-level are loaded, i.e the parent and sibling are present. | ||
46 | * | 50 | * |
47 | * @param id the name of the right to search for. | 51 | * @param id the name of the right to search for. |
48 | * @return an instance of the right if found, else null. | 52 | * @return an instance of the right if found, else null. |