List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:com.xpn.xwiki.internal.doc.AbstractDocumentRevisionProvider.java
@Override public XWikiDocument getRevision(XWikiDocument document, String revision) throws XWikiException { XWikiDocument newdoc;/*from w w w. j a v a 2 s. c o m*/ if (StringUtils.isEmpty(revision)) { newdoc = new XWikiDocument(document.getDocumentReference()); } else if (revision.equals(document.getVersion())) { newdoc = document; } else { newdoc = getRevision(document.getDocumentReferenceWithLocale(), revision); } return newdoc; }
From source file:minor.commodity.CommodityQuote.java
@Override public void validate() { if (StringUtils.isEmpty(getCticker())) { addFieldError("cticker", "Commodity Quote cannot be blank"); }//from ww w . j a va 2 s. co m if (StringUtils.isNumeric(getCticker())) { addFieldError("cticker", "Commodity Quote cannot be numeric"); } if (StringUtils.length(getCticker()) > 12) { addFieldError("cticker", "Invalid Ticker length"); } }
From source file:com.ejisto.modules.factory.impl.EnumFactory.java
@Override public Enum<T> create(MockedField m, Enum<T> actualValue) { try {//from ww w .jav a 2 s . c o m String name = m.getFieldValue(); if (StringUtils.isEmpty(name)) { return actualValue; } @SuppressWarnings("unchecked") Class<Enum<T>> clazz = (Class<Enum<T>>) Class.forName(m.getFieldType()); if (!clazz.isEnum()) { return actualValue; } Enum<T>[] enums = clazz.getEnumConstants(); for (Enum<T> en : enums) { if (en.name().equals(name)) { return en; } } if (actualValue != null) { return actualValue; } return enums.length > 0 ? enums[0] : null; } catch (Exception ex) { log.warn(String.format("enum value not found for %s.", m), ex); } return actualValue; }
From source file:com.github.rvesse.airline.builder.AbstractBuilder.java
/** * Checks a value given for a parameter is not null/empty * // w w w. j av a2s. co m * @param value * Value * @param paramName * Parameter */ protected final void checkNotEmpty(String value, String paramName) { if (StringUtils.isEmpty(value)) throw new IllegalArgumentException(String.format("%s cannot be null/empty", paramName)); }
From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.HashMapToStringUserType.java
@Override public void setParameterValues(Properties parameters) { String keyType = (String) parameters.get("keyType"); if (!StringUtils.isEmpty(keyType)) { try {/*from ww w .j a v a 2s . co m*/ this.keyType = Class.forName(keyType); } catch (ClassNotFoundException e) { throw new HibernateException(e); } } else { this.keyType = String.class; } }
From source file:com.huangyunkun.jviff.modal.StepResult.java
public void addImage(String fileName) { if (StringUtils.isEmpty(firstImage)) { firstImage = fileName;//from w w w . j av a 2 s. c o m } else { secondImage = fileName; } }
From source file:com.company.vertxstarter.MainVerticle.java
@Override public void start(Future<Void> fut) { // Create a router object. Router router = Router.router(vertx); //CORS handler router.route().handler(CorsHandler.create("*").allowedMethod(HttpMethod.GET).allowedMethod(HttpMethod.POST) .allowedMethod(HttpMethod.OPTIONS).allowedHeader("Content-Type").allowedHeader("Accept")); //default headers router.route().handler(ctx -> {// w ww .j av a 2 s.c om ctx.response().putHeader("Cache-Control", "no-store, no-cache").putHeader("Content-Type", "application/json"); if (StringUtils.isEmpty(ctx.request().getHeader("Accept"))) { ctx.fail(Failure.NO_MEDIA_TYPE); return; } else if (!"application/json".equalsIgnoreCase(ctx.request().getHeader("Accept"))) { ctx.fail(Failure.UNSUPPORTED_MEDIA_TYPE); return; } ctx.next(); }); //error handling router.route().failureHandler(ctx -> { HttpServerResponse response = ctx.response(); final JsonObject error = new JsonObject(); Failure ex; if (ctx.failure() instanceof Failure) { //specific error ex = (Failure) ctx.failure(); } else { //general error ctx.failure().printStackTrace(); ex = Failure.INTERNAL_ERROR; } error.put("message", ex.getMessage()); response.setStatusCode(ex.getCode()).end(error.encode()); }); //default 404 handling router.route().last().handler(ctx -> { HttpServerResponse response = ctx.response(); final JsonObject error = new JsonObject(); error.put("message", Failure.NOT_FOUND.getMessage()); response.setStatusCode(404).end(error.encode()); }); //routes Injector injector = Guice.createInjector(new AppInjector()); router.route(HttpMethod.GET, "/people").handler(injector.getInstance(PersonResource.class)::get); // Create the HTTP server and pass the "accept" method to the request handler. HttpServerOptions serverOptions = new HttpServerOptions(); serverOptions.setCompressionSupported(true); vertx.createHttpServer(serverOptions).requestHandler(router::accept) .listen(config().getInteger("http.port", 8080), result -> { if (result.succeeded()) { fut.complete(); } else { fut.fail(result.cause()); } }); }
From source file:com.gargoylesoftware.htmlunit.util.URLCreator.java
protected URL toNormalUrl(final String url) throws MalformedURLException { final URL response = new URL(url); if (response.getProtocol().startsWith("http") && StringUtils.isEmpty(response.getHost())) { throw new MalformedURLException("Missing host name in url: " + url); }//from w w w . ja v a 2 s . co m return response; }
From source file:app.controller.LinkController.java
@GetMapping("/fetch") public Response<Collection> fetchUrInfo(@RequestHeader(value = "token") String token, @RequestParam(value = "url") String url) { String uid = mAuthService.checkIfAuthBind(token); if (StringUtils.isEmpty(uid)) { return ResultCode.error(ResultCode.USER_AUTH_FAILED); }//from w w w. j av a2 s . c om int resultCode; if (StringUtils.isEmpty(url)) { resultCode = ResultCode.ARGUMENT_ERROR; } else { Collection col = mFetchService.getUrlInfo(uid, url); if (col == null) { resultCode = ResultCode.FETCH_URL_DATA_FAILED; } else { return new Response<>(col); } } return ResultCode.error(resultCode); }
From source file:cherry.common.testtool.StubReposControllerImpl.java
@Override public String alwaysReturnJson(String className, String methodName, int methodIndex, String value, String valueType) {//from w ww. jav a2 s .co m if (StringUtils.isEmpty(value)) { return jsonStubService.clear(className, methodName, methodIndex); } else { return jsonStubService.alwaysReturn(className, methodName, methodIndex, value, valueType); } }