From d497553fcaa461f1ba1db692295055a14cb84925 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Mon, 10 Feb 2020 21:44:20 +0100 Subject: [PATCH] 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; } -}