Use Objects.requireNonNull() in Presence

Also make Objects.requireNonNull() throw NullPointerException to match
the original API behavior.
This commit is contained in:
Florian Schmaus 2015-02-03 18:58:17 +01:00
parent 34ce7929a8
commit 4013c68584
2 changed files with 3 additions and 5 deletions

View File

@ -19,6 +19,7 @@ package org.jivesoftware.smack.packet;
import java.util.Locale;
import org.jivesoftware.smack.util.Objects;
import org.jivesoftware.smack.util.XmlStringBuilder;
/**
@ -131,10 +132,7 @@ public final class Presence extends Packet {
* @param type the type of the presence packet.
*/
public void setType(Type type) {
if(type == null) {
throw new NullPointerException("Type cannot be null");
}
this.type = type;
this.type = Objects.requireNonNull(type, "Type cannot be null");
}
/**

View File

@ -20,7 +20,7 @@ public class Objects {
public static <T> T requireNonNull(T obj, String message) {
if (obj == null) {
throw new IllegalArgumentException(message);
throw new NullPointerException(message);
}
return obj;
}