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

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

Introduction

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

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is whitespace, empty ("") or null.

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

Usage

From source file:net.sourceforge.mavenhippo.gen.ClassReference.java

public ClassReference(String className) {
    if (StringUtils.isBlank(className)) {
        throw new IllegalArgumentException("className parameter is required.");
    }//www  .j  a  v a2s.co m
    this.className = className.trim().intern();
}

From source file:com.mb.framework.util.property.HostnameAwareList.java

/**
 * default constructor//from w  w w . j  a va 2s.  c  om
 * 
 * @throws UnknownHostException
 */
public HostnameAwareList() throws UnknownHostException {
    hostname = InetAddress.getLocalHost().getHostName().toUpperCase();
    logger.debug("Resolved hostname: " + hostname);

    if (StringUtils.isBlank(hostname)) {
        throw new UnknownHostException("Error resolving hostname, hostname is null or empty: " + hostname);
    }
}

From source file:com.navercorp.pinpoint.web.util.ThreadDumpUtils.java

public static String createDumpMessage(TThreadDump threadDump) {
    TThreadState threadState = getThreadState(threadDump.getThreadState());

    // set threadName
    StringBuilder message = new StringBuilder("\"" + threadDump.getThreadName() + "\"");

    // set threadId
    String hexStringThreadId = Long.toHexString(threadDump.getThreadId());
    message.append(" Id=0x" + hexStringThreadId);

    // set threadState
    message.append(" " + threadState.name());

    if (!StringUtils.isBlank(threadDump.getLockName())) {
        message.append(" on ").append(threadDump.getLockName());
    }/*from ww w .j  a  v a2 s . c  om*/

    if (!StringUtils.isBlank(threadDump.getLockOwnerName())) {
        message.append(" owned by \"").append(threadDump.getLockOwnerName()).append("\" Id=")
                .append(threadDump.getLockOwnerId());
    }

    if (threadDump.isSuspended()) {
        message.append(" (suspended)");
    }
    if (threadDump.isInNative()) {
        message.append(" (in native)");
    }
    message.append(LINE_SEPARATOR);

    // set StackTrace
    for (int i = 0; i < threadDump.getStackTraceSize(); i++) {
        String stackTrace = threadDump.getStackTrace().get(i);
        message.append(TAB_SEPARATOR + "at ").append(stackTrace);
        message.append(LINE_SEPARATOR);

        if (i == 0 && !StringUtils.isBlank(threadDump.getLockName())) {
            switch (threadState) {
            case BLOCKED:
                message.append(TAB_SEPARATOR + "-  blocked on ").append(threadDump.getLockName());
                message.append(LINE_SEPARATOR);
                break;
            case WAITING:
                message.append(TAB_SEPARATOR + "-  waiting on ").append(threadDump.getLockName());
                message.append(LINE_SEPARATOR);
                break;
            case TIMED_WAITING:
                message.append(TAB_SEPARATOR + "-  waiting on ").append(threadDump.getLockName());
                message.append(LINE_SEPARATOR);
                break;
            default:
            }
        }

        if (threadDump.getLockedMonitors() != null) {
            for (TMonitorInfo lockedMonitor : threadDump.getLockedMonitors()) {
                if (lockedMonitor.getStackDepth() == i) {
                    message.append(TAB_SEPARATOR + "-  locked ").append(lockedMonitor.getStackFrame());
                    message.append(LINE_SEPARATOR);
                }
            }
        }
    }

    // set Locks
    List<String> lockedSynchronizers = threadDump.getLockedSynchronizers();
    if (!CollectionUtils.isEmpty(lockedSynchronizers)) {
        message.append(LINE_SEPARATOR + TAB_SEPARATOR + "Number of locked synchronizers = ")
                .append(lockedSynchronizers.size());
        message.append(LINE_SEPARATOR);
        for (String lockedSynchronizer : lockedSynchronizers) {
            message.append(TAB_SEPARATOR + "- ").append(lockedSynchronizer);
            message.append(LINE_SEPARATOR);
        }
    }

    message.append(LINE_SEPARATOR);
    return message.toString();
}

From source file:com.monarchapis.client.authentication.SimpleAuthRequestProcessor.java

public SimpleAuthRequestProcessor(String apiKey, AccessTokenSource accessTokenSource) {
    if (StringUtils.isBlank(apiKey)) {
        throw new IllegalArgumentException("apiKey must not be blank or null");
    }/*from   ww w .j  a v a  2 s .  com*/

    this.apiKey = apiKey;
    this.accessTokenSource = accessTokenSource;
}

From source file:com.nesscomputing.service.discovery.announce.GalaxyAnnouncer.java

public static final Set<ServiceInformation> buildServices(final AnnouncementConfig announcementConfig,
        final GalaxyHttpServerConfig httpServerConfig, final GalaxyConfig galaxyConfig) {
    final Set<ServiceInformation> services = Sets.newHashSet();

    final String serviceName = announcementConfig.getServiceName();
    if (StringUtils.isBlank(serviceName)) {
        LOG.warn("No service name given, not announcing anything. This is not what you want!");
    } else {//from   w  w  w .j av a  2  s. c om
        final String serviceType = announcementConfig.getServiceType();

        if (announcementConfig.isAnnounceInternal()) {
            LOG.debug("Internal services are announced");
            services.addAll(buildInternalServices(serviceName, serviceType, httpServerConfig, galaxyConfig));
        }
        if (announcementConfig.isAnnounceExternal()) {
            LOG.debug("External services are announced");
            services.addAll(buildExternalServices(serviceName, serviceType, httpServerConfig, galaxyConfig));
        }
    }

    LOG.debug("Total number of announcements: %d", services.size());
    return services;
}

From source file:com.github.britter.beanvalidators.net.IPConstraintValidator.java

@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/* www . jav a2 s.co m*/

    switch (type) {
    case IP_V4:
        return InetAddressValidator.getInstance().isValidInet4Address(value);
    case IP_V6:
        return InetAddressValidator.getInstance().isValidInet6Address(value);
    default:
        return InetAddressValidator.getInstance().isValid(value);
    }
}

From source file:com.thinkbiganalytics.policy.precondition.AvailablePolicies.java

/**
 * Find all classes annotated with {@link PreconditionPolicy} and transfrom them into the user interface object
 *
 * @return user interface objects of the {@link PreconditionPolicy} on the classpath
 *///  www .ja va 2  s. c  o  m
public static List<PreconditionRule> discoverPreconditions() {

    List<PreconditionRule> rules = new ArrayList<>();
    Set<Class<?>> validators = ReflectionPolicyAnnotationDiscoverer
            .getTypesAnnotatedWith(PreconditionPolicy.class);
    for (Class c : validators) {
        PreconditionPolicy policy = (PreconditionPolicy) c.getAnnotation(PreconditionPolicy.class);
        String desc = policy.description();
        String shortDesc = policy.shortDescription();
        if (StringUtils.isBlank(desc) && StringUtils.isNotBlank(shortDesc)) {
            desc = shortDesc;
        }
        if (StringUtils.isBlank(shortDesc) && StringUtils.isNotBlank(desc)) {
            shortDesc = desc;
        }
        List<FieldRuleProperty> properties = PreconditionAnnotationTransformer.instance().getUiProperties(c);
        rules.add(new PreconditionRuleBuilder(policy.name()).description(desc).shortDescription(shortDesc)
                .addProperties(properties).objectClassType(c).build());
    }
    return rules;
}

From source file:com.vmware.photon.controller.api.frontend.exceptions.external.IsoAlreadyAttachedException.java

@Override
public String getMessage() {
    if (!StringUtils.isBlank(id)) {
        return String.format("Only one iso allowed to attached to the vm, iso id %s already attached to the vm",
                id);/*from  w  ww. j a v  a2 s . c o  m*/
    }
    return "Only one iso allowed to attached to the vm, one already attached to the vm";
}

From source file:com.vmware.photon.controller.api.frontend.exceptions.external.MoreThanOneIsoAttachedException.java

@Override
public String getMessage() {
    if (!StringUtils.isBlank(id)) {
        return String.format("More than one ISO is attached to vm %s", id);
    }/*from   ww  w . j  a va 2  s.c om*/
    return "More than one ISO is attached to vm";
}

From source file:com.rogers.ute.creditservice.util.CreditServiceUtils.java

public static CreditEvaluationRequestInfoType createRequestBody(CreditCheckForm creditCheckForm) {
    CreditEvaluationRequestInfoType creditEvaluationRequestInfoType = new CreditEvaluationRequestInfoType();

    creditEvaluationRequestInfoType.setBusinessType(creditCheckForm.getBusinessType());
    creditEvaluationRequestInfoType.setECID(creditCheckForm.getECID());
    creditEvaluationRequestInfoType.setFirstName(creditCheckForm.getFirstName());
    creditEvaluationRequestInfoType.setMiddleName(creditCheckForm.getMiddleName());
    creditEvaluationRequestInfoType.setLastBusinessName(creditCheckForm.getLastBusinessName());
    creditEvaluationRequestInfoType.setCustAddrLine1(creditCheckForm.getCustAddrLine1());
    creditEvaluationRequestInfoType.setCustAddrLine2(creditCheckForm.getCustAddrLine2());
    creditEvaluationRequestInfoType.setCustAddrCity(creditCheckForm.getCustAddrCity());
    creditEvaluationRequestInfoType.setCustAddrProvince(creditCheckForm.getCustAddrProvince());
    creditEvaluationRequestInfoType.setCustAddrPostalCode(creditCheckForm.getCustAddrPostalCode());
    creditEvaluationRequestInfoType.setHomePhone(creditCheckForm.getHomePhone());
    if (!StringUtils.isBlank(creditCheckForm.getBirthDate()))
        creditEvaluationRequestInfoType.setBirthDate(asXMLGregorianCalendar(creditCheckForm.getBirthDate()));
    setIDValue(creditEvaluationRequestInfoType, creditCheckForm, creditCheckForm.getFirstIDType(),
            creditCheckForm.getFirstIdentifier());
    setIDValue(creditEvaluationRequestInfoType, creditCheckForm, creditCheckForm.getSecondIDType(),
            creditCheckForm.getSecondIdentifier());

    creditEvaluationRequestInfoType.setEmail(creditCheckForm.getEmail());

    creditEvaluationRequestInfoType.setAccountType(creditCheckForm.getAccountType());
    populateFixedValues(creditEvaluationRequestInfoType);

    return creditEvaluationRequestInfoType;
}