From 9dbaedbc8d243427248aac17802fdc653935b4e7 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Wed, 5 Feb 2020 22:20:04 +0100 Subject: [PATCH 1/4] Contacts events Created 2 events used for the contact list (add/remove) of the client and requesting a list of users form the server. --- .../java/envoy/event/ContactOperation.java | 50 +++++++++++++++++++ .../java/envoy/event/ContactsRequest.java | 32 ++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/main/java/envoy/event/ContactOperation.java create mode 100644 src/main/java/envoy/event/ContactsRequest.java diff --git a/src/main/java/envoy/event/ContactOperation.java b/src/main/java/envoy/event/ContactOperation.java new file mode 100644 index 0000000..1a5a108 --- /dev/null +++ b/src/main/java/envoy/event/ContactOperation.java @@ -0,0 +1,50 @@ +package envoy.event; + +import envoy.data.User; + +/** + * Project: envoy-common
+ * File: ContactOperation.java
+ * Created: 05.02.2020
+ * + * @author Maximilian Käfer + * @since Envoy Common v0.2-alpha + */ +public class ContactOperation implements Event { + + public enum Operation { + ADD, REMOVE; + } + + private final User contact; + private final Operation operationType; + + private static final long serialVersionUID = -1166652868189511553L; + + /** + * Initializes a {@link ContacsOperation}. + * + * @param operationType the {@link Operation} which should be executed on the + * {@link contact}. + * @since Envoy Common v0.2-alpha + */ + public ContactOperation(User contact, Operation operationType) { + this.contact = contact; + this.operationType = operationType; + } + + /** + * @return the {@link User}, which should be added/removed from the contacts + * list. + * @since Envoy Common v0.2-alpha + */ + @Override + public User get() { return contact; } + + /** + * @return the {@link Operation}, which should be executed with the contact, + * this event corresponds with. + * @since Envoy Common v0.2-alpha + */ + public Operation getOperationType() { return operationType; } +} diff --git a/src/main/java/envoy/event/ContactsRequest.java b/src/main/java/envoy/event/ContactsRequest.java new file mode 100644 index 0000000..04abcfd --- /dev/null +++ b/src/main/java/envoy/event/ContactsRequest.java @@ -0,0 +1,32 @@ +package envoy.event; + +/** + * Project: envoy-common
+ * File: ContactsRequest.java
+ * Created: 05.02.2020
+ * + * @author Maximilian Käfer + * @since Envoy Common v0.2-alpha + */ +public class ContactsRequest implements Event { + + private final String request; + + private static final long serialVersionUID = -7969312055630533627L; + + /** + * Initializes a {@link ContactsRequest}. + * + * @param request the string, which is entered by the client to request + * corresponding clients as contacts from the server. + * @since Envoy Common v0.2-alpha + */ + public ContactsRequest(String request) { this.request = request; } + + /** + * @return the request string + * @since Envoy Common v0.2-alpha + */ + @Override + public String get() { return request; } +} From efe5fd30ce84f98b7932707908569e48cf06a60e Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sat, 8 Feb 2020 13:44:05 +0100 Subject: [PATCH 2/4] Removed user id from Contacts --- src/main/java/envoy/data/Contacts.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/envoy/data/Contacts.java b/src/main/java/envoy/data/Contacts.java index bd19102..12846ac 100644 --- a/src/main/java/envoy/data/Contacts.java +++ b/src/main/java/envoy/data/Contacts.java @@ -13,7 +13,6 @@ import java.util.List; */ public class Contacts implements Serializable { - private final long userId; private final List contacts; private static final long serialVersionUID = 136970804968152871L; @@ -25,20 +24,13 @@ public class Contacts implements Serializable { * @param contacts the contact list * @since Envoy Common v0.2-alpha */ - public Contacts(long userId, List contacts) { - this.userId = userId; + public Contacts(List contacts) { this.contacts = contacts; } @Override public String toString() { return String.format("Contacts[%s]", contacts); } - /** - * @return the ID of the user this contacts belong to - * @since Envoy Common v0.2-alpha - */ - public long getUserId() { return userId; } - /** * @return a list of users messages can be sent to * @since Envoy Common v0.2-alpha From 06b8594f427674fd3e0229941c5019c2018acec8 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Sun, 9 Feb 2020 23:58:09 +0100 Subject: [PATCH 3/4] Adjusted ContactsRequest --- src/main/java/envoy/event/ContactsRequest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/envoy/event/ContactsRequest.java b/src/main/java/envoy/event/ContactsRequest.java index 04abcfd..00d593d 100644 --- a/src/main/java/envoy/event/ContactsRequest.java +++ b/src/main/java/envoy/event/ContactsRequest.java @@ -1,5 +1,7 @@ package envoy.event; +import envoy.data.User; + /** * Project: envoy-common
* File: ContactsRequest.java
@@ -11,6 +13,7 @@ package envoy.event; public class ContactsRequest implements Event { private final String request; + private final User client; private static final long serialVersionUID = -7969312055630533627L; @@ -21,7 +24,10 @@ public class ContactsRequest implements Event { * corresponding clients as contacts from the server. * @since Envoy Common v0.2-alpha */ - public ContactsRequest(String request) { this.request = request; } + public ContactsRequest(String request, User client) { + this.request = request; + this.client = client; + } /** * @return the request string @@ -29,4 +35,9 @@ public class ContactsRequest implements Event { */ @Override public String get() { return request; } + + /** + * @return returns the client, which sent this request + */ + public User getClient() { return client; } } From 4edfc781393ae0d90e0f4190d0eaf23792e228c8 Mon Sep 17 00:00:00 2001 From: kske Date: Mon, 10 Feb 2020 21:44:20 +0100 Subject: [PATCH 4/4] Small refactoring --- src/main/java/envoy/data/Contacts.java | 9 +-- .../java/envoy/event/ContactOperation.java | 50 -------------- .../envoy/event/ContactOperationEvent.java | 69 +++++++++++++++++++ .../envoy/event/ContactSearchRequest.java | 33 +++++++++ .../java/envoy/event/ContactsRequest.java | 43 ------------ 5 files changed, 105 insertions(+), 99 deletions(-) delete mode 100644 src/main/java/envoy/event/ContactOperation.java create mode 100644 src/main/java/envoy/event/ContactOperationEvent.java create mode 100644 src/main/java/envoy/event/ContactSearchRequest.java delete mode 100644 src/main/java/envoy/event/ContactsRequest.java diff --git a/src/main/java/envoy/data/Contacts.java b/src/main/java/envoy/data/Contacts.java index 12846ac..c86c1fc 100644 --- a/src/main/java/envoy/data/Contacts.java +++ b/src/main/java/envoy/data/Contacts.java @@ -7,26 +7,23 @@ import java.util.List; * Project: envoy-common
* File: Contacts.java
* Created: 02.01.2020
- * + * * @author Kai S. K. Engelbart * @since Envoy Common v0.2-alpha */ public class Contacts implements Serializable { - private final List contacts; + private final List contacts; private static final long serialVersionUID = 136970804968152871L; /** * Creates an instance of {@link Contacts}. * - * @param userId the ID of the user this contacts belong to * @param contacts the contact list * @since Envoy Common v0.2-alpha */ - public Contacts(List contacts) { - this.contacts = contacts; - } + public Contacts(List contacts) { this.contacts = contacts; } @Override public String toString() { return String.format("Contacts[%s]", contacts); } diff --git a/src/main/java/envoy/event/ContactOperation.java b/src/main/java/envoy/event/ContactOperation.java deleted file mode 100644 index 1a5a108..0000000 --- a/src/main/java/envoy/event/ContactOperation.java +++ /dev/null @@ -1,50 +0,0 @@ -package envoy.event; - -import envoy.data.User; - -/** - * Project: envoy-common
- * File: ContactOperation.java
- * Created: 05.02.2020
- * - * @author Maximilian Käfer - * @since Envoy Common v0.2-alpha - */ -public class ContactOperation implements Event { - - public enum Operation { - ADD, REMOVE; - } - - private final User contact; - private final Operation operationType; - - private static final long serialVersionUID = -1166652868189511553L; - - /** - * Initializes a {@link ContacsOperation}. - * - * @param operationType the {@link Operation} which should be executed on the - * {@link contact}. - * @since Envoy Common v0.2-alpha - */ - public ContactOperation(User contact, Operation operationType) { - this.contact = contact; - this.operationType = operationType; - } - - /** - * @return the {@link User}, which should be added/removed from the contacts - * list. - * @since Envoy Common v0.2-alpha - */ - @Override - public User get() { return contact; } - - /** - * @return the {@link Operation}, which should be executed with the contact, - * this event corresponds with. - * @since Envoy Common v0.2-alpha - */ - public Operation getOperationType() { return operationType; } -} diff --git a/src/main/java/envoy/event/ContactOperationEvent.java b/src/main/java/envoy/event/ContactOperationEvent.java new file mode 100644 index 0000000..643e04b --- /dev/null +++ b/src/main/java/envoy/event/ContactOperationEvent.java @@ -0,0 +1,69 @@ +package envoy.event; + +import envoy.data.User; + +/** + * Signifies the modification of a contact list.
+ *
+ * Project: envoy-common
+ * File: ContactOperationEvent.java
+ * Created: 05.02.2020
+ * + * @author Maximilian Käfer + * @since Envoy Common v0.2-alpha + */ +public class ContactOperationEvent implements Event { + + /** + * Specifies the operation performed on a contact list.
+ *
+ * Project: envoy-common
+ * File: ContactOperationEvent.java
+ * Created: 05.02.2020
+ * + * @author Maximilian Käfer + * @since Envoy Common v0.2-alpha + */ + public enum Operation { + + /** + * Adds a user to the contact list. + */ + ADD, + + /** + * Removes a user from the contact list. + */ + REMOVE; + } + + private final User contact; + private final Operation operationType; + + private static final long serialVersionUID = -1166652868189511553L; + + /** + * Initializes a {@link ContactOperationEvent}. + * + * @param contact the user on which the operation is performed + * @param operationType the type of operation to perform + * @since Envoy Common v0.2-alpha + */ + public ContactOperationEvent(User contact, Operation operationType) { + this.contact = contact; + this.operationType = operationType; + } + + /** + * @return the user to perform an operation on + * @since Envoy Common v0.2-alpha + */ + @Override + public User get() { return contact; } + + /** + * @return the type of operation to perform + * @since Envoy Common v0.2-alpha + */ + public Operation getOperationType() { return operationType; } +} diff --git a/src/main/java/envoy/event/ContactSearchRequest.java b/src/main/java/envoy/event/ContactSearchRequest.java new file mode 100644 index 0000000..701c1dc --- /dev/null +++ b/src/main/java/envoy/event/ContactSearchRequest.java @@ -0,0 +1,33 @@ +package envoy.event; + +/** + * Requests a contact search from the server.
+ *
+ * Project: envoy-common
+ * File: ContactSearchRequest.java
+ * Created: 05.02.2020
+ * + * @author Maximilian Käfer + * @since Envoy Common v0.2-alpha + */ +public class ContactSearchRequest implements Event { + + private final String searchPhrase; + + private static final long serialVersionUID = -7969312055630533627L; + + /** + * Initializes a {@link ContactSearchRequest}. + * + * @param searchPhrase the search phrase to use in the contact search + * @since Envoy Common v0.2-alpha + */ + public ContactSearchRequest(String searchPhrase) { this.searchPhrase = searchPhrase; } + + /** + * @return the search phrase + * @since Envoy Common v0.2-alpha + */ + @Override + public String get() { return searchPhrase; } +} diff --git a/src/main/java/envoy/event/ContactsRequest.java b/src/main/java/envoy/event/ContactsRequest.java deleted file mode 100644 index 00d593d..0000000 --- a/src/main/java/envoy/event/ContactsRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -package envoy.event; - -import envoy.data.User; - -/** - * Project: envoy-common
- * File: ContactsRequest.java
- * Created: 05.02.2020
- * - * @author Maximilian Käfer - * @since Envoy Common v0.2-alpha - */ -public class ContactsRequest implements Event { - - private final String request; - private final User client; - - private static final long serialVersionUID = -7969312055630533627L; - - /** - * Initializes a {@link ContactsRequest}. - * - * @param request the string, which is entered by the client to request - * corresponding clients as contacts from the server. - * @since Envoy Common v0.2-alpha - */ - public ContactsRequest(String request, User client) { - this.request = request; - this.client = client; - } - - /** - * @return the request string - * @since Envoy Common v0.2-alpha - */ - @Override - public String get() { return request; } - - /** - * @return returns the client, which sent this request - */ - public User getClient() { return client; } -}