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:com.yevster.spdxtra.Validate.java

public static void notBlank(String name) {
    if (StringUtils.isBlank(name)) {
        throw exceptionFactory.apply("Argument cannot be blank");
    }/*from   w w  w . j av  a2  s.  c  o  m*/
}

From source file:mesclasses.util.validation.Validators.java

public static List<FError> validate(Cours c) {
    List<FError> err = Lists.newArrayList();
    LOG.debug("validation du cours " + c);
    if (c.getId() == null) {
        err.add(new FError(NO_ID("Cours")));
        return err;
    }/*from   ww w .  ja v  a 2 s  .  c o m*/
    if (StringUtils.isBlank(c.getDay())) {
        err.add(new FError(MANDATORY(c, "jour")));
    }
    if (StringUtils.isBlank(c.getWeek())) {
        err.add(new FError(MANDATORY(c, "priodicit")));
    }
    if (c.getClasse() == null) {
        err.add(new FError(MANDATORY(c, "classe")));
    }
    if (c.getStartHour() == null) {
        err.add(new FError(MANDATORY(c, "heure de dbut")));
    }
    if (c.getEndHour() == null) {
        err.add(new FError(MANDATORY(c, "heure de fin")));
    }
    return err;
}

From source file:com.zx.stlife.controller.wx.LoginWxController.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request) {
    String backUrl = request.getParameter("backUrl");
    String url = null;/* w w  w .j a va  2 s  .  c  o  m*/
    if (StringUtils.isBlank(backUrl)) {
        if (oauthUrlWithNotBackUrl == null) {
            WxAccount wxAccount = wxAccountService.get();
            oauthUrlWithNotBackUrl = "redirect:"
                    + ConstWeixinH5.OAUTH_URL.replace("APPID", wxAccount.getAppId()).replace("REDIRECT_URL",
                            Encodes.urlEncode(ConstWeixinH5.REDIRECT_URL));
        }
        url = oauthUrlWithNotBackUrl;
    } else {
        String redirectUrl = Encodes.urlEncode(ConstWeixinH5.REDIRECT_URL + "?backUrl=" + backUrl);
        WxAccount wxAccount = wxAccountService.get();
        // ?
        url = "redirect:" + ConstWeixinH5.OAUTH_URL.replace("APPID", wxAccount.getAppId())
                .replace("REDIRECT_URL", redirectUrl);
    }

    return url;
}

From source file:com.jim.im.exception.ImAllRuntimeExceptionMapper.java

@Override
public Response toResponse(RuntimeException e) {
    ApiErrorCode errorCode = ApiErrorCode.INNER_ERROR;

    String errorMsg = e.getMessage();
    if (StringUtils.isBlank(errorMsg)) {
        errorMsg = IMConstant.MSG_INNER_ERROR;
    }/*from   w  ww.  j av  a2s.  c om*/

    String requestId = RequestContext.get(IMConstant.REQUEST_ID);

    ApiErrorCodeException errorCodeException = new ApiErrorCodeException(requestId, errorCode, errorMsg, e);
    logger.error(requestId, errorCodeException);

    return RestResult.failure(requestId, errorCode.errorCode, errorMsg);
}

From source file:com.mirth.connect.client.ui.components.rsta.ac.js.PartialHashMap.java

public List<V> getPartial(Object key) {
    String fixedKey = fixKey(key);

    if (StringUtils.isBlank(fixedKey)) {
        List<V> list = new ArrayList<V>();
        for (List<V> value : values()) {
            list.addAll(value);// w  w w  . jav a 2 s. c o m
        }
        return list;
    } else {
        List<V> list = new ArrayList<V>();

        for (Entry<String, List<V>> entry : entrySet()) {
            String entryKey = entry.getKey();

            if (entry.getKey().startsWith(fixedKey)) {
                list.addAll(entry.getValue());
            } else {
                String[] array = splitMap.get(entryKey);
                if (array != null) {
                    for (String element : array) {
                        if (element.startsWith(fixedKey)) {
                            list.addAll(entry.getValue());
                            break;
                        }
                    }
                }
            }
        }

        return list;
    }
}

From source file:controllers.api.v1.Flow.java

public static Result getPagedProjects(String application) {
    ObjectNode result = Json.newObject();
    int page = 1;
    String pageStr = request().getQueryString("page");
    if (StringUtils.isBlank(pageStr)) {
        page = 1;/*from   w  w w .  ja  v a2 s.co m*/
    } else {
        try {
            page = Integer.parseInt(pageStr);
        } catch (NumberFormatException e) {
            Logger.error(
                    "Flow Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage());
            page = 1;
        }
    }

    int size = 10;
    String sizeStr = request().getQueryString("size");
    if (StringUtils.isBlank(sizeStr)) {
        size = 10;
    } else {
        try {
            size = Integer.parseInt(sizeStr);
        } catch (NumberFormatException e) {
            Logger.error(
                    "Flow Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage());
            size = 10;
        }
    }

    result.put("status", "ok");
    result.set("data", FlowsDAO.getPagedProjectsByApplication(application, page, size));
    return ok(result);
}

From source file:com.github.jackygurui.vertxredissonrepository.repository.index.DefaultCompoundValueResolver.java

@Override
public String resolve(Object value, JsonObject root, String id, String fieldName, RedissonIndex index) {
    AtomicReference<String> s = new AtomicReference<>();
    if (StringUtils.isBlank(index.valueField())) {
        s.set(value instanceof String ? (String) value : Json.encode(value));
    } else {//  w w w  .  ja  v  a2  s.com
        s.set(root.getString(index.valueField()));
    }
    Arrays.stream(index.compoundIndexFields()).forEach(
            e -> s.set(s.get().concat(RedisRepository.DEFAULT_SEPERATOR).concat(root.getValue(e).toString())));
    return s.get().concat(RedisRepository.DEFAULT_SEPERATOR).concat(id);
}

From source file:com.ottogroup.bi.spqr.metrics.MetricsReporterFactory.java

/**
 * Attaches a {@link GraphiteReporter} to provided {@link MetricsHandler}
 * @param metricsHandler/*from  w  w  w.  j  a  v a2s  .  co m*/
 * @param id
 * @param period
 * @param host
 * @param port
 * @throws RequiredInputMissingException
 */
private static void attachGraphiteReporter(final MetricsHandler metricsHandler, final String id,
        final int period, final String host, final int port) throws RequiredInputMissingException {

    //////////////////////////////////////////////////////////////////////////
    // validate input
    if (StringUtils.isBlank(id))
        throw new RequiredInputMissingException("Missing required metric reporter id");
    if (metricsHandler == null)
        throw new RequiredInputMissingException("Missing required metrics handler");
    if (StringUtils.isBlank(host))
        throw new RequiredInputMissingException("Missing required graphite host");
    if (port < 0)
        throw new RequiredInputMissingException("Missing required graphite port");
    //////////////////////////////////////////////////////////////////////////

    final Graphite graphite = new Graphite(new InetSocketAddress(host, port));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metricsHandler.getRegistry())
            .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL)
            .build(graphite);
    reporter.start((period > 0 ? period : 1), TimeUnit.SECONDS);
    metricsHandler.addScheduledReporter(id, reporter);
}

From source file:edu.cornell.kfs.vnd.document.validation.impl.CuVendorPreRules.java

@Override
protected boolean doCustomPreRules(MaintenanceDocument document) {
    setupConvenienceObjects(document);//  w  w  w  .  j  a v a2 s.  co  m
    setVendorNamesAndIndicator(document);
    setVendorRestriction(document);
    if (StringUtils.isBlank(question) || (question.equals(VendorConstants.CHANGE_TO_PARENT_QUESTION_ID))) {
        detectAndConfirmChangeToParent(document);
    }
    if (!document.isNew()) {
        if (StringUtils.isBlank(question) || (question.equals(CUVendorConstants.EXPIRED_DATE_QUESTION_ID))) {
            detectAndConfirmExpirationDates(document);
        }
    }

    //check to page review ONLY if it is a new vendor
    if (newVendorDetail.getVendorHeaderGeneratedIdentifier() == null
            && newVendorDetail.getVendorDetailAssignedIdentifier() == null) {
        displayReview(document);
    }
    return true;
}

From source file:de.pixida.logtest.designer.automaton.PropertyNode.java

String apply(String value) {
    if (StringUtils.isBlank(value)) {
        value = null;//from   ww  w.  ja  v a2s .com
    }
    if (value != null) {
        if (!this.isVisible()) {
            final double margin = 80.0;
            this.moveTo(this.parent.getPosition().add(margin, margin));
            this.showAndAddToScene();
        }

        this.setContent(value);
    } else {
        this.hideAndRemoveFromScene();
    }
    return value;
}