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

53 lines
1.4 KiB
Java
Raw Normal View History

package envoy.event;
import envoy.data.Contact;
/**
* This event informs<br>
* a) the server of the name change of a user or a group.
* b) another user of this users name change.
*
* Project: <strong>envoy-common</strong><br>
2020-06-20 09:19:39 +02:00
* File: <strong>NameChange.java</strong><br>
* Created: <strong>25 Mar 2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Common v0.1-beta
*/
2020-06-20 09:19:39 +02:00
public class NameChange extends Event<String> {
2020-03-26 12:45:10 +01:00
private final long id;
private static final long serialVersionUID = 0L;
/**
2020-06-20 09:19:39 +02:00
* 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
*/
2020-06-20 09:19:39 +02:00
public NameChange(long contactID, String newName) {
super(newName);
id = contactID;
}
/**
2020-06-20 09:19:39 +02:00
* 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
*/
2020-06-20 09:19:39 +02:00
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
2020-06-20 09:19:39 +02:00
public String toString() { return String.format("NameChange[id=%d,name=%s]", id, value); }
}