List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.consol.citrus.samples.flightbooking.entity.converter.FlightConverter.java
/** * Get model form entity./*from www . j a v a 2s . c o m*/ * @param entity * @return * @throws ParseException */ public static Flight from(FlightEntity entity) { DateFormat dateFormat = new SimpleDateFormat("yyyy-dd-MM'T'HH:mm:ss"); if (entity == null) { return null; } Flight model = new Flight(); Calendar scheduledArrival = null; Calendar scheduledDeparture = null; try { if (StringUtils.hasText(entity.getScheduledArrival())) { scheduledArrival = Calendar.getInstance(); scheduledArrival.setTime(dateFormat.parse(entity.getScheduledArrival())); } if (StringUtils.hasText(entity.getScheduledDeparture())) { scheduledDeparture = Calendar.getInstance(); scheduledDeparture.setTime(dateFormat.parse(entity.getScheduledDeparture())); } } catch (ParseException e) { throw new IllegalArgumentException("Failed to parse date format", e); } model.setAirline(entity.getAirline()); model.setFlightId(entity.getFlightId()); model.setFromAirport(entity.getFromAirport()); model.setScheduledArrival(scheduledArrival); model.setToAirport(entity.getToAirport()); model.setScheduledDeparture(scheduledDeparture); return model; }
From source file:fr.univlorraine.mondossierweb.utils.PropertyUtils.java
/** Retourne l'url de serveur elasticSearch */ public static String getElasticSearchUrl() { String value = System.getProperty("context.param.elasticsearch.url"); if (!StringUtils.hasText(value)) throw new NullPointerException("param.elasticsearch.url cannot be null !"); return value; }
From source file:org.focusns.common.web.page.config.PageConfigKey.java
public static String generateKey(String path, Map<String, ?> paramsMap) { if (paramsMap.isEmpty()) { return path; }/*from w ww .j a v a 2 s. co m*/ // StringBuilder sb = new StringBuilder(path); for (String paramName : paramsMap.keySet()) { if (PARAM_NAMES_EXCLUDE.contains(paramName)) { continue; } // String paramValue = String.valueOf(paramsMap.get(paramName)); if (StringUtils.hasText(paramValue)) { sb.append(paramName).append("=").append(paramsMap.get(paramName)); } } // return sb.toString(); }
From source file:springfox.documentation.swagger2.web.ForwardedHeader.java
/** * Creates a new {@link ForwardedHeader} from the given source. * * @param source can be {@literal null}. * @return//from w w w . j a v a2s .c o m */ public static ForwardedHeader of(String source) { if (!StringUtils.hasText(source)) { return NO_HEADER; } Map<String, String> elements = new HashMap<String, String>(); for (String part : source.split(";")) { String[] keyValue = part.split("="); if (keyValue.length != 2) { continue; } elements.put(keyValue[0].trim(), keyValue[1].trim()); } Assert.notNull(elements, "Forwarded elements must not be null!"); Assert.isTrue(!elements.isEmpty(), "At least one forwarded element needs to be present!"); return new ForwardedHeader(elements); }
From source file:com.benfante.taglib.frontend.tags.BootstrapTagHelper.java
/** * compute css classe for input in case of prefix & suffix * * @param prefix/*from w w w .j a v a2 s . co m*/ * @param suffix * @return */ public static String prependAppendCssClasses(final String prefix, final String suffix) { return (StringUtils.hasText(prefix) ? "input-prepend" : "") + " " + (StringUtils.hasText(suffix) ? "input-append" : ""); }
From source file:com.afousan.model.RetwisSecurity.java
public static boolean isSignedIn() { return StringUtils.hasText(getName()); }
From source file:fi.hsl.parkandride.ApplicationVersionFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) res; if (StringUtils.hasText(version)) { response.setHeader("Liipi-Version", version); }/*from ww w. ja v a 2 s. co m*/ chain.doFilter(req, res); }
From source file:org.cloudfoundry.identity.uaa.authentication.login.PromptEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { setValue(Prompt.valueOf(text));// w ww . j a v a 2 s .c o m } else { setValue(null); } }
From source file:org.opencredo.demos.twityourl.ConfigurationProperties.java
protected static void checkPropertySet(String propertyName, String valueRetrieved) { if (!StringUtils.hasText(valueRetrieved) || valueRetrieved.equals("${" + propertyName + "}")) { throw new RuntimeException("No value for key " + propertyName + " found you may want to add this to your maven settings.xml"); }//from w w w . j a v a 2 s . c o m }
From source file:com.pamarin.income.util.UrlUtils.java
public static String decodeQuerystringRequestUri(String requestUri) { if (!StringUtils.hasText(requestUri)) { return ""; }//from w w w . jav a 2s . co m int indexOf = requestUri.indexOf(encode("?")); if (indexOf == -1) { return requestUri; } String querystring = decode(requestUri.substring(indexOf)); return requestUri.substring(0, indexOf) + querystring; }