Example usage for org.apache.commons.lang3 StringUtils isNotBlank

List of usage examples for org.apache.commons.lang3 StringUtils isNotBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNotBlank.

Prototype

public static boolean isNotBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty (""), not null and not whitespace only.

 StringUtils.isNotBlank(null)      = false StringUtils.isNotBlank("")        = false StringUtils.isNotBlank(" ")       = false StringUtils.isNotBlank("bob")     = true StringUtils.isNotBlank("  bob  ") = true 

Usage

From source file:com.aistor.modules.sys.utils.DictUtils.java

public static String getDictValue(String label, String type, String defaultLabel) {
    if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(label)) {
        for (Dict dict : getDictList(type)) {
            if (type.equals(dict.getType()) && label.equals(dict.getLabel())) {
                return dict.getValue();
            }//from w  w w  . j a  v  a  2s  .  c  o  m
        }
    }
    return defaultLabel;
}

From source file:com.qatickets.common.StringHelper.java

public static String leaveOnlyLettersAndDigits(String value) {
    StringBuilder sb = new StringBuilder();
    if (StringUtils.isNotBlank(value)) {
        char[] chars = value.toCharArray();
        for (char ch : chars) {
            if (Character.isLetterOrDigit(ch)) {
                sb.append(ch);/*from  w w w .  j  a va 2  s  .c o m*/
            }
        }
    }
    return sb.toString();
}

From source file:com.synopsys.integration.blackduck.service.model.BlackDuckQuery.java

public static Optional<BlackDuckQuery> createQuery(final String prefix, final String parameter) {
    if (StringUtils.isNotBlank(parameter)) {
        return Optional.of(new BlackDuckQuery(prefix + ":" + parameter));
    }//from w w  w  .ja  va2 s .c o  m

    return Optional.empty();
}

From source file:aiai.ai.station.StationResourceUtils.java

public static AssetFile prepareResourceFile(File rootDir, Enums.BinaryDataType binaryDataType, String id,
        String resourceFilename) {

    final AssetFile assetFile = new AssetFile();
    final File trgDir = new File(rootDir, binaryDataType.toString());
    if (!trgDir.exists() && !trgDir.mkdirs()) {
        assetFile.isError = true;//from w  w  w .  jav  a  2 s  .co  m
        log.error("Can't create resource dir for task: {}", trgDir.getAbsolutePath());
        return assetFile;
    }
    if (StringUtils.isNotBlank(resourceFilename)) {
        assetFile.file = new File(trgDir, resourceFilename);
    } else {
        final String resId = id.replace(':', '_');
        assetFile.file = new File(trgDir, "" + resId);
    }
    assetFile.isExist = assetFile.file.exists();

    if (assetFile.isExist) {
        if (assetFile.file.length() == 0) {
            assetFile.file.delete();
            assetFile.isExist = false;
        } else {
            assetFile.isContent = true;
        }
    }
    return assetFile;
}

From source file:com.synopsys.integration.log.LogLevel.java

public static LogLevel fromString(final String level) {
    if (StringUtils.isNotBlank(level)) {
        try {//  w  w w . j a v  a  2  s  . c  o  m
            return LogLevel.valueOf(level.toUpperCase());
        } catch (final IllegalArgumentException e) {
        }
    }
    return LogLevel.INFO;
}

From source file:jease.cms.service.Timers.java

public static void start() {
    stop();/*ww  w.  j ava 2  s.c  o m*/
    timer = new Timer();
    timer.schedule(new TimerTask() {
        public void run() {
            try {
                String newTimerTaskClass = Registry.getParameter(Names.JEASE_TIMER_TASK);
                if (StringUtils.isNotBlank(newTimerTaskClass)) {
                    if (!StringUtils.equals(timerTaskClass, newTimerTaskClass)) {
                        timerTaskClass = newTimerTaskClass;
                        runnable = (Runnable) Reflections.newInstance(timerTaskClass);
                    }
                    if (runnable != null) {
                        runnable.run();
                    }
                }
            } catch (Throwable e) {
                timerTaskClass = null;
                runnable = null;
            }
        }
    }, 1000, 1000);
}

From source file:models.service.reminder.RemindSender.java

public static void remind(Item item, Option option, User oldUser, User newUser, Map<String, Object> params) {
    String template = getTemplate(item, option);
    String content = parseTemplate(template, oldUser, newUser, params);

    switch (option) {
    case BY_EMAIL:
        if (StringUtils.isNotBlank(oldUser.email)) {
            sendEmail(item, oldUser.email, content);
        }//  www .  j ava 2  s .co  m
        break;

    case BY_SMS:
        if (StringUtils.isNotBlank(oldUser.phoneNumber)) {
            sendSms(oldUser.phoneNumber, content);
        }
        break;

    case BY_MSG:
        sendMsg(newUser, content);
        break;
    }
}

From source file:com.omertron.themoviedbapi.enumeration.ArtworkType.java

/**
 * Convert a string into an Enum type/*from w w w  .  jav  a2 s  . c  o  m*/
 *
 * @param artworkType
 * @return
 * @throws IllegalArgumentException If type is not recognised
 *
 */
public static ArtworkType fromString(String artworkType) {
    if (StringUtils.isNotBlank(artworkType)) {
        try {
            return ArtworkType.valueOf(artworkType.trim().toUpperCase());
        } catch (IllegalArgumentException ex) {
            throw new IllegalArgumentException("ArtworkType " + artworkType + " does not exist.", ex);
        }
    }
    throw new IllegalArgumentException("ArtworkType must not be null");
}

From source file:com.moviejukebox.model.enumerations.VideoType.java

/**
 * Convert a string into an Enum type//from ww  w  .j av  a  2 s .c  om
 *
 * @param sType
 * @return
 */
public static VideoType fromString(String sType) {
    if (StringUtils.isNotBlank(sType)) {
        for (final VideoType extension : EnumSet.allOf(VideoType.class)) {
            if (sType.equalsIgnoreCase(extension.type)) {
                return extension;
            }
        }
    }
    // We've not found the type, so return both
    return ALL;
}

From source file:com.moviejukebox.model.attachment.ContentType.java

/**
 * Convert a string into an Enum type//from   w w w .j a  va 2s . c  o m
 *
 * @param type
 * @return
 * @throws IllegalArgumentException If type is not recognised
 *
 */
public static ContentType fromString(String type) {
    if (StringUtils.isNotBlank(type)) {
        try {
            return ContentType.valueOf(type.trim().toUpperCase());
        } catch (IllegalArgumentException ex) {
            throw new IllegalArgumentException("ContentType " + type + " does not exist.", ex);
        }
    }
    throw new IllegalArgumentException("ContentType must not be null");
}