1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 02:39:42 +02:00

requireNotNullOrEmpty -> requireNotNullNorEmpty

This commit is contained in:
Paul Schaub 2018-07-17 15:10:39 +02:00
parent cf2b3ef634
commit 74bebc13e6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
32 changed files with 82 additions and 52 deletions

View file

@ -497,7 +497,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
public synchronized void login(CharSequence username, String password, Resourcepart resource) throws XMPPException,
SmackException, IOException, InterruptedException {
if (!config.allowNullOrEmptyUsername) {
StringUtils.requireNotNullOrEmpty(username, "Username must not be null or empty");
StringUtils.requireNotNullNorEmpty(username, "Username must not be null nor empty");
}
throwNotConnectedExceptionIfAppropriate("Did you call connect() before login()?");
throwAlreadyLoggedInExceptionIfAppropriate();

View file

@ -894,8 +894,8 @@ public abstract class ConnectionConfiguration {
* @return a reference to this builder.
*/
public B addEnabledSaslMechanism(String saslMechanism) {
return addEnabledSaslMechanism(Arrays.asList(StringUtils.requireNotNullOrEmpty(saslMechanism,
"saslMechanism must not be null or empty")));
return addEnabledSaslMechanism(Arrays.asList(StringUtils.requireNotNullNorEmpty(saslMechanism,
"saslMechanism must not be null nor empty")));
}
/**

View file

@ -42,7 +42,7 @@ public class PacketExtensionFilter implements StanzaFilter {
* @param namespace the XML namespace of the stanza extension.
*/
public PacketExtensionFilter(String elementName, String namespace) {
StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
StringUtils.requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
this.elementName = elementName;
this.namespace = namespace;

View file

@ -50,7 +50,7 @@ public class PacketIDFilter implements StanzaFilter {
*/
@Deprecated
public PacketIDFilter(String packetID) {
StringUtils.requireNotNullOrEmpty(packetID, "Packet ID must not be null or empty.");
StringUtils.requireNotNullNorEmpty(packetID, "Packet ID must not be null nor empty.");
this.packetID = packetID;
}

View file

@ -40,7 +40,7 @@ public class StanzaExtensionFilter implements StanzaFilter {
* @param namespace the XML namespace of the stanza extension.
*/
public StanzaExtensionFilter(String elementName, String namespace) {
StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
StringUtils.requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
this.elementName = elementName;
this.namespace = namespace;

View file

@ -44,7 +44,7 @@ public class StanzaIdFilter implements StanzaFilter {
* @param stanzaID the stanza ID to filter for.
*/
public StanzaIdFilter(String stanzaID) {
this.stanzaId = StringUtils.requireNotNullOrEmpty(stanzaID, "Stanza ID must not be null or empty.");
this.stanzaId = StringUtils.requireNotNullNorEmpty(stanzaID, "Stanza ID must not be null nor empty.");
}
@Override

View file

@ -35,7 +35,7 @@ public class ThreadFilter extends FlexibleStanzaTypeFilter<Message> implements S
* @param thread the thread value to filter for.
*/
public ThreadFilter(String thread) {
StringUtils.requireNotNullOrEmpty(thread, "Thread must not be null or empty.");
StringUtils.requireNotNullNorEmpty(thread, "Thread must not be null nor empty.");
this.thread = thread;
}

View file

@ -27,7 +27,7 @@ public abstract class AbstractTextElement implements ExtensionElement {
private final String lang;
protected AbstractTextElement(String text, String lang) {
this.text = StringUtils.requireNotNullOrEmpty(text, "Text must not be null or empty");
this.text = StringUtils.requireNotNullNorEmpty(text, "Text must not be null nor empty");
this.lang = lang;
}

View file

@ -66,8 +66,8 @@ public final class StandardExtensionElement implements ExtensionElement {
private StandardExtensionElement(String name, String namespace, Map<String, String> attributes, String text,
MultiMap<String, StandardExtensionElement> elements) {
this.name = StringUtils.requireNotNullOrEmpty(name, "Name must not be null or empty");
this.namespace = StringUtils.requireNotNullOrEmpty(namespace, "Namespace must not be null or empty");
this.name = StringUtils.requireNotNullNorEmpty(name, "Name must not be null nor empty");
this.namespace = StringUtils.requireNotNullNorEmpty(namespace, "Namespace must not be null nor empty");
if (attributes == null) {
this.attributes = Collections.emptyMap();
}
@ -173,7 +173,7 @@ public final class StandardExtensionElement implements ExtensionElement {
}
public Builder addAttribute(String name, String value) {
StringUtils.requireNotNullOrEmpty(name, "Attribute name must be set");
StringUtils.requireNotNullNorEmpty(name, "Attribute name must be set");
Objects.requireNonNull(value, "Attribute value must be not null");
if (attributes == null) {
attributes = new LinkedHashMap<>();

View file

@ -17,7 +17,7 @@
package org.jivesoftware.smack.packet;
import static org.jivesoftware.smack.util.StringUtils.requireNotNullOrEmpty;
import static org.jivesoftware.smack.util.StringUtils.requireNotNullNorEmpty;
import java.util.Collection;
import java.util.List;
@ -122,7 +122,7 @@ public abstract class Stanza implements TopLevelStreamElement {
*/
public void setStanzaId(String id) {
if (id != null) {
requireNotNullOrEmpty(id, "id must either be null or not the empty String");
requireNotNullNorEmpty(id, "id must either be null or not the empty String");
}
this.id = id;
}
@ -324,8 +324,8 @@ public abstract class Stanza implements TopLevelStreamElement {
* @since 4.1
*/
public List<ExtensionElement> getExtensions(String elementName, String namespace) {
requireNotNullOrEmpty(elementName, "elementName must not be null or empty");
requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
requireNotNullNorEmpty(elementName, "elementName must not be null nor empty");
requireNotNullNorEmpty(namespace, "namespace must not be null nor empty");
String key = XmppStringUtils.generateKey(elementName, namespace);
return packetExtensions.getAll(key);
}

View file

@ -39,8 +39,8 @@ public class SaslStreamElements {
public AuthMechanism(String mechanism, String authenticationText) {
this.mechanism = Objects.requireNonNull(mechanism, "SASL mechanism shouldn't be null.");
this.authenticationText = StringUtils.requireNotNullOrEmpty(authenticationText,
"SASL authenticationText must not be null or empty (RFC6120 6.4.2)");
this.authenticationText = StringUtils.requireNotNullNorEmpty(authenticationText,
"SASL authenticationText must not be null nor empty (RFC6120 6.4.2)");
}
@Override

View file

@ -31,7 +31,15 @@ public class Objects {
return requireNonNull(obj, null);
}
public static <T extends Collection<?>> T requireNonNullOrEmpty(T collection, String message) {
/**
* Require a collection to be neither null, nor empty.
*
* @param collection collection
* @param message error message
* @param <T> Collection type
* @return collection
*/
public static <T extends Collection<?>> T requireNonNullNorEmpty(T collection, String message) {
if (requireNonNull(collection).isEmpty()) {
throw new IllegalArgumentException(message);
}

View file

@ -444,7 +444,29 @@ public class StringUtils {
return csOne.toString().compareTo(csTwo.toString());
}
/**
* Require a {@link CharSequence} to be neither null, nor empty.
*
* @deprecated use {@link #requireNotNullNorEmpty(CharSequence, String)} instead.
* @param cs CharSequence
* @param message error message
* @param <CS> CharSequence type
* @return cs
*/
@Deprecated
public static <CS extends CharSequence> CS requireNotNullOrEmpty(CS cs, String message) {
return requireNotNullNorEmpty(cs, message);
}
/**
* Require a {@link CharSequence} to be neither null, nor empty.
*
* @param cs CharSequence
* @param message error message
* @param <CS> CharSequence type
* @return cs
*/
public static <CS extends CharSequence> CS requireNotNullNorEmpty(CS cs, String message) {
if (isNullOrEmpty(cs)) {
throw new IllegalArgumentException(message);
}

View file

@ -372,7 +372,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
private final String xmlFragment;
private XmlNsAttribute(String value) {
this.value = StringUtils.requireNotNullOrEmpty(value, "Value must not be null");
this.value = StringUtils.requireNotNullNorEmpty(value, "Value must not be null");
this.xmlFragment = " xmlns='" + value + '\'';
}

View file

@ -48,7 +48,7 @@ public class SRVRecord extends HostAddress implements Comparable<SRVRecord> {
*/
public SRVRecord(DnsName fqdn, int port, int priority, int weight, List<InetAddress> inetAddresses) {
super(fqdn, port, inetAddresses);
StringUtils.requireNotNullOrEmpty(fqdn, "The FQDN must not be null");
StringUtils.requireNotNullNorEmpty(fqdn, "The FQDN must not be null");
if (weight < 0 || weight > 65535)
throw new IllegalArgumentException(
"DNS SRV records weight must be a 16-bit unsigned integer (i.e. between 0-65535. Weight was: "