2020-03-25 16:33:06 +01:00
|
|
|
package envoy.event;
|
|
|
|
|
|
|
|
import envoy.data.Contact;
|
|
|
|
|
|
|
|
/**
|
2020-09-25 14:29:23 +02:00
|
|
|
* This event informs
|
|
|
|
* <p>
|
2020-10-19 18:17:51 +02:00
|
|
|
* a) the server of the name change of a user or a group. b) another user of this users name change.
|
2020-03-25 16:33:06 +01:00
|
|
|
*
|
|
|
|
* @author Leon Hofmeister
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
2020-08-22 13:37:07 +02:00
|
|
|
public final class NameChange extends Event<String> {
|
2020-03-25 16:33:06 +01:00
|
|
|
|
2020-03-26 12:45:10 +01:00
|
|
|
private final long id;
|
|
|
|
|
2020-10-19 18:17:51 +02:00
|
|
|
private static final long serialVersionUID = 0L;
|
2020-03-25 16:33:06 +01:00
|
|
|
|
|
|
|
/**
|
2020-06-20 09:19:39 +02:00
|
|
|
* Creates a new {@link NameChange} for a user or a group.
|
2020-03-25 16:33:06 +01:00
|
|
|
*
|
|
|
|
* @param contactID the id of the {@link Contact} who wishes to change his name
|
|
|
|
* @param newName the new name of this contact
|
|
|
|
* @since Envoy Common v0.1-beta
|
|
|
|
*/
|
2020-06-20 09:19:39 +02:00
|
|
|
public NameChange(long contactID, String newName) {
|
2020-03-25 16:33:06 +01:00
|
|
|
super(newName);
|
|
|
|
id = contactID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-10-19 18:17:51 +02:00
|
|
|
* Initializes a {@link NameChange} through a Contact where the name has already been set.
|
2020-03-25 16:33:06 +01:00
|
|
|
*
|
|
|
|
* @param contact the contact whose name was updated
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-10-19 18:17:51 +02:00
|
|
|
public NameChange(Contact contact) {
|
|
|
|
this(contact.getID(), contact.getName());
|
|
|
|
}
|
2020-03-25 16:33:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the ID of the {@link Contact} this event is related to
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-04-01 18:15:41 +02:00
|
|
|
public long getID() { return id; }
|
2020-03-25 16:33:06 +01:00
|
|
|
|
|
|
|
@Override
|
2020-10-19 18:17:51 +02:00
|
|
|
public String toString() {
|
|
|
|
return String.format("NameChange[id=%d,name=%s]", id, value);
|
|
|
|
}
|
2020-03-25 16:33:06 +01:00
|
|
|
}
|