List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:org.openmrs.module.idgen.validator.RemoteIdentifierSourceValidator.java
/** * @see Validator#validate(Object, Errors) *//*from w w w .j a v a2 s.co m*/ public void validate(Object o, Errors errors) { RemoteIdentifierSource source = (RemoteIdentifierSource) o; // Url is required if (!StringUtils.hasText(source.getUrl())) { errors.reject("Url is required"); } }
From source file:com.porvak.bracket.social.jdbc.versioned.SqlDatabaseChange.java
private static String readScript(Resource resource) throws IOException { EncodedResource encoded = resource instanceof EncodedResource ? (EncodedResource) resource : new EncodedResource(resource); LineNumberReader lnr = new LineNumberReader(encoded.getReader()); String currentStatement = lnr.readLine(); StringBuilder scriptBuilder = new StringBuilder(); while (currentStatement != null) { if (StringUtils.hasText(currentStatement) && (SQL_COMMENT_PREFIX != null && !currentStatement.startsWith(SQL_COMMENT_PREFIX))) { if (scriptBuilder.length() > 0) { scriptBuilder.append('\n'); }// w w w . j a v a 2s. c om scriptBuilder.append(currentStatement); } currentStatement = lnr.readLine(); } return scriptBuilder.toString(); }
From source file:org.cloudfoundry.workers.stocks.MockStockSymbolLookupClient.java
@Override public StockSymbolLookup lookupSymbol(String symbol) throws Throwable { return new StockSymbolLookup(randomLong(), randomDouble(), symbol, StringUtils.hasText(null) ? null : "NYSE", randomDouble(), randomDouble(), randomDouble()); }
From source file:org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler.java
public boolean authenticateUsernamePasswordInternal(final UsernamePasswordCredentials credentials) { final String username = credentials.getUsername(); final String password = credentials.getPassword(); if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.equals(getPasswordEncoder().encode(password))) { log.debug("User [" + username + "] was successfully authenticated."); return true; }/*from w w w .java 2s . c o m*/ log.debug("User [" + username + "] failed authentication"); return false; }
From source file:org.wallride.autoconfigure.WallRideInitializer.java
public static ConfigurableEnvironment createEnvironment(ApplicationStartedEvent event) { StandardEnvironment environment = new StandardEnvironment(); String home = environment.getProperty(WallRideProperties.HOME_PROPERTY); if (!StringUtils.hasText(home)) { throw new IllegalStateException(WallRideProperties.HOME_PROPERTY + " is empty"); }//from www . j ava 2 s . c o m if (!home.endsWith("/")) { home = home + "/"; } String config = home + WallRideProperties.DEFAULT_CONFIG_PATH_NAME; String media = home + WallRideProperties.DEFAULT_MEDIA_PATH_NAME; System.setProperty(WallRideProperties.CONFIG_LOCATION_PROPERTY, config); System.setProperty(WallRideProperties.MEDIA_LOCATION_PROPERTY, media); event.getSpringApplication().getListeners().stream() .filter(listener -> listener.getClass().isAssignableFrom(ConfigFileApplicationListener.class)) .map(listener -> (ConfigFileApplicationListener) listener) .forEach(listener -> listener.setSearchLocations(DEFAULT_CONFIG_SEARCH_LOCATIONS + "," + config)); return environment; }
From source file:cn.edu.zjnu.acm.judge.config.thymeleaf.EmptyTextProcessor.java
@Override public void doProcess(ITemplateContext context, IText text, ITextStructureHandler structureHandler) { String content = text.getText(); if (!StringUtils.hasText(content)) { structureHandler.removeText();// ww w .j a v a 2 s. c o m } }
From source file:org.openmrs.module.orderentryui.propertyeditor.CareSettingEditor.java
/** * @should set using id// www. ja v a 2s . c o m * @should set using uuid * * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) */ public void setAsText(String text) throws IllegalArgumentException { OrderService ps = Context.getOrderService(); if (StringUtils.hasText(text)) { try { setValue(ps.getCareSetting(Integer.valueOf(text))); } catch (Exception ex) { CareSetting careSetting = ps.getCareSettingByUuid(text); setValue(careSetting); if (careSetting == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("CareSetting not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:org.openmrs.module.orderentryui.propertyeditor.OrderFrequencyEditor.java
/** * @should set using id/*from w ww.j ava 2 s . c om*/ * @should set using uuid * * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String) */ public void setAsText(String text) throws IllegalArgumentException { OrderService ps = Context.getOrderService(); if (StringUtils.hasText(text)) { try { setValue(ps.getOrderFrequency(Integer.valueOf(text))); } catch (Exception ex) { OrderFrequency orderFrequency = ps.getOrderFrequencyByUuid(text); setValue(orderFrequency); if (orderFrequency == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("OrderFrequency not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:com.seajas.search.utilities.spring.SystemPropertyInitializingBean.java
/** * Initialize the actual properties./* w w w. jav a 2s. c o m*/ */ @Override public void afterPropertiesSet() throws Exception { for (Map.Entry<String, String> systemProperty : systemProperties.entrySet()) if (StringUtils.hasText(systemProperty.getValue())) System.setProperty(systemProperty.getKey(), systemProperty.getValue()); }
From source file:com.kdubb.socialshowcaseboot.facebook.PostToWallAfterConnectInterceptor.java
public void preConnect(ConnectionFactory<Facebook> connectionFactory, MultiValueMap<String, String> parameters, WebRequest request) {//from ww w .ja v a2 s .c o m if (StringUtils.hasText(request.getParameter(POST_TO_WALL_PARAMETER))) { request.setAttribute(POST_TO_WALL_ATTRIBUTE, Boolean.TRUE, WebRequest.SCOPE_SESSION); } }