List of usage examples for org.springframework.util Assert hasText
public static void hasText(@Nullable String text, Supplier<String> messageSupplier)
From source file:org.cleverbus.test.route.TestWsUriBuilder.java
@Override public String getInWsUri(QName qName, String endpointMappingRef, @Nullable String params) { Assert.notNull(qName, "the qName must not be null"); Assert.hasText(qName.getLocalPart(), "the localPart must not be empty"); return URI_WS_IN + qName.getLocalPart(); }
From source file:org.cleverbus.core.common.contextcall.ContextCallRoute.java
/** * Makes call.// w ww. j a v a 2 s .c o m * * @param callId Call ID for getting call parameters from {@link ContextCallRegistry} */ @Handler public void makeCall(@Header(CALL_ID_HEADER) String callId) { Assert.hasText(callId, "the callId must not be empty"); // get params ContextCallParams params = callRegistry.getParams(callId); Object res = ReflectionCallUtils.invokeMethod(params, getApplicationContext()); // save response callRegistry.addResponse(callId, res); Log.debug("Response of the call ID '" + callId + "' was saved: " + res); }
From source file:com.github.hateoas.forms.affordance.PartialUriTemplate.java
/** * Creates a new {@link PartialUriTemplate} using the given template string. * * @param template must not be {@literal null} or empty. */// w w w. ja v a 2 s.c om public PartialUriTemplate(String template) { Assert.hasText(template, "Template must not be null or empty!"); Matcher matcher = VARIABLE_REGEX.matcher(template); // first group is the variable start without leading {: "", "/", "?", "#", // second group is the comma-separated name list without the trailing } of the variable int endOfPart = 0; while (matcher.find()) { // 0 is the current match, i.e. the entire variable expression int startOfPart = matcher.start(0); // add part before current match if (endOfPart < startOfPart) { final String partWithoutVariables = template.substring(endOfPart, startOfPart); final StringTokenizer stringTokenizer = new StringTokenizer(partWithoutVariables, "?", true); boolean inQuery = false; while (stringTokenizer.hasMoreTokens()) { final String token = stringTokenizer.nextToken(); if ("?".equals(token)) { inQuery = true; } else { if (!inQuery) { urlComponents.add(token); } else { urlComponents.add("?" + token); } variableIndices.add(Collections.<Integer>emptyList()); } } } endOfPart = matcher.end(0); // add current match as part final String variablePart = template.substring(startOfPart, endOfPart); urlComponents.add(variablePart); // collect variablesInPart and track for each part which variables it contains // group(1) is the variable head without the leading { TemplateVariable.VariableType type = TemplateVariable.VariableType.from(matcher.group(1)); // group(2) are the variable names String[] names = matcher.group(2).split(","); List<Integer> variablesInPart = new ArrayList<Integer>(); for (String name : names) { TemplateVariable variable = new TemplateVariable(name, type); variablesInPart.add(variables.size()); variables.add(variable); variableNames.add(name); } variableIndices.add(variablesInPart); } // finish off remaining part if (endOfPart < template.length()) { urlComponents.add(template.substring(endOfPart)); variableIndices.add(Collections.<Integer>emptyList()); } }
From source file:com.francetelecom.clara.cloud.coremodel.ConfigRole.java
public ConfigRole(String applicationUID) { super(UUIDUtils.generateUUID("cfg")); Assert.hasText(applicationUID, "Cannot create ConfigRole: applicationUID should not be empty"); this.applicationUID = applicationUID; lastModificationDate = new Date(); }
From source file:com.iflytek.edu.cloud.frame.utils.ReflectionUtils.java
/** * ?,?DeclaredField.// w ww . java2 s . c o m */ protected static Field getDeclaredField(final Class clazz, final String fieldName) { Assert.notNull(clazz, "clazz?"); Assert.hasText(fieldName, "fieldName"); for (Class superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) { try { return superClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { // Field??,? } } return null; }
From source file:com.orange.cloud.servicebroker.filter.securitygroups.domain.Destination.java
private void setHost(String host) { Assert.hasText(host, String.format("Cannot create connection info. Invalid host : <%s>", host)); this.host = host; }
From source file:org.opencredo.couchdb.core.CouchDbDocumentTemplate.java
/** * Constructs an instance of CouchDbDocumentTemplate with a default database, user, and password for Basic Authentication * //w w w . j ava2 s. c o m * @param defaultDatabaseUrl the default database to connect to */ public CouchDbDocumentTemplate(String defaultDatabaseUrl, String username, String password) { super(username, password, defaultDatabaseUrl); Assert.hasText(defaultDatabaseUrl, "defaultDatabaseUrl must not be empty"); setDefaultDocumentUrl(defaultDatabaseUrl); }
From source file:architecture.ee.jdbc.datasource.DefaultDataSourceFactory.java
public DataSource getDataSource() { String profileTag = "database." + profileName; ApplicationProperties config = repository.getSetupApplicationProperties(); Collection<String> dataSourceProviders = config.getChildrenNames(profileTag); log.debug(CommonLogLocalizer.format("003040", profileName)); if (dataSourceProviders.size() == 0) throw new RuntimeError(CommonLogLocalizer.format("003041", profileName)); for (String dataSourceProvider : dataSourceProviders) { String providerTag = profileTag + "." + dataSourceProvider; if ("jndiDataSourceProvider".equals(dataSourceProvider)) { String jndiNameTag = providerTag + ".jndiName"; String jndiName = config.get(jndiNameTag + ".jndiName"); Assert.hasText(jndiName, CommonLogLocalizer.getMessage("003042")); JndiDataSourceLookup lookup = new JndiDataSourceLookup(); return lookup.getDataSource(jndiName); } else if ("pooledDataSourceProvider".equals(dataSourceProvider)) { String driverClassName = config.get(providerTag + ".driverClassName"); String url = config.get(providerTag + ".url"); String username = config.get(providerTag + ".username"); String password = config.get(providerTag + ".password"); log.debug(CommonLogLocalizer.format("003043", driverClassName, url)); org.apache.commons.dbcp.BasicDataSource dbcp = new org.apache.commons.dbcp.BasicDataSource(); dbcp.setDriverClassName(driverClassName); dbcp.setUrl(url);//from ww w.j a va 2s . c o m dbcp.setUsername(username); dbcp.setPassword(password); String propertiesTag = providerTag + ".connectionProperties"; for (String name : config.getChildrenNames(propertiesTag)) { String value = config.get(propertiesTag + "." + name); log.debug(CommonLogLocalizer.format("003044", name, value)); dbcp.addConnectionProperty(name, value); } return dbcp; } } return null; }
From source file:org.cleverbus.core.common.route.EndpointRegistryImpl.java
/** * Returns {@code true} if specified URI matches specified pattern. * * @param endpointURI the endpoint URI/*from w w w .jav a2 s . c o m*/ * @param pattern pattern * @return {@code true} if specified URI matches at least one of specified patterns otherwise {@code false} */ private boolean filter(String endpointURI, @Nullable Pattern pattern) { Assert.hasText(endpointURI, "the endpointURI must be defined"); if (pattern == null) { return true; } Matcher matcher = pattern.matcher(endpointURI); if (matcher.matches()) { return true; } return false; }