List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:com.crossover.trial.weather.domain.IATA.java
public static IATA valueOf(String code) { Assert.hasText(code, "iata code is required"); Assert.isTrue(code.matches("[a-zA-Z]{3}"), "iata must be a 3-letter code"); return new IATA(code); }
From source file:com.sishuok.bigpipe.PageletResult.java
public PageletResult container(String container) { Assert.isTrue(this.isFrameResult == false, "only be not frame result has container"); this.container = container; return this; }
From source file:org.hsweb.web.core.datasource.DatabaseType.java
public static DatabaseType fromJdbcUrl(String url) { if (StringUtils.hasLength(url)) { Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'"); String urlWithoutPrefix = url.substring("jdbc".length()).toLowerCase(); for (DatabaseType driver : values()) { String prefix = ":" + driver.name().toLowerCase() + ":"; if (driver != unknown && urlWithoutPrefix.startsWith(prefix)) { return driver; }//from ww w . ja v a 2 s .c o m } } return unknown; }
From source file:com.nortal.petit.orm.statement.DeleteStatement.java
public DeleteStatement(JdbcOperations jdbcTemplate, StatementBuilder statementBuilder, B... beans) { Assert.isTrue(ArrayUtils.isNotEmpty(beans), "InsertStatement.construct: beans are mandatory"); this.beans = Arrays.asList(beans); super.init(jdbcTemplate, statementBuilder, (Class<B>) beans[0].getClass()); }
From source file:example.springdata.cassandra.util.CassandraResource.java
CassandraResource(String host, int port) { Assert.hasText(host, "Host must not be null or empty!"); Assert.isTrue(port >= 0 && port <= 65535, "Port must be in the range of 0..65535!"); this.host = host; this.port = port; }
From source file:com.oreilly.springdata.querydsl.core.EmailAddress.java
public EmailAddress(String emailAddress) { Assert.isTrue(isValid(emailAddress), "Invalid email address!"); this.value = emailAddress; }
From source file:org.jasig.cas.ticket.support.MultiTimeUseOrTimeoutExpirationPolicy.java
public MultiTimeUseOrTimeoutExpirationPolicy(final int numberOfUses, final long timeToKillInMilliSeconds) { this.timeToKillInMilliSeconds = timeToKillInMilliSeconds; this.numberOfUses = numberOfUses; Assert.isTrue(this.numberOfUses > 0, "numberOfUsers must be greater than 0."); Assert.isTrue(this.timeToKillInMilliSeconds > 0, "timeToKillInMilliseconds must be greater than 0."); }
From source file:com.orange.clara.cloud.cf.servicebroker.log.domain.SyslogDrainUrl.java
private void setValue(String value) { Assert.hasText(value, "Invalid syslog drain url <" + value + ">. Syslog drain url should not be empty."); Assert.isTrue(value.startsWith(SYSLOG_SCHEME), "Invalid syslog drain url <" + value + ">. Syslog drain url should start with " + SYSLOG_SCHEME + "."); this.value = value; }
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 ww.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.fns.grivet.query.Constraint.java
public Constraint(String[] constraintParts) { Assert.notEmpty(constraintParts, "Constraint parts must not be null or empty!"); Assert.isTrue(constraintParts.length >= 3, "Must have 3 or more constraint parts!"); attributeName = constraintParts[0];/*from ww w . ja v a 2 s.co m*/ operator = Operator.fromValue(constraintParts[1]); values = constraintParts[2].split("\\s*,\\s*"); if (operator.equals(Operator.BETWEEN)) { Assert.isTrue(values.length == 2, "Operator [between] requires two values!"); } if (constraintParts.length == 4) { if (constraintParts[3] == null) { conjunction = null; } else { conjunction = Conjunction.fromValue(constraintParts[3]); } } else { conjunction = null; } }