Example usage for org.apache.commons.lang3 Validate notBlank

List of usage examples for org.apache.commons.lang3 Validate notBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 Validate notBlank.

Prototype

public static <T extends CharSequence> T notBlank(final T chars) 

Source Link

Document

Validate that the specified argument character sequence is neither null , a length of zero (no characters), empty nor whitespace; otherwise throwing an exception.

Usage

From source file:com.github.aynu.mosir.core.standard.util.MessageHelper.java

/**
 * //  ww  w.  j av a2s  .com
 * @param message 
 * @param values 
 * @return 
 */
public static String createMessage(final String message, final Object... values) {
    Validate.notBlank(message);
    return MessageFormat.format(message, values);
}

From source file:ca.travelagency.persistence.query.OrderBy.java

public static OrderBy make(String property, boolean ascending) {
    Validate.notBlank(property);
    OrderBy result = new OrderBy();
    result.property = property;/*from   w  w  w  .ja v a  2  s  .c o  m*/
    result.ascending = ascending;
    return result;
}

From source file:co.runrightfast.commons.utils.ValidationUtils.java

static void notBlank(final String val) {
    Validate.notBlank(val);
}

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static String toDateString(Date date, String pattern) {
    Validate.notBlank(pattern);
    return date == null ? null : new SimpleDateFormat(pattern).format(date);
}

From source file:com.github.aynu.mosir.core.standard.util.MessageHelper.java

/**
 * //from  ww w  .  j  ava  2s . co m
 * @param key 
 * @param values 
 * @return 
 */
public static String templateMessage(final String key, final Object... values) {
    Validate.notBlank(key);
    return createMessage(DEF.getText(key), values);
}

From source file:cz.afrosoft.whattoeat.core.gui.I18n.java

/**
 * Get localized text for specified key.
 * @param key (NotBlank) Key of text./*from w  w w . ja  va2s  . c  o  m*/
 * @return (NotNull) Localized text.
 * @throws java.util.MissingResourceException If key is not found in loaded resource bundle.
 */
public static String getText(final String key) {
    Validate.notBlank(key);
    return resourceBundle.getString(key);
}

From source file:de.vandermeer.skb.interfaces.render.HasText.java

/**
 * Creates a new simple text object./*from   w ww.ja va2 s  .  c  o m*/
 * @param text input text, cannot be blank
 * @return new simple text object
 * @throws NullPointerException if `text` was null
 * @throws IllegalArgumentException if `text` was blank
 */
static HasText create(final String text) {
    Validate.notBlank(text);
    return new HasText() {
        @Override
        public String getText() {
            return text;
        }
    };
}

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static Date fromDateString(String s, String pattern) {
    Validate.notBlank(pattern);
    try {/* w  w w  . j a  v a 2  s .  co  m*/
        return isBlank(s) ? null : new SimpleDateFormat(pattern).parse(s);
    } catch (ParseException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:de.vandermeer.skb.interfaces.FormattingTupleWrapper.java

/**
 * Creates a new wrapper.//from w w  w .  jav a2  s.  c  o  m
 * @param msg the message for the wrapper, should not be blank
 * @return new wrapper with given message
 * @throws NullPointerException if `msg` was null
 * @throws IllegalArgumentException if `msg` was blank
 */
static FormattingTupleWrapper create(final String msg) {
    Validate.notBlank(msg);

    return new FormattingTupleWrapper() {
        @Override
        public FormattingTuple getTuple() {
            return MessageFormatter.arrayFormat(msg, new Object[0]);
        }
    };
}

From source file:cz.afrosoft.whattoeat.core.gui.I18n.java

/**
 * Get localized text for specified key and fill specified parameters to it.
 *
 * @param key    (NotBlank) Key of text.
 * @param params (NotNull) Parameters to fill into message.
 * @return (NotNull) Localized text with filled parameters.
 * @throws java.util.MissingResourceException If key is not found in loaded resource bundle.
 * @see MessageFormat#format(String, Object...).
 *//*  w  w  w.  j  a  v a  2  s  . com*/
public static String getText(final String key, final Object... params) {
    Validate.notBlank(key);
    Validate.notNull(params);

    return MessageFormat.format(getText(key), params);
}