This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/common/src/main/java/envoy/event/NameChange.java

52 lines
1.2 KiB
Java

package envoy.event;
import envoy.data.Contact;
/**
* This event informs
* <p>
* a) the server of the name change of a user or a group. b) another user of this users name change.
*
* @author Leon Hofmeister
* @since Envoy Common v0.1-beta
*/
public final class NameChange extends Event<String> {
private final long id;
private static final long serialVersionUID = 0L;
/**
* Creates a new {@link NameChange} for a user or a group.
*
* @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
*/
public NameChange(long contactID, String newName) {
super(newName);
id = contactID;
}
/**
* Initializes a {@link NameChange} through a Contact where the name has already been set.
*
* @param contact the contact whose name was updated
* @since Envoy Common v0.2-alpha
*/
public NameChange(Contact contact) {
this(contact.getID(), contact.getName());
}
/**
* @return the ID of the {@link Contact} this event is related to
* @since Envoy Common v0.2-alpha
*/
public long getID() { return id; }
@Override
public String toString() {
return String.format("NameChange[id=%d,name=%s]", id, value);
}
}