Changed the SimpleRegistry and VoterRegistryMessage Documentation

The documentation was partial in part of the methods
Voter-Registry
Vladimir Eliezer Tokarev 2016-01-22 06:23:25 -08:00
parent d4d2d2f5b6
commit 4324bdeecd
2 changed files with 17 additions and 13 deletions

View File

@ -32,6 +32,11 @@ public class SimpleRegistry {
this.communicator = communicator; this.communicator = communicator;
} }
/**
* Creates array of Tags in given length
* @param length the length og wanted array
* @return Tag.Builder[]
*/
private Tag.Builder[] GetTagsArrayInLength(int length) { private Tag.Builder[] GetTagsArrayInLength(int length) {
Tag.Builder[] tags = new Tag.Builder[length]; Tag.Builder[] tags = new Tag.Builder[length];
@ -96,18 +101,17 @@ public class SimpleRegistry {
private List<VoterRegistryMessage> GetRelevantVoterRegistryMessages(List<Tag> tags) throws InvalidProtocolBufferException { private List<VoterRegistryMessage> GetRelevantVoterRegistryMessages(List<Tag> tags) throws InvalidProtocolBufferException {
List<BulletinBoardAPI.BulletinBoardMessage> relevantMessages = GetRelevantMessages(tags); List<BulletinBoardAPI.BulletinBoardMessage> relevantMessages = GetRelevantMessages(tags);
List<BasicMessage> messages = CollectionMessagesUtils.GetBasicMessagesFromBulletinBoardMessages(relevantMessages); List<BasicMessage> messages = CollectionMessagesUtils.GetBasicMessagesFromBulletinBoardMessages(relevantMessages);
List<VoterRegistryMessage> voterRegistryMessages = CollectionMessagesUtils.ConvertToVoterRegistryMessages(messages); return CollectionMessagesUtils.ConvertToVoterRegistryMessages(messages);
return voterRegistryMessages;
} }
/** /**
* Adds new voter to the bulletin-board * Adds new voter to the bulletin-board
* *
* @param voterID * @param voterID id of the new user
* @param personalData for example residence location * @param personalData for example residence location
* @return void * @return void
* @throws throws CommunicationException * @throws CommunicationException, IOException
*/ */
public void AddVoter(String voterID, String personalData) throws CommunicationException, IOException { public void AddVoter(String voterID, String personalData) throws CommunicationException, IOException {
Tag.Builder[] tags = GetTagsArrayInLength(3); Tag.Builder[] tags = GetTagsArrayInLength(3);
@ -124,8 +128,8 @@ public class SimpleRegistry {
/** /**
* Adding given voter to given group * Adding given voter to given group
* *
* @param voterID * @param voterID the voter id
* @param groupID * @param groupID the group id to which we want add the voter
* @return true if the adding action succeeded else return false * @return true if the adding action succeeded else return false
* @throws CommunicationException * @throws CommunicationException
*/ */
@ -145,8 +149,8 @@ public class SimpleRegistry {
/** /**
* Removes given voter from given group * Removes given voter from given group
* *
* @param voterID * @param voterID the voter id
* @param groupID * @param groupID the group from which we want to remove the user
* @return true if the removing action succeeded else return false * @return true if the removing action succeeded else return false
* @throws CommunicationException * @throws CommunicationException
*/ */
@ -190,7 +194,7 @@ public class SimpleRegistry {
* @throws CommunicationException, InvalidProtocolBufferException * @throws CommunicationException, InvalidProtocolBufferException
*/ */
public List<String> GetGroups(String id) throws CommunicationException, InvalidProtocolBufferException { public List<String> GetGroups(String id) throws CommunicationException, InvalidProtocolBufferException {
List<Tag> GroupsActionsTags = new ArrayList<Tag>(); List<Tag> GroupsActionsTags = new ArrayList<>();
GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.ID_TAG + " " + id).build()); GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.ID_TAG + " " + id).build());
GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.GROUP_ACTION_TAG + " " + RegistryTags.REMOVE_FROM_GROUP_TAG).build()); GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.GROUP_ACTION_TAG + " " + RegistryTags.REMOVE_FROM_GROUP_TAG).build());
GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.GROUP_ACTION_TAG + " " + RegistryTags.ADD_TO_GROUP_TAG).build()); GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.GROUP_ACTION_TAG + " " + RegistryTags.ADD_TO_GROUP_TAG).build());
@ -213,7 +217,7 @@ public class SimpleRegistry {
* @throws CommunicationException * @throws CommunicationException
*/ */
public List<String> GetPersonIDDetails(String id) throws CommunicationException, InvalidProtocolBufferException, ParseException { public List<String> GetPersonIDDetails(String id) throws CommunicationException, InvalidProtocolBufferException, ParseException {
List<Tag> GroupsActionsTags = new ArrayList<Tag>(); List<Tag> GroupsActionsTags = new ArrayList<>();
GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.ID_TAG + " " + id).build()); GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.ID_TAG + " " + id).build());
GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.VOTER_ENTRY_TAG.toString()).build()); GroupsActionsTags.add(Tag.newBuilder().setContent(RegistryTags.VOTER_ENTRY_TAG.toString()).build());

View File

@ -20,7 +20,7 @@ public class VoterRegistryMessage {
/** /**
* Gets the wanted tag from given basic message * Gets the wanted tag from given basic message
* @param tagName * @param tagName the name of the tag
* @return string * @return string
*/ */
public String GetWantedTagFromBasicMessage(RegistryTags tagName){ public String GetWantedTagFromBasicMessage(RegistryTags tagName){
@ -51,7 +51,7 @@ public class VoterRegistryMessage {
/** /**
* Checks if the given message have the ADD_TO_GROUP_TAG * Checks if the given message have the ADD_TO_GROUP_TAG
* @return * @return true when ADD_TO_GROUP_TAG exist else false
*/ */
public boolean IsGroupAdding() { public boolean IsGroupAdding() {
for (ProtobufsMessages.Tag tag : base.getTagList()) { for (ProtobufsMessages.Tag tag : base.getTagList()) {