本文整理了Java中org.springframework.util.Assert.state()
方法的一些代码示例,展示了Assert.state()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.state()
方法的具体详情如下:
包路径:org.springframework.util.Assert
类名称:Assert
方法名:state
[英]Assert a boolean expression, throwing IllegalStateExceptionif the test result is false
.
Call #isTrue(boolean) if you wish to throw IllegalArgumentException on an assertion failure.
Assert.state(id == null);
[中]断言一个布尔表达式,如果测试结果为false
,则抛出IllegalStateException。
如果希望在断言失败时抛出IllegalArgumentException,请调用#isTrue(布尔值)。
Assert.state(id == null);
代码示例来源:origin: spring-projects/spring-framework
/**
* Expose the singleton instance (for access through the 'early singleton' proxy).
* @return the singleton instance that this FactoryBean holds
* @throws IllegalStateException if the singleton instance is not initialized
*/
@Nullable
private T getSingletonInstance() throws IllegalStateException {
Assert.state(this.initialized, "Singleton instance not initialized yet");
return this.singletonInstance;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void setApplicationContext(@Nullable ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
if (applicationContext != null) {
Assert.state(!applicationContext.containsBean("mvcContentNegotiationManager"),
"The Java/XML config for Spring MVC and Spring WebFlux cannot both be enabled, " +
"e.g. via @EnableWebMvc and @EnableWebFlux, in the same application.");
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@SuppressWarnings("unchecked")
protected RowMapper<T> newRowMapper(@Nullable Object[] parameters, @Nullable Map<?, ?> context) {
if (this.rowMapper != null) {
return this.rowMapper;
}
else {
Assert.state(this.rowMapperClass != null, "No RowMapper set");
return BeanUtils.instantiateClass(this.rowMapperClass);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Nullable
public String getIncludedUrl() {
int count = this.includedUrls.size();
Assert.state(count <= 1,
() -> "More than 1 URL included - check getIncludedUrls instead: " + this.includedUrls);
return (count == 1 ? this.includedUrls.get(0) : null);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@SuppressWarnings("unchecked")
public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue)
throws AccessException {
Assert.state(target instanceof Map, "Target must be a Map");
Map<Object, Object> map = (Map<Object, Object>) target;
map.put(name, newValue);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Destination resolveDestinationName(@Nullable Session session, String destinationName, boolean pubSubDomain)
throws JMSException {
Assert.state(this.beanFactory != null, "BeanFactory is required");
try {
return this.beanFactory.getBean(destinationName, Destination.class);
}
catch (BeansException ex) {
throw new DestinationResolutionException(
"Failed to look up Destination bean with name '" + destinationName + "'", ex);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void doWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener)
throws WorkException {
Assert.state(this.syncTaskExecutor != null, "No 'syncTaskExecutor' set");
executeWork(this.syncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
代码示例来源:origin: spring-projects/spring-framework
private void execute(@Nullable DatabasePopulator populator) {
Assert.state(this.dataSource != null, "DataSource must be set");
if (this.enabled && populator != null) {
DatabasePopulatorUtils.execute(populator, this.dataSource);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Access the given target object by resolving the given property name against the given target
* environment.
*/
@Override
public TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException {
Assert.state(target instanceof Environment, "Target must be of type Environment");
return new TypedValue(((Environment) target).getProperty(name));
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public AsyncContext startAsync(ServletRequest request, @Nullable ServletResponse response) {
Assert.state(this.asyncSupported, "Async not supported");
this.asyncStarted = true;
this.asyncContext = new MockAsyncContext(request, response);
return this.asyncContext;
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException {
Assert.state(target instanceof BeanFactory, "Target must be of type BeanFactory");
return new TypedValue(((BeanFactory) target).getBean(name));
}
代码示例来源:origin: spring-projects/spring-framework
@SuppressWarnings("unchecked")
@Nullable
public List<Object> getConstantValue() {
Assert.state(this.constant != null, "No constant");
return (List<Object>) this.constant.getValue();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, @Nullable WebDataBinderFactory binderFactory) throws Exception {
Assert.state(mavContainer != null, "ModelAndViewContainer is required for model exposure");
return mavContainer.getModel();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return a CallableStatementCreator to perform an operation
* with this parameters.
* @param inParams parameters. May be {@code null}.
*/
protected CallableStatementCreator newCallableStatementCreator(@Nullable Map<String, ?> inParams) {
Assert.state(this.callableStatementFactory != null, "No CallableStatementFactory available");
return this.callableStatementFactory.newCallableStatementCreator(inParams);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
}
代码示例来源:origin: spring-projects/spring-framework
@SuppressWarnings("unchecked")
@Nullable
public Map<Object, Object> getConstantValue() {
Assert.state(this.constant != null, "No constant");
return (Map<Object, Object>) this.constant.getValue();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return a PreparedStatementCreator to perform an operation
* with the given parameters.
* @param params the parameter array (may be {@code null})
*/
protected final PreparedStatementCreator newPreparedStatementCreator(@Nullable Object[] params) {
Assert.state(this.preparedStatementFactory != null, "No PreparedStatementFactory available");
return this.preparedStatementFactory.newPreparedStatementCreator(params);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Overloaded variant of {@link #send(Object)} that also accepts a MediaType
* hint for how to serialize the given Object.
* @param object the object to write
* @param mediaType a MediaType hint for selecting an HttpMessageConverter
* @throws IOException raised when an I/O error occurs
* @throws java.lang.IllegalStateException wraps any other errors
*/
public synchronized void send(Object object, @Nullable MediaType mediaType) throws IOException {
Assert.state(!this.complete, "ResponseBodyEmitter is already set complete");
sendInternal(object, mediaType);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Nullable
public URI getUri() {
Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized");
return this.webSocketSession.getUri();
}
内容来源于网络,如有侵权,请联系作者删除!