1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-23 04:22:05 +01:00

Make Nick immutable

This commit is contained in:
Florian Schmaus 2018-10-21 09:01:54 +02:00
parent 2f1f0b6c1a
commit 382057f520

View file

@ -20,6 +20,7 @@ import java.io.IOException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder; import org.jivesoftware.smack.util.XmlStringBuilder;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -37,10 +38,10 @@ public class Nick implements ExtensionElement {
public static final String ELEMENT_NAME = "nick"; public static final String ELEMENT_NAME = "nick";
private String name = null; private final String name;
public Nick(String name) { public Nick(String name) {
this.name = name; this.name = StringUtils.requireNotNullNorEmpty(name, "Nickname must be given");
} }
/** /**
@ -52,16 +53,6 @@ public class Nick implements ExtensionElement {
return name; return name;
} }
/**
* Sets the value of this nickname.
*
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
@Override @Override
public String getElementName() { public String getElementName() {
return ELEMENT_NAME; return ELEMENT_NAME;