Contacts events

Created 2 events used for the contact list (add/remove) of the client
and requesting a list of users form the server.
This commit is contained in:
DieGurke 2020-02-05 22:20:04 +01:00
parent 3069b8cf50
commit 9dbaedbc8d
2 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,50 @@
package envoy.event;
import envoy.data.User;
/**
* Project: <strong>envoy-common</strong><br>
* File: <strong>ContactOperation.java</strong><br>
* Created: <strong>05.02.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Common v0.2-alpha
*/
public class ContactOperation implements Event<User> {
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; }
}

View File

@ -0,0 +1,32 @@
package envoy.event;
/**
* Project: <strong>envoy-common</strong><br>
* File: <strong>ContactsRequest.java</strong><br>
* Created: <strong>05.02.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Common v0.2-alpha
*/
public class ContactsRequest implements Event<String> {
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; }
}