From c07d86ab4d3421dcbd02d6d1e2f38a74f7c6ae6f Mon Sep 17 00:00:00 2001 From: jcartign Date: Tue, 20 Sep 2016 07:53:11 +0200 Subject: [PATCH] Clarify API: removing set --- src/main/java/fr/plil/sio/persistence/api/Group.java | 8 +++----- src/main/java/fr/plil/sio/persistence/api/GroupService.java | 5 +++-- src/main/java/fr/plil/sio/persistence/api/Right.java | 10 +++++----- src/main/java/fr/plil/sio/persistence/api/RightService.java | 4 ++++ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/plil/sio/persistence/api/Group.java b/src/main/java/fr/plil/sio/persistence/api/Group.java index d9cf671..c629518 100644 --- a/src/main/java/fr/plil/sio/persistence/api/Group.java +++ b/src/main/java/fr/plil/sio/persistence/api/Group.java @@ -2,8 +2,6 @@ package fr.plil.sio.persistence.api; import java.util.LinkedList; import java.util.List; -import java.util.Set; -import java.util.TreeSet; public class Group { @@ -14,7 +12,7 @@ public class Group { /** * Users in the group. */ - private Set users = new TreeSet<>(); + private List users = new LinkedList<>(); /** * List of rights. The list CANNOT contains duplicate rights. @@ -45,11 +43,11 @@ public class Group { this.name = name; } - public Set getUsers() { + public List getUsers() { return users; } - public void setUsers(Set users) { + public void setUsers(List users) { this.users = users; } } diff --git a/src/main/java/fr/plil/sio/persistence/api/GroupService.java b/src/main/java/fr/plil/sio/persistence/api/GroupService.java index f2992a9..c20990a 100644 --- a/src/main/java/fr/plil/sio/persistence/api/GroupService.java +++ b/src/main/java/fr/plil/sio/persistence/api/GroupService.java @@ -23,7 +23,8 @@ public interface GroupService { boolean delete(String name); /** - * Find a group in the database based on its name. + * Find a group in the database based on its name. Only references at one level are available (i.e. the users + * who belong to the group). * * @param name the name of the group to search for. * @return an instance of the group if found, else null. @@ -32,7 +33,7 @@ public interface GroupService { Group findByName(String name); /** - * Add a right in the group. Right is inserted at the end of rights list of the group. + * Add a right in the group. * * @param groupName the name of the group. * @param right the right to add diff --git a/src/main/java/fr/plil/sio/persistence/api/Right.java b/src/main/java/fr/plil/sio/persistence/api/Right.java index 5f6335c..291f2c0 100644 --- a/src/main/java/fr/plil/sio/persistence/api/Right.java +++ b/src/main/java/fr/plil/sio/persistence/api/Right.java @@ -1,7 +1,7 @@ package fr.plil.sio.persistence.api; -import java.util.HashSet; -import java.util.Set; +import java.util.LinkedList; +import java.util.List; public class Right { @@ -13,13 +13,13 @@ public class Right { private Right parent; /// the sibling right(s), eventually empty - private Set siblings = new HashSet<>(); + private List siblings = new LinkedList<>(); - public Set getSiblings() { + public List getSiblings() { return siblings; } - public void setSiblings(Set siblings) { + public void setSiblings(List siblings) { this.siblings = siblings; } diff --git a/src/main/java/fr/plil/sio/persistence/api/RightService.java b/src/main/java/fr/plil/sio/persistence/api/RightService.java index 469cdbc..5bebe3e 100644 --- a/src/main/java/fr/plil/sio/persistence/api/RightService.java +++ b/src/main/java/fr/plil/sio/persistence/api/RightService.java @@ -16,6 +16,8 @@ public interface RightService { /** * Create a sibling right attached to a parent right with a specific name in the database. * It is possible that two rights has the same name. + * Return only the right with the parent in the field parent. + * * * @param name the name of the right * @param parent the parent right @@ -34,6 +36,7 @@ public interface RightService { /** * Find a list of rights in the database based on their name. + * All dependencies at one-level are loaded, i.e for each right returned the parent and sibling are present. * * @param name the name of the rights to search for. * @return A list of rights, eventually empty. @@ -43,6 +46,7 @@ public interface RightService { /** * Find a right in the database based on its id. + * All dependencies at one-level are loaded, i.e the parent and sibling are present. * * @param id the name of the right to search for. * @return an instance of the right if found, else null. -- libgit2 0.21.2