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] 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; } +}