Merge pull request #10 from informatik-ag-ngl/f/contacts

Contact-handling related Events
This commit is contained in:
DieGurke 2020-02-10 21:46:27 +01:00 committed by GitHub
commit 15b5289267
3 changed files with 105 additions and 14 deletions

View File

@ -13,32 +13,21 @@ import java.util.List;
*/
public class Contacts implements Serializable {
private final long userId;
private final List<User> contacts;
private final List<User> 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(long userId, List<User> contacts) {
this.userId = userId;
this.contacts = contacts;
}
public Contacts(List<User> 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

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