Small refactoring

This commit is contained in:
Kai S. K. Engelbart 2020-02-10 21:44:20 +01:00
parent a767f10ac9
commit d497553fca
5 changed files with 105 additions and 99 deletions

View File

@ -13,20 +13,17 @@ import java.util.List;
*/ */
public class Contacts implements Serializable { public class Contacts implements Serializable {
private final List<User> contacts; private final List<User> contacts;
private static final long serialVersionUID = 136970804968152871L; private static final long serialVersionUID = 136970804968152871L;
/** /**
* Creates an instance of {@link Contacts}. * Creates an instance of {@link Contacts}.
* *
* @param userId the ID of the user this contacts belong to
* @param contacts the contact list * @param contacts the contact list
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public Contacts(List<User> contacts) { public Contacts(List<User> contacts) { this.contacts = contacts; }
this.contacts = contacts;
}
@Override @Override
public String toString() { return String.format("Contacts[%s]", contacts); } public String toString() { return String.format("Contacts[%s]", contacts); }

View File

@ -1,50 +0,0 @@
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,69 @@
package envoy.event;
import envoy.data.User;
/**
* Signifies the modification of a contact list.<br>
* <br>
* Project: <strong>envoy-common</strong><br>
* File: <strong>ContactOperationEvent.java</strong><br>
* Created: <strong>05.02.2020</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy Common v0.2-alpha
*/
public class ContactOperationEvent implements Event<User> {
/**
* Specifies the operation performed on a contact list.<br>
* <br>
* Project: <strong>envoy-common</strong><br>
* File: <strong>ContactOperationEvent.java</strong><br>
* Created: <strong>05.02.2020</strong><br>
*
* @author Maximilian K&auml;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; }
}

View File

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

View File

@ -1,43 +0,0 @@
package envoy.event;
import envoy.data.User;
/**
* 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 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; }
}