Merge pull request #10 from informatik-ag-ngl/f/contacts
Contact-handling related Events
This commit is contained in:
commit
15b5289267
@ -7,38 +7,27 @@ import java.util.List;
|
|||||||
* Project: <strong>envoy-common</strong><br>
|
* Project: <strong>envoy-common</strong><br>
|
||||||
* File: <strong>Contacts.java</strong><br>
|
* File: <strong>Contacts.java</strong><br>
|
||||||
* Created: <strong>02.01.2020</strong><br>
|
* Created: <strong>02.01.2020</strong><br>
|
||||||
*
|
*
|
||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public class Contacts implements Serializable {
|
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;
|
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(long userId, List<User> contacts) {
|
public Contacts(List<User> contacts) { this.contacts = contacts; }
|
||||||
this.userId = userId;
|
|
||||||
this.contacts = contacts;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return String.format("Contacts[%s]", contacts); }
|
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
|
* @return a list of users messages can be sent to
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
|
69
src/main/java/envoy/event/ContactOperationEvent.java
Normal file
69
src/main/java/envoy/event/ContactOperationEvent.java
Normal 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ä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ä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; }
|
||||||
|
}
|
33
src/main/java/envoy/event/ContactSearchRequest.java
Normal file
33
src/main/java/envoy/event/ContactSearchRequest.java
Normal 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ä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; }
|
||||||
|
}
|
Reference in New Issue
Block a user