本文整理了Java中org.springframework.util.Assert.isNull()
方法的一些代码示例,展示了Assert.isNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.isNull()
方法的具体详情如下:
包路径:org.springframework.util.Assert
类名称:Assert
方法名:isNull
[英]Assert that an object is null
.
Assert.isNull(value);
[中]断言对象为null
Assert.isNull(value);
代码示例来源:origin: spring-projects/spring-framework
/**
* Assert that an object is {@code null}.
* @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)}
*/
@Deprecated
public static void isNull(@Nullable Object object) {
isNull(object, "[Assertion failed] - the object argument must be null");
}
代码示例来源:origin: org.springframework/spring-core
/**
* Assert that an object is {@code null}.
* @deprecated as of 4.3.7, in favor of {@link #isNull(Object, String)}
*/
@Deprecated
public static void isNull(@Nullable Object object) {
isNull(object, "[Assertion failed] - the object argument must be null");
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
if (annotation != null) {
Assert.isNull(annotatedMethod.get(), "found more than one method on target class ["
+ clazz + "] with the annotation type [" + annotationType + "]");
annotatedMethod.set(method);
}
}
});
代码示例来源:origin: spring-projects/spring-retry
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType);
if (annotation != null) {
Assert.isNull(annotatedMethod.get(), "found more than one method on target class ["
+ clazz + "] with the annotation type [" + annotationType + "]");
annotatedMethod.set(method);
}
}
});
代码示例来源:origin: spring-projects/spring-framework
/**
* Configure a base URL to prepend URI templates with. The base URL must
* have a scheme and host but may optionally contain a port and a path.
* The base URL must be fully expanded and encoded which can be done via
* {@link UriComponentsBuilder}.
* @param baseUrl the base URL.
*/
public void setBaseUrl(@Nullable String baseUrl) {
if (baseUrl != null) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString(baseUrl).build();
Assert.hasText(uriComponents.getScheme(), "'baseUrl' must have a scheme");
Assert.hasText(uriComponents.getHost(), "'baseUrl' must have a host");
Assert.isNull(uriComponents.getQuery(), "'baseUrl' cannot have a query");
Assert.isNull(uriComponents.getFragment(), "'baseUrl' cannot have a fragment");
}
this.baseUrl = baseUrl;
}
代码示例来源:origin: spring-projects/spring-security
@Override
public <T extends OAuth2AuthorizedClient> Mono<T> loadAuthorizedClient(String clientRegistrationId,
Authentication authentication, ServerWebExchange serverWebExchange) {
Assert.notNull(clientRegistrationId, "clientRegistrationId cannot be null");
Assert.isNull(serverWebExchange, "serverWebExchange must be null");
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
return Mono.fromSupplier(() -> (T) this.clientRegistrationIdToAuthorizedClient.get(clientRegistrationId));
}
代码示例来源:origin: spring-projects/spring-security
@Override
public Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentication authentication,
ServerWebExchange serverWebExchange) {
Assert.notNull(clientRegistrationId, "clientRegistrationId cannot be null");
Assert.isNull(serverWebExchange, "serverWebExchange " + serverWebExchange + "must be null");
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
return Mono.fromRunnable(() -> {
this.clientRegistrationIdToAuthorizedClient.remove(clientRegistrationId);
});
}
代码示例来源:origin: spring-projects/spring-data-mongodb
private IndexField(String key, @Nullable Direction direction, @Nullable Type type, @Nullable Float weight) {
Assert.hasText(key, "Key must not be null or empty");
if (Type.GEO.equals(type) || Type.TEXT.equals(type)) {
Assert.isNull(direction, "Geo/Text indexes must not have a direction!");
} else {
Assert.notNull(direction, "Default indexes require a direction");
}
this.key = key;
this.direction = direction;
this.type = type == null ? Type.DEFAULT : type;
this.weight = weight == null ? Float.NaN : weight;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void isNullWithMessage() {
Assert.isNull(null, "Bla");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void isNullWithMessageSupplier() {
Assert.isNull(null, () -> "enigma");
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Execute the statement to open the cursor.
*/
@Override
protected void doOpen() throws Exception {
Assert.state(!initialized, "Stream is already initialized. Close before re-opening.");
Assert.isNull(rs, "ResultSet still open! Close before re-opening.");
initializeConnection();
openCursor(con);
initialized = true;
}
代码示例来源:origin: org.springframework/spring-web
/**
* Configure a base URL to prepend URI templates with. The base URL must
* have a scheme and host but may optionally contain a port and a path.
* The base URL must be fully expanded and encoded which can be done via
* {@link UriComponentsBuilder}.
* @param baseUrl the base URL.
*/
public void setBaseUrl(@Nullable String baseUrl) {
if (baseUrl != null) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString(baseUrl).build();
Assert.hasText(uriComponents.getScheme(), "'baseUrl' must have a scheme");
Assert.hasText(uriComponents.getHost(), "'baseUrl' must have a host");
Assert.isNull(uriComponents.getQuery(), "'baseUrl' cannot have a query");
Assert.isNull(uriComponents.getFragment(), "'baseUrl' cannot have a fragment");
}
this.baseUrl = baseUrl;
}
代码示例来源:origin: spring-projects/spring-security
@Override
public Mono<Void> saveAuthorizedClient(
OAuth2AuthorizedClient authorizedClient,
Authentication authentication, ServerWebExchange serverWebExchange) {
Assert.notNull(authorizedClient, "authorizedClient cannot be null");
Assert.isNull(serverWebExchange, "serverWebExchange must be null");
Assert.isTrue(isUnauthenticated(authentication), "The user " + authentication + " should not be authenticated");
return Mono.fromRunnable(() -> {
String clientRegistrationId = authorizedClient.getClientRegistration().getRegistrationId();
this.clientRegistrationIdToAuthorizedClient.put(clientRegistrationId, authorizedClient);
});
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void beginCheckpoint() throws Exception {
org.springframework.util.Assert.isTrue("algorithmPropertyValue1".equals(algorithmPropertyName1), "The value of algorithmPropertyValue1 does not equal algorithmPropertyValue1");
org.springframework.util.Assert.isTrue("algorithmPropertyValue2".equals(algorithmPropertyName2), "The value of algorithmPropertyValue2 does not equal algorithmPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedAlgorithmPropertyValue".equals(annotationNamedProperty), "The annotationNamedAlgorithmPropertyValue does not equal annotationNamedAlgorithmPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void beforeStep() throws Exception {
org.springframework.util.Assert.isTrue("stepListenerPropertyValue1".equals(stepListenerPropertyName1), "The value of stepListenerPropertyValue1 does not equal stepListenerPropertyValue1");
org.springframework.util.Assert.isTrue("stepListenerPropertyValue2".equals(stepListenerPropertyName2), "The value of stepListenerPropertyValue2 does not equal stepListenerPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedStepListenerPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedStepListenerPropertyValue does note equal annotationNamedStepListenerPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public void open(Serializable serializable) throws Exception {
org.springframework.util.Assert.isTrue("writerPropertyValue1".equals(writerPropertyName1), "The value of writerPropertyValue1 does not equal writerPropertyValue1");
org.springframework.util.Assert.isTrue("writerPropertyValue2".equals(writerPropertyName2), "The value of writerPropertyValue2 does not equal writerPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedWriterPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedWriterPropertyValue does not equal annotationNamedWriterPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public Object processItem(Object o) throws Exception {
org.springframework.util.Assert.isTrue("processorPropertyValue1".equals(processorPropertyName1), "The value of processorPropertyValue1 does not equal processorPropertyValue1");
org.springframework.util.Assert.isTrue("processorPropertyValue2".equals(processorPropertyName2), "The value of processorPropertyValue2 does not equal processorPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedProcessorPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedProcessorPropertyValue does not equal annotationNamedProcessorPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "The notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "The notDefinedNamedProperty is not null");
return o;
}
}
代码示例来源:origin: spring-projects/spring-batch
@Override
public String decide(javax.batch.runtime.StepExecution[] executions) throws Exception {
org.springframework.util.Assert.isTrue("deciderPropertyValue1".equals(deciderPropertyName1), "The value of deciderPropertyValue1 does not equal deciderPropertyValue1");
org.springframework.util.Assert.isTrue("deciderPropertyValue2".equals(deciderPropertyName2), "The value of deciderPropertyValue2 does not equal deciderPropertyValue2");
org.springframework.util.Assert.isTrue("annotationNamedDeciderPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedDeciderPropertyValue does not equal annotationNamedDeciderPropertyValue");
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
return "step2";
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void isNullWithNonNullObjectAndNullMessageSupplier() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(equalTo(null));
Assert.isNull("foo", (Supplier<String>) null);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void isNullWithNonNullObjectAndMessageSupplier() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("enigma");
Assert.isNull("foo", () -> "enigma");
}
内容来源于网络,如有侵权,请联系作者删除!