From 4013c685841c1de5976e7fa63c4aab294e8619ff Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 3 Feb 2015 18:58:17 +0100 Subject: [PATCH] Use Objects.requireNonNull() in Presence Also make Objects.requireNonNull() throw NullPointerException to match the original API behavior. --- .../main/java/org/jivesoftware/smack/packet/Presence.java | 6 ++---- .../src/main/java/org/jivesoftware/smack/util/Objects.java | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java index 7fa39edeb..5af896579 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java @@ -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"); } /** diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java b/smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java index fa5bd6561..0ee27afcb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java @@ -20,7 +20,7 @@ public class Objects { public static T requireNonNull(T obj, String message) { if (obj == null) { - throw new IllegalArgumentException(message); + throw new NullPointerException(message); } return obj; }