org.springframework.util.Assert.notEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(595)

本文整理了Java中org.springframework.util.Assert.notEmpty()方法的一些代码示例,展示了Assert.notEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.notEmpty()方法的具体详情如下:
包路径:org.springframework.util.Assert
类名称:Assert
方法名:notEmpty

Assert.notEmpty介绍

[英]Assert that a collection has elements; that is, it must not be null and must have at least one element.

Assert.notEmpty(collection, "Collection must have elements");

[中]断言集合具有元素;也就是说,它不能是null,并且必须至少有一个元素

Assert.notEmpty(collection, "Collection must have elements");

代码示例

代码示例来源:origin: spring-projects/spring-framework

@SuppressWarnings("unchecked")
HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters, Log logger) {
  Assert.notNull(responseType, "'responseType' must not be null");
  Assert.notEmpty(messageConverters, "'messageConverters' must not be empty");
  this.responseType = responseType;
  this.responseClass = (responseType instanceof Class ? (Class<T>) responseType : null);
  this.messageConverters = messageConverters;
  this.logger = logger;
}

代码示例来源:origin: spring-projects/spring-framework

public WebMvcStompWebSocketEndpointRegistration(
    String[] paths, WebSocketHandler webSocketHandler, TaskScheduler sockJsTaskScheduler) {
  Assert.notEmpty(paths, "No paths specified");
  Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
  this.paths = paths;
  this.webSocketHandler = webSocketHandler;
  this.sockJsTaskScheduler = sockJsTaskScheduler;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a {@link ResourceHandlerRegistration} instance.
 * @param resourceLoader a resource loader for turning a String location
 * into a {@link Resource}
 * @param pathPatterns one or more resource URL path patterns
 */
public ResourceHandlerRegistration(ResourceLoader resourceLoader, String... pathPatterns) {
  Assert.notNull(resourceLoader, "ResourceLoader is required");
  Assert.notEmpty(pathPatterns, "At least one path pattern is required for resource handling");
  this.resourceLoader = resourceLoader;
  this.pathPatterns = pathPatterns;
}

代码示例来源:origin: spring-projects/spring-framework

public DelegatingWebConnection(WebConnection defaultConnection, List<DelegateWebConnection> connections) {
  Assert.notNull(defaultConnection, "Default WebConnection must not be null");
  Assert.notEmpty(connections, "Connections List must not be empty");
  this.connections = connections;
  this.defaultConnection = defaultConnection;
}

代码示例来源:origin: org.springframework/spring-web

@SuppressWarnings("unchecked")
HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters, Log logger) {
  Assert.notNull(responseType, "'responseType' must not be null");
  Assert.notEmpty(messageConverters, "'messageConverters' must not be empty");
  this.responseType = responseType;
  this.responseClass = (responseType instanceof Class ? (Class<T>) responseType : null);
  this.messageConverters = messageConverters;
  this.logger = logger;
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) {
  Assert.notNull(handler, "WebSocketHandler must not be null");
  Assert.notEmpty(paths, "Paths must not be empty");
  this.handlerMap.put(handler, Arrays.asList(paths));
  return this;
}

代码示例来源:origin: spring-projects/spring-security

public void afterPropertiesSet() throws Exception {
  Assert.notEmpty(this.decisionVoters, "A list of AccessDecisionVoters is required");
  Assert.notNull(this.messages, "A message source must be set");
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Constructor that also accepts a {@link ReactiveAdapterRegistry}.
 * @param messageReaders readers to convert from the request body
 * @param adapterRegistry for adapting to other reactive types from Flux and Mono
 */
protected AbstractMessageReaderArgumentResolver(
    List<HttpMessageReader<?>> messageReaders, ReactiveAdapterRegistry adapterRegistry) {
  super(adapterRegistry);
  Assert.notEmpty(messageReaders, "At least one HttpMessageReader is required");
  Assert.notNull(adapterRegistry, "ReactiveAdapterRegistry is required");
  this.messageReaders = messageReaders;
  this.supportedMediaTypes = messageReaders.stream()
      .flatMap(converter -> converter.getReadableMediaTypes().stream())
      .collect(Collectors.toList());
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(delegates, "The 'delegates' may not be null");
  Assert.notEmpty(delegates, "The 'delegates' may not be empty");
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(validators, "The 'validators' may not be null");
  Assert.notEmpty(validators, "The 'validators' may not be empty");
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(delegates, "The 'delegates' may not be null");
  Assert.notEmpty(delegates, "The 'delegates' may not be empty");
}

代码示例来源:origin: spring-projects/spring-batch

@Override
public void afterPropertiesSet() throws Exception {
  Assert.notNull(this.keys, "The 'keys' property must be provided");
  Assert.notEmpty(this.keys, "The 'keys' property must not be empty");
  Assert.notNull(this.statuses, "The 'statuses' property must be provided");
  Assert.notEmpty(this.statuses, "The 'statuses' property must not be empty");
}

代码示例来源:origin: org.springframework.security/spring-security-core

public void afterPropertiesSet() throws Exception {
  Assert.notEmpty(this.decisionVoters, "A list of AccessDecisionVoters is required");
  Assert.notNull(this.messages, "A message source must be set");
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public ItemsReturnedEvent(Long orderId, Map<Long, Integer> returnedItems) {
  super(orderId);
  Assert.notNull(orderId);
  Assert.notEmpty(returnedItems);
  this.itemsAndQuantitiesReturned = Collections.unmodifiableMap(returnedItems);
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public ItemsFulfilledEvent(Long fulfillmentGroupId, Map<Long, Integer> fulfilled) {
  super(fulfillmentGroupId);
  Assert.notNull(fulfillmentGroupId);
  Assert.notEmpty(fulfilled);
  this.itemsAndQuantitiesFulfilled = Collections.unmodifiableMap(fulfilled);
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public ItemsCancelledEvent(Long fulfillmentGroupId, Map<Long, Integer> cancelledItems) {
  super(fulfillmentGroupId);
  Assert.notNull(fulfillmentGroupId);
  Assert.notEmpty(cancelledItems);
  this.itemsAndQuantitiesCancelled = Collections.unmodifiableMap(cancelledItems);
}

代码示例来源:origin: spring-projects/spring-security

public LdapUserDetails createUserDetails() {
    Person p = (Person) super.createUserDetails();
    Assert.notNull(p.cn, "person.sn cannot be null");
    Assert.notEmpty(p.cn, "person.cn cannot be empty");
    // TODO: Check contents for null entries
    return p;
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Whether this converter should convert messages for which no content type
 * could be resolved through the configured
 * {@link org.springframework.messaging.converter.ContentTypeResolver}.
 * <p>A converter can configured to be strict only when a
 * {@link #setContentTypeResolver contentTypeResolver} is configured and the
 * list of {@link #getSupportedMimeTypes() supportedMimeTypes} is not be empty.
 * <p>When this flag is set to {@code true}, {@link #supportsMimeType(MessageHeaders)}
 * will return {@code false} if the {@link #setContentTypeResolver contentTypeResolver}
 * is not defined or if no content-type header is present.
 */
public void setStrictContentTypeMatch(boolean strictContentTypeMatch) {
  if (strictContentTypeMatch) {
    Assert.notEmpty(getSupportedMimeTypes(), "Strict match requires non-empty list of supported mime types");
    Assert.notNull(getContentTypeResolver(), "Strict match requires ContentTypeResolver");
  }
  this.strictContentTypeMatch = strictContentTypeMatch;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
 * Creates a new {@link FacetOperationBuilder} to append a new facet using {@literal operations}. <br />
 * {@link FacetOperationBuilder} takes a pipeline of {@link AggregationOperation} to categorize documents into a
 * single facet.
 *
 * @param operations must not be {@literal null} or empty.
 * @return
 */
public FacetOperationBuilder and(AggregationOperation... operations) {
  Assert.notNull(operations, "AggregationOperations must not be null!");
  Assert.notEmpty(operations, "AggregationOperations must not be empty!");
  return new FacetOperationBuilder(facets, Arrays.asList(operations));
}

代码示例来源:origin: spring-projects/spring-data-jpa

/**
 * Creates a new JPA {@link Metamodel} based {@link MappingContext}.
 *
 * @param models must not be {@literal null} or empty.
 */
public JpaMetamodelMappingContext(Set<Metamodel> models) {
  Assert.notNull(models, "JPA metamodel must not be null!");
  Assert.notEmpty(models, "At least one JPA metamodel must be present!");
  this.models = new Metamodels(models);
  this.persistenceProvider = PersistenceProvider.fromMetamodel(models.iterator().next());
}

相关文章