mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Add StringUtils.requireNotNullOrEmpty and Objects.requireNonNull
and use this in a few places.
This commit is contained in:
parent
603f64166b
commit
86ea027301
18 changed files with 88 additions and 100 deletions
|
@ -316,14 +316,8 @@ public class DiscoverInfo extends IQ implements Cloneable {
|
|||
* @param lang the entity's lang.
|
||||
*/
|
||||
public Identity(String category, String type, String name, String lang) {
|
||||
if (StringUtils.isNullOrEmpty(category)) {
|
||||
throw new IllegalArgumentException("category cannot be null");
|
||||
}
|
||||
if (StringUtils.isNullOrEmpty(type)) {
|
||||
throw new IllegalArgumentException("type cannot be null");
|
||||
}
|
||||
this.category = category;
|
||||
this.type = type;
|
||||
this.category = StringUtils.requireNotNullOrEmpty(category, "category cannot be null");
|
||||
this.type = StringUtils.requireNotNullOrEmpty(type, "type cannot be null");
|
||||
this.key = XmppStringUtils.generateKey(category, type);
|
||||
this.name = name;
|
||||
this.lang = lang;
|
||||
|
@ -493,9 +487,7 @@ public class DiscoverInfo extends IQ implements Cloneable {
|
|||
* @param variable the feature's variable.
|
||||
*/
|
||||
public Feature(String variable) {
|
||||
if (variable == null)
|
||||
throw new IllegalArgumentException("variable cannot be null");
|
||||
this.variable = variable;
|
||||
this.variable = StringUtils.requireNotNullOrEmpty(variable, "variable cannot be null");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jivesoftware.smackx.iqversion.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A Version IQ packet, which is used by XMPP clients to discover version information
|
||||
|
@ -85,16 +86,9 @@ public class Version extends IQ {
|
|||
*/
|
||||
public Version(String name, String version, String os) {
|
||||
super(ELEMENT, NAMESPACE);
|
||||
if (name == null)
|
||||
{
|
||||
throw new IllegalArgumentException("name must not be null");
|
||||
}
|
||||
if (version == null) {
|
||||
throw new IllegalArgumentException("version must not be null");
|
||||
}
|
||||
this.setType(IQ.Type.result);
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.name = StringUtils.requireNotNullOrEmpty(name, "name must not be null");
|
||||
this.version = StringUtils.requireNotNullOrEmpty(version, "version must not be null");
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,9 +274,7 @@ public class MultiUserChat {
|
|||
private Presence enter(String nickname, String password, DiscussionHistory history,
|
||||
long timeout) throws NotConnectedException, NoResponseException,
|
||||
XMPPErrorException {
|
||||
if (StringUtils.isNullOrEmpty(nickname)) {
|
||||
throw new IllegalArgumentException("Nickname must not be null or blank.");
|
||||
}
|
||||
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
|
||||
// We enter a room by sending a presence packet where the "to"
|
||||
// field is in the form "roomName@service/nickname"
|
||||
Presence joinPresence = new Presence(Presence.Type.available);
|
||||
|
@ -844,9 +842,7 @@ public class MultiUserChat {
|
|||
* @throws NotConnectedException
|
||||
*/
|
||||
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||
if (StringUtils.isNullOrEmpty(nickname)) {
|
||||
throw new IllegalArgumentException("Nickname must not be null or blank.");
|
||||
}
|
||||
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
|
||||
// Check that we already have joined the room before attempting to change the
|
||||
// nickname.
|
||||
if (!joined) {
|
||||
|
@ -881,9 +877,7 @@ public class MultiUserChat {
|
|||
* @throws NotConnectedException
|
||||
*/
|
||||
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws NotConnectedException {
|
||||
if (StringUtils.isNullOrEmpty(nickname)) {
|
||||
throw new IllegalArgumentException("Nickname must not be null or blank.");
|
||||
}
|
||||
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
|
||||
// Check that we already have joined the room before attempting to change the
|
||||
// availability status.
|
||||
if (!joined) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue