List of usage examples for org.springframework.util Assert state
public static void state(boolean expression, Supplier<String> messageSupplier)
From source file:org.codehaus.grepo.query.jpa.repository.DefaultJpaRepository.java
/** * @return Returns the entity manager./*from w w w . j av a2 s . c o m*/ * @throws IllegalStateException in case factory is null */ protected EntityManager createEntityManager() throws IllegalStateException { Assert.state(getEntityManagerFactory() != null, "No EntityManagerFactory specified"); return (hasJpaProperties() ? getEntityManagerFactory().createEntityManager(getJpaPropertyMap()) : getEntityManagerFactory().createEntityManager()); }
From source file:de.escalon.hypermedia.spring.AffordanceBuilderFactory.java
private boolean containsCollection(Type genericReturnType) { final boolean ret; if (genericReturnType instanceof ParameterizedType) { ParameterizedType t = (ParameterizedType) genericReturnType; Type rawType = t.getRawType(); Assert.state(rawType instanceof Class<?>, "raw type is not a Class: " + rawType.toString()); Class<?> cls = (Class<?>) rawType; if (HttpEntity.class.isAssignableFrom(cls)) { Type[] typeArguments = t.getActualTypeArguments(); ret = containsCollection(typeArguments[0]); } else if (Resources.class.isAssignableFrom(cls) || Collection.class.isAssignableFrom(cls)) { ret = true;/*from w ww . java 2 s. com*/ } else { ret = false; } } else if (genericReturnType instanceof GenericArrayType) { ret = true; } else if (genericReturnType instanceof WildcardType) { WildcardType t = (WildcardType) genericReturnType; ret = containsCollection(getBound(t.getLowerBounds())) || containsCollection(getBound(t.getUpperBounds())); } else if (genericReturnType instanceof TypeVariable) { ret = false; } else if (genericReturnType instanceof Class) { Class<?> cls = (Class<?>) genericReturnType; ret = Resources.class.isAssignableFrom(cls) || Collection.class.isAssignableFrom(cls); } else { ret = false; } return ret; }
From source file:com.riptide.plugins.jenkins.cloudfront.utils.AntPathMatcher.java
public Map<String, String> extractUriTemplateVariables(String pattern, String path) { Map<String, String> variables = new LinkedHashMap<String, String>(); boolean result = doMatch(pattern, path, true, variables); Assert.state(result, "Pattern \"" + pattern + "\" is not a match for \"" + path + "\""); return variables; }
From source file:com.github.springtestdbunit.bean.DatabaseConfigBean.java
/** * Set a property to the underlying data config. * @param propertyName the name of the property * @param dataConfigPropertyName the data config property name * @param value the value to set/*from w ww . j a v a2 s. c o m*/ */ private void setProperty(String propertyName, String dataConfigPropertyName, Object value) { ConfigProperty configProperty = CONFIG_PROPERTIES.get(dataConfigPropertyName); Assert.state(configProperty != null, "Unsupported config property " + dataConfigPropertyName + " for " + propertyName); if (!configProperty.isNullable()) { Assert.notNull(value, propertyName + " cannot be null"); } if (value != null) { Assert.isInstanceOf(configProperty.getPropertyType(), value, "Unable to set " + propertyName + " "); } this.databaseConfig.setProperty(dataConfigPropertyName, value); }
From source file:egovframework.rte.bat.core.item.file.EgovPartitionFlatFileItemWriter.java
/** * ?? OutputState ? ? /*from w w w.j a va2s . c o m*/ * @return */ private OutputState getOutputState() { if (state == null) { File file; try { file = resource.getFile(); } catch (IOException e) { throw new ItemStreamException("Could not convert resource to file: [" + resource + "]", e); } Assert.state(!file.exists() || file.canWrite(), "Resource is not writable: [" + resource + "]"); state = new OutputState(); state.setDeleteIfExists(shouldDeleteIfExists); state.setAppendAllowed(append); state.setEncoding(encoding); } return (OutputState) state; }
From source file:org.kurento.rabbitmq.RabbitTemplate.java
public void setConfirmCallback(ConfirmCallback confirmCallback) { Assert.state(this.confirmCallback == null || this.confirmCallback == confirmCallback, "Only one ConfirmCallback is supported by each RabbitTemplate"); this.confirmCallback = confirmCallback; }
From source file:org.kurento.rabbitmq.RabbitTemplate.java
public void setReturnCallback(ReturnCallback returnCallback) { Assert.state(this.returnCallback == null || this.returnCallback == returnCallback, "Only one ReturnCallback is supported by each RabbitTemplate"); this.returnCallback = returnCallback; }
From source file:org.cleverbus.api.route.AbstractBasicRoute.java
/** * Returns bean by its type from registry. * * @param type the type of the registered bean * @return bean of specified type/*from ww w.ja va 2 s.co m*/ */ protected final <T> T getBean(Class<T> type) { Set<T> beans = getContext().getRegistry().findByType(type); Assert.state(beans.size() == 1, "there is more beans of type " + type); return beans.iterator().next(); }
From source file:com.github.hateoas.forms.spring.AffordanceBuilder.java
/** * Copy of {@link ServletUriComponentsBuilder#getCurrentRequest()} until SPR-10110 gets fixed. * * @return request// w ww. j a v a 2s. c om */ private static HttpServletRequest getCurrentRequest() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); Assert.state(requestAttributes != null, "Could not find current request via RequestContextHolder"); Assert.isInstanceOf(ServletRequestAttributes.class, requestAttributes); HttpServletRequest servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest(); Assert.state(servletRequest != null, "Could not find current HttpServletRequest"); return servletRequest; }
From source file:org.opennms.web.controller.ksc.AscoTlcCustomViewController.java
/** * <p>afterPropertiesSet</p> * * @throws java.lang.Exception if any./*from w w w . j av a 2 s .c o m*/ */ public void afterPropertiesSet() throws Exception { Assert.state(m_kscReportFactory != null, "property kscReportFactory must be set"); Assert.state(m_kscReportService != null, "property kscReportService must be set"); Assert.state(m_resourceService != null, "property resourceService must be set"); Assert.state(m_defaultGraphsPerLine != 0, "property defaultGraphsPerLine must be set"); m_executor = Executors.newSingleThreadExecutor(); }