List of usage examples for org.springframework.util Assert hasText
public static void hasText(@Nullable String text, Supplier<String> messageSupplier)
From source file:org.openscada.spring.client.command.DataItemCommand.java
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.connection, "'connection' must not be null"); Assert.hasText(this.itemName, "'itemName' must be set"); }
From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManager.java
@Override public PropertiesConfiguration initConfiguration(final String key, final Class<?> valueType, final String tag) throws IllegalArgumentException, ConfigurationException { Assert.hasText(key, "No key provided !"); if (this.configurationByKey.containsKey(key)) { throw new IllegalArgumentException("Configuration element already initialized for key: " + key + " !"); }/* w ww .j a v a 2 s .co m*/ Assert.notNull(valueType, "No value type provided !"); Assert.hasText(tag, "No tag provided !"); final String propertiesFileName = FilenameUtils.concat(this.configFileDirectory, key + ".properties"); final File propertiesFile = new File(propertiesFileName); final PropertiesConfiguration config = new PropertiesConfiguration(propertiesFile); this.configurationByKey.put(key, config); this.valueTypeByKey.put(key, valueType); this.tagConfigurationKey(key, tag); return config; }
From source file:grails.plugin.cache.redis.GrailsRedisCache.java
/** * Constructor.// w ww . ja va 2 s . com * * @param name cache name * @param prefix * @param cachePrefix */ public GrailsRedisCache(String name, byte[] prefix, RedisTemplate<? extends Object, ? extends Object> template, Long ttl) { Assert.hasText(name, "non-empty cache name is required"); this.name = name; this.template = template; this.prefix = prefix; this.ttl = ttl == null ? NEVER_EXPIRE : ttl.longValue(); StringRedisSerializer stringSerializer = new StringRedisSerializer(); // name of the set holding the keys setName = stringSerializer.serialize(name + "~keys"); cacheLockName = stringSerializer.serialize(name + "~lock"); }
From source file:fr.mby.opa.picsimpl.service.BasicPictureService.java
@Override public Picture createPicture(final String filename, final byte[] contents) throws PictureAlreadyExistsException, IOException, UnsupportedPictureTypeException { Assert.hasText(filename, "No filename supplied !"); Assert.notNull(contents, "No contents supplied !"); Picture picture = null;/*w w w .ja va 2 s .co m*/ if (contents.length > 0) { // Generate picture hash final String uniqueHash = this.generateHash(contents); final Long alreadyExistingPictureId = this.pictureDao.findPictureIdByHash(uniqueHash); if (alreadyExistingPictureId != null) { throw new PictureAlreadyExistsException(filename); } picture = this.pictureFactory.build(filename, contents); picture.setOriginalHash(uniqueHash); picture.setCurrentHash(uniqueHash); } return picture; }
From source file:com.miko.demo.neo4j.model.EntityC.java
public EntityC(String name, BigDecimal value) { Assert.hasText(name, "Name can not be empty"); Assert.isTrue(BigDecimal.ZERO.compareTo(value) < 0, "Value must be greater than zero!"); this.name = name; this.value = value; }
From source file:com.azaptree.services.command.impl.CommandCatalogImpl.java
@Override public synchronized void addCommand(final Command command) { Assert.notNull(command, "command is required"); Assert.hasText(command.getName(), "command.name is required"); if (getCommand(command.getName()) != null) { throw new IllegalArgumentException( String.format("Command names must be unique within a catalog: %s", command.getName())); }/*w w w . j ava2s.com*/ commands = ImmutableMap.<String, org.apache.commons.chain.Command>builder().putAll(commands) .put(command.getName(), command).build(); }
From source file:cat.albirar.framework.sets.impl.SetDefaultImpl.java
/** * {@inheritDoc}//from w w w . ja v a 2 s . c om */ @Override public boolean add(String e) { // Check for valid argument Assert.hasText(e, "The property name is required"); // First check if property exists if (!SetUtils.checkPathForModel(modelRoot, e)) { throw new IllegalArgumentException("The property path '".concat(e).concat("' doesn't exists at model '") .concat(modelRoot.getName()).concat("'")); } return super.add(e); }
From source file:org.zalando.failsafeactuator.service.CircuitBreakerRegistry.java
/** * Will put the {@link CircuitBreaker} into the registry. There is no check which avoids overwriting of identifiers. Therefore be sure that your identifiers * are unique, or you want to overwrite the current {@link CircuitBreaker} which is registered with this identifier. * * @param breaker Which should be added//from w ww. j a va 2 s. com * @param name Which is used to identify the CircuitBreaker */ void registerCircuitBreaker(final CircuitBreaker breaker, final String name) { Assert.hasText(name, "Name for circuit breaker needs to be set"); Assert.notNull(breaker, "Circuit breaker to add, can't be null"); final CircuitBreaker replaced = concurrentBreakerMap.put(name, breaker); Assert.isNull(replaced, String.format(ALREADY_REGISTERED_ERROR, name)); }
From source file:com.azaptree.services.security.domain.config.impl.HashServiceConfig.java
public HashServiceConfig(final String name) { Assert.hasText(name, "name is required"); this.name = name; hashAlgorithmName = "SHA-256"; final SecureRandomNumberGenerator rng = new SecureRandomNumberGenerator(); privateSalt = rng.nextBytes(32).getBytes(); hashIterations = 1024 * 128;/*from w ww . j ava 2 s . com*/ secureRandomNumberGeneratorNextBytesSize = 32; validate(); }
From source file:com.ecsteam.springutils.pattern.controller.PatternServletRequest.java
public PatternServletRequest(String uri) { Assert.hasText(uri, "uri must not be empty"); this.uri = uri; }