Java Code Examples for org.jivesoftware.smack.util.StringUtils#requireNullOrNotEmpty()

The following examples show how to use org.jivesoftware.smack.util.StringUtils#requireNullOrNotEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageBuilder.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a subject with a corresponding language.
 *
 * @param language the language of the subject being added.
 * @param subject the subject being added to the message.
 * @return a reference to this builder.
 * @throws NullPointerException if the subject is null.
 */
public MessageBuilder addSubject(String language, String subject) {
    language = StringUtils.requireNullOrNotEmpty(language, "language must be null or not empty");

    for (Subject currentSubject : getExtensions(Subject.class)) {
        if (StringUtils.nullSafeCharSequenceEquals(language, currentSubject.getLanguage())) {
            throw new IllegalArgumentException("Subject with the language " + language + " already exists");
        }
    }

    Subject messageSubject = new Subject(language, subject);
    addExtension(messageSubject);

    return this;
}
 
Example 2
Source File: MessageBuilder.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a body with a corresponding language.
 *
 * @param language the language of the body being added.
 * @param body the body being added to the message.
 * @return a reference to this builder.
 */
public MessageBuilder addBody(String language, String body) {
    language = StringUtils.requireNullOrNotEmpty(language, "language must be null or not empty");

    for (Body currentBody : getExtensions(Body.class)) {
        if (StringUtils.nullSafeCharSequenceEquals(language, currentBody.getLanguage())) {
            throw new IllegalArgumentException("Bodyt with the language " + language + " already exists");
        }
    }

    Body messageBody = new Body(language, body);
    addExtension(messageBody);

    return this;
}
 
Example 3
Source File: Message.java    From Smack with Apache License 2.0 4 votes vote down vote up
public Thread(String thread, String parent) {
    this.thread = StringUtils.requireNotNullNorEmpty(thread, "thread must not be null nor empty");
    this.parent = StringUtils.requireNullOrNotEmpty(parent, "parent must be null or not empty");
}
 
Example 4
Source File: StanzaBuilder.java    From Smack with Apache License 2.0 4 votes vote down vote up
protected StanzaBuilder(String stanzaId) {
    this.stanzaIdSource = null;
    this.stanzaId = StringUtils.requireNullOrNotEmpty(stanzaId, "Stanza ID must not be the empty String");
}
 
Example 5
Source File: DiscoverInfo.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the node attribute that supplements the 'jid' attribute. A node is merely
 * something that is associated with a JID and for which the JID can provide information.<p>
 *
 * Node attributes SHOULD be used only when trying to provide or query information which
 * is not directly addressable.
 *
 * @param node the node attribute that supplements the 'jid' attribute
 * @deprecated use {@link DiscoverInfoBuilder#setNode(String)} instead.
 */
@Deprecated
// TODO: Remove in Smack 4.5.
public void setNode(String node) {
    this.node = StringUtils.requireNullOrNotEmpty(node, "The node can not be the empty string");
}