Example usage for org.apache.commons.lang StringUtils isEmpty

List of usage examples for org.apache.commons.lang StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isEmpty.

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:com.haulmont.cuba.desktop.gui.icons.IconResolverImpl.java

@Override
public Icon getIconResource(String icon) {
    if (StringUtils.isEmpty(icon)) {
        return null;
    }/*from   w w  w. java  2  s. c om*/

    String themeIcon = App.getInstance().getThemeConstants().get("icons." + processPath(icon));

    if (StringUtils.isNotEmpty(themeIcon)) {
        return getResource(themeIcon);
    }

    return getResource(icon);
}

From source file:com.clican.pluto.dataprocess.dpl.function.impl.Match.java

public Object calculate(Map<String, Object> row) throws CalculationException, PrefixAndSuffixException {
    String value1 = pas1.getValue(row);
    String value2 = pas2.getValue(row);
    if (StringUtils.isEmpty(value2)) {
        return false;
    }//from ww w.  jav a2  s  . c  o  m
    return value1.matches(value2);
}

From source file:com.hula.lang.parser.util.ValidationUtil.java

/**
 * Assert that the signature of this command line is BeanShell
 * //from ww w  .  j av a 2  s .c o m
 * @param command The command to inspect
 * @param errors A list of error to append to
 */
public static void assertBeanShellSignature(AbstractCommand command, List<ParseError> errors) {
    String signature = ParserUtil.stripCommandDeclaration(command.getCommandLine());

    if (StringUtils.isEmpty(signature)) {
        errors.add(new ParseError("Test must be specified", command.getLineNumber(), command.getCommandLine(),
                null));

    } else {
        try {
            ExpressionUtil.validate(signature);
        } catch (Throwable e) {
            errors.add(new ParseError("Test cannot be evaluated", command.getLineNumber(),
                    command.getCommandLine(), e));
        }
    }

}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.KubernetesResourceProperties.java

public static KubernetesResourceProperties fromCustomResource(CustomKubernetesResource customResource) {
    String deployPriority = customResource.getDeployPriority();
    int deployPriorityValue;
    if (StringUtils.isEmpty(deployPriority)) {
        deployPriorityValue = WORKLOAD_CONTROLLER_PRIORITY.getValue();
    } else {/*from   w  w w  . ja v a2  s.  c  o  m*/
        try {
            deployPriorityValue = Integer.valueOf(deployPriority);
        } catch (NumberFormatException e) {
            deployPriorityValue = KubernetesHandler.DeployPriority.fromString(deployPriority).getValue();
        }
    }

    KubernetesHandler handler = CustomKubernetesHandlerFactory.create(
            KubernetesKind.fromString(customResource.getKubernetesKind()),
            KubernetesSpinnakerKindMap.SpinnakerKind.fromString(customResource.getSpinnakerKind()),
            customResource.isVersioned(), deployPriorityValue);

    return KubernetesResourceProperties.builder().handler(handler).versioned(customResource.isVersioned())
            .versionedConverter(new KubernetesVersionedArtifactConverter())
            .unversionedConverter(new KubernetesUnversionedArtifactConverter()).build();
}

From source file:hudson.scm.util.ParamUtils.java

/**
 * Populates text with parameter values.
 *
 * @param text input text to process/*from w w w.j av  a 2  s  . com*/
 * @param parameters map with parameters.
 * @return populated text.
 */
public static String populateParamValues(String text, Map<String, String> parameters) {
    if (MapUtils.isEmpty(parameters) || StringUtils.isEmpty(text)) {
        return text;
    }
    List<String> searchList = new ArrayList<String>(parameters.keySet().size());
    List<String> replacementList = new ArrayList<String>(parameters.keySet().size());
    for (String key : parameters.keySet()) {
        searchList.add(String.format(PARAM_FORMAT, key));
        replacementList.add(parameters.get(key));
    }
    return org.apache.commons.lang.StringUtils.replaceEach(text,
            searchList.toArray(new String[searchList.size()]),
            replacementList.toArray(new String[replacementList.size()]));
}

From source file:edu.cornell.med.icb.util.SimpleChecksum.java

/**
 * Takes a string and returns a that same string
 * with two additional characters which are a simple
 * checksum, each char will be "A".."Z". An empty
 * (no characters) or null string will just be
 * returned with no change./*w  w w.  ja v a2s  . c  o m*/
 * @param valToChecksum the string to add the checksum to
 * @return the string with the checksum
 */
public static String simpleChecksum(final String valToChecksum) {
    if (StringUtils.isEmpty(valToChecksum)) {
        return valToChecksum;
    }

    final Adler32 adler = new Adler32();
    adler.update(valToChecksum.getBytes());
    final long[] result = splitLong(adler.getValue());

    return String.format("%s%c%c", valToChecksum, CHECKSUM_CHARS[(int) result[0]],
            CHECKSUM_CHARS[(int) result[1]]);
}

From source file:gobblin.util.concurrent.TaskSchedulerType.java

/**
 * Return the {@link TaskSchedulerType} with the specified name. If the specified name
 * does not map to a {@link TaskSchedulerType}, then {@link #SCHEDULEDEXECUTORSERVICE}
 * will be returned.//from  ww  w  . j  ava2 s  .co m
 *
 * @param name the name of the {@link TaskSchedulerType}
 * @return the specified {@link TaskSchedulerType} or {@link #SCHEDULEDEXECUTORSERVICE}
 */
public static TaskSchedulerType parse(String name) {
    if (StringUtils.isEmpty(name)) {
        return SCHEDULEDEXECUTORSERVICE;
    }
    return Enums.getIfPresent(TaskSchedulerType.class, name.toUpperCase()).or(SCHEDULEDEXECUTORSERVICE);
}

From source file:com.devnexus.ting.web.converter.StringToRoom.java

@Override
public Room convert(String source) {

    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {/*from   ww  w .  j a v  a  2s  .c  o m*/
        return new Room(Long.valueOf(source));
    }

}

From source file:iddb.core.util.Validator.java

public static boolean isValidPlayerName(String value) {
    if (StringUtils.isEmpty(value) || value.contains(" "))
        return false;
    for (int i = 0; i < value.length(); i++)
        if (!validPlayerNameChar(value.charAt(i)))
            return false;
    return true;//from  w  w w .  ja v a  2 s .  com
}

From source file:com.beto.test.securityinterceptor.security.UserNamePasswordAuth.java

@Override
protected String obtainUsername(HttpServletRequest request) {
    logger.debug("ExUsernamePasswordAuthenticationFilter.obtainUsername() method called..."
            + request.getParameter(getUsernameParameter()) + "   "
            + request.getParameter(getPasswordParameter()));
    String username = request.getParameter(getUsernameParameter());
    String password = request.getParameter(getPasswordParameter());

    if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
        throw new BadCredentialsException("");
    }/*from  w  ww  . ja v a2 s  .c o  m*/

    return username;
}