List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:example.app.geode.cache.loader.FactorialsCacheLoader.java
@Override public Long load(LoaderHelper<Long, Long> helper) throws CacheLoaderException { Long key = helper.getKey();//from w w w .ja va 2 s .co m Assert.isTrue(key >= 0L, String.format("Number [%d] must be greater than equal to 0", key)); if (key <= 2L) { return (key < 2L ? 1L : 2L); } long result = key; while (--key > 1L) { result *= key; } return result; }
From source file:rasmantuta.testutil.PopulatedTemporaryFolder.java
private String[] createActualResources() { // Get annotated Resources AdditionalResources additionalResources = method.getAnnotation(AdditionalResources.class); OverrideResources overrideResources = method.getAnnotation(OverrideResources.class); Assert.isTrue((null == additionalResources || null == overrideResources), "Both @AdditionalResources and @OverrideResources can not be used on same method."); String[] res;/*w ww. j a v a 2 s . c om*/ if (null != additionalResources) { res = (String[]) ArrayUtils.addAll(resources, additionalResources.value()); } else if (null != overrideResources) { res = overrideResources.value(); } else { res = resources; } return res; }
From source file:org.sharetask.security.WorkspaceOwnerPermission.java
@Override public boolean isAllowed(final Authentication authentication, final Object targetDomainObject) { boolean result; Assert.isTrue(isAuthenticated(authentication), "UserAuthentication is not authenticated!"); Assert.isTrue(targetDomainObject instanceof Long); final Long workspaceId = (Long) targetDomainObject; final String userName = authentication.getName(); final Workspace workspace = this.workspaceRepository.read(workspaceId); if (isWorkspaceOwner(workspace, userName)) { result = true;//from w w w . j a v a 2 s . c o m } else { result = false; } return result; }
From source file:biz.c24.io.spring.integration.config.XPathRouterParser.java
@Override protected BeanDefinition doParseRouter(Element element, ParserContext parserContext) { BeanDefinitionBuilder xpathRouterBuilder = BeanDefinitionBuilder .genericBeanDefinition("biz.c24.io.spring.integration.router.C24XPathRouter"); String expression = element.getAttribute("xpath-statement"); String expressionRef = element.getAttribute("xpath-statement-ref"); boolean hasRef = StringUtils.hasText(expressionRef); Assert.isTrue(hasRef ^ StringUtils.hasText(expression), "Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required."); if (hasRef) { xpathRouterBuilder.addConstructorArgReference(expressionRef); } else {/* w ww . ja va2s . c o m*/ xpathRouterBuilder.addConstructorArgValue(expression); } return xpathRouterBuilder.getBeanDefinition(); }
From source file:org.obiba.onyx.core.identifier.impl.randomincrement.RandomIncrementIdentifierSequence.java
public void startSequence(String prefix, long lastIdentifier) { Assert.isTrue(!sequenceStateExists(), "called startSequence with existing IdentifierSequenceState"); createSequenceState(prefix, lastIdentifier); }
From source file:com.jaxio.celerio.configuration.database.IndexHolder.java
public void addIndex(Index index) { if (indexes.isEmpty()) { name = index.getIndexName();//from w ww . j ava2s. com isNonUnique = index.isNonUnique(); } else { Assert.isTrue(name.equalsIgnoreCase(index.getIndexName()), "The indexName must be the same"); Assert.isTrue(!(isNonUnique ^ index.isNonUnique()), "Indexes must have same non unique value"); } indexes.add(index); }
From source file:fr.mby.utils.common.prefs.StreamPreferences.java
/** * @param parent//from w ww.j av a2 s. com * @param name */ public StreamPreferences(final AbstractPreferences parent, final String name, final InputStream inputStream, final OutputStream outputStream) { super(parent, name); Assert.notNull(inputStream, "No InputStream provided !"); Assert.notNull(outputStream, "No OutputStream provided !"); Assert.isTrue(inputStream.markSupported(), "The provided InputStream does not support mark !"); this.inputStreamStorage = inputStream; this.outputStreamStorage = outputStream; this.prefsStorage = new ConcurrentHashMap<String, String>(); this.childrenStorage = new ConcurrentHashMap<String, AbstractPreferences>(); }
From source file:org.socialsignin.spring.data.dynamodb.query.ScanExpressionCountQuery.java
public void assertScanCountEnabled(boolean scanCountEnabled) { if (pageQuery) { Assert.isTrue(scanCountEnabled, "Scanning for the total counts for this query is not enabled. " + "To enable annotate your repository method with @EnableScanCount, or " + "enable scanning for all repository methods by annotating your repository interface with @EnableScanCount. This total count is required to serve this Page query - if total counts are not desired an alternative approach could be to replace the Page query with a Slice query "); } else {/*from w w w.j a v a 2 s.co m*/ Assert.isTrue(scanCountEnabled, "Scanning for counts for this query is not enabled. " + "To enable annotate your repository method with @EnableScanCount, or " + "enable scanning for all repository methods by annotating your repository interface with @EnableScanCount"); } }
From source file:biz.c24.io.spring.integration.config.XPathTransformerParser.java
@Override protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String expression = element.getAttribute("xpath-statement"); String expressionRef = element.getAttribute("xpath-statement-ref"); boolean hasRef = StringUtils.hasText(expressionRef); Assert.isTrue(hasRef ^ StringUtils.hasText(expression), "Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required."); if (hasRef) { builder.addConstructorArgReference(expressionRef); } else {/*from w w w .ja v a 2 s .c o m*/ builder.addConstructorArgValue(expression); } IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "evaluation-type"); }
From source file:com.nortal.petit.orm.statement.UpdateStatement.java
public UpdateStatement(JdbcOperations jdbcTemplate, StatementBuilder statementBuilder, Class<B> beanClass) { Assert.isTrue(beanClass != null, "UpdateStatement.construct: beanClass is mandatory"); super.init(jdbcTemplate, statementBuilder, beanClass); }