public abstract class GroupDB
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Collection<GroupRecord> |
data
The collection of group data records.
|
(package private) UserDB |
userDB
Reference to GroupDB needed for change and delete methods.
|
Constructor and Description |
---|
GroupDB() |
Modifier and Type | Method and Description |
---|---|
(package private) abstract void |
add(GroupRecord gr)
Add the given GroupRecord to the given GroupDB.
|
(package private) abstract void |
change(GroupRecord old_gr,
GroupRecord new_gr)
Change the given old GroupRecord to the given new record.
|
(package private) abstract void |
delete(GroupRecord gr)
Delete the given group record from the given GroupDB.
|
(package private) abstract GroupRecord |
findById(java.lang.String id)
Find a group by unique name.
|
java.util.Collection<GroupRecord> data
UserDB userDB
abstract void add(GroupRecord gr)
pre: // // All group members are registered users. // forall (String id ; gr.members.contains(id) ; exists(UserRecord ur ; userDB.data.contains(ur) ; ur.id.equals(id))) && // // All group leaders are members of the group. // forall (String id ; gr.leaders.contains(id) ; gr.members.contains(id)); post: // // A group record is in the output db if and only if it is the new // record to be added or it is in the input db. // forall (GroupRecord gr_other ; data'.contains(gr_other) iff gr_other.equals(gr) || data.contains(gr_other));
abstract void delete(GroupRecord gr)
pre: // // The given GroupRecord is in the given GroupDB. // data.contains(gr); post: // // A group record is in the output db if and only if it is not the // existing record to be deleted and it is in the input db. // forall (GroupRecord gr_other ; data'.contains(gr_other) iff !gr_other.equals(gr) && data.contains(gr_other));
abstract void change(GroupRecord old_gr, GroupRecord new_gr)
pre: // // The old and new group records are not the same. // !old_gr.equals(new_gr) && // // All group members are registered users. // forall (String id ; new_gr.members.contains(id) ; exists(UserRecord ur ; userDB.data.contains(ur) && ur.id.equals(id))) && // // All group leaders are members of the group. // forall (String id ; new_gr.leaders.contains(id) ; new_gr.members.contains(id)); post: // // A group record is in the output db if and only if it is the new // record to be added or it is in the input db, and it is not the old // record. // forall (GroupRecord gr_other ; data'.contains(gr_other) iff gr_other.equals(new_gr) || data.contains(gr_other) && !gr_other.equals(old_gr));
abstract GroupRecord findById(java.lang.String id)
post: // // If there is a record with the given name in the input db, then the // output record is equal to that record, otherwise the output record // is empty. // exists(GroupRecord gr_found ; data.contains(gr_found) ; gr_found.name.equals(id) && gr_found.equals(return)) || !exists(GroupRecord gr_found ; data.contains(gr_found) ; gr_found.name.equals(id)) && return == null;