mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 07:22:07 +01:00
Use Objects.requireNonNull() in Presence
Also make Objects.requireNonNull() throw NullPointerException to match the original API behavior.
This commit is contained in:
parent
34ce7929a8
commit
4013c68584
2 changed files with 3 additions and 5 deletions
|
@ -19,6 +19,7 @@ package org.jivesoftware.smack.packet;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.Objects;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,10 +132,7 @@ public final class Presence extends Packet {
|
||||||
* @param type the type of the presence packet.
|
* @param type the type of the presence packet.
|
||||||
*/
|
*/
|
||||||
public void setType(Type type) {
|
public void setType(Type type) {
|
||||||
if(type == null) {
|
this.type = Objects.requireNonNull(type, "Type cannot be null");
|
||||||
throw new NullPointerException("Type cannot be null");
|
|
||||||
}
|
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class Objects {
|
||||||
|
|
||||||
public static <T> T requireNonNull(T obj, String message) {
|
public static <T> T requireNonNull(T obj, String message) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
throw new IllegalArgumentException(message);
|
throw new NullPointerException(message);
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue