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

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

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

Assert.hasText介绍

[英]Assert that the given String has valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Assert.hasText(name, "'name' must not be empty");

[中]断言给定字符串具有有效的文本内容;也就是说,它不能是null,并且必须至少包含一个非空白字符

Assert.hasText(name, "'name' must not be empty");

代码示例

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

/**
 * Create an instance with a matching pattern.
 * @param matchingPattern the matching pattern, possibly not the same as the
 * input pattern, e.g. inputPattern="/foo" and matchingPattern="/foo/".
 * @param lookupPath the lookup path extracted from the request
 * @param pathMatcher the PathMatcher used
 */
public RequestMatchResult(String matchingPattern, String lookupPath, PathMatcher pathMatcher) {
  Assert.hasText(matchingPattern, "'matchingPattern' is required");
  Assert.hasText(lookupPath, "'lookupPath' is required");
  Assert.notNull(pathMatcher, "'pathMatcher' is required");
  this.matchingPattern = matchingPattern;
  this.lookupPath = lookupPath;
  this.pathMatcher = pathMatcher;
}

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

/**
 * Constructor with a path and an {@code javax.websocket.Endpoint}.
 * @param path the endpoint path
 * @param endpoint the endpoint instance
 */
public DefaultServerEndpointConfig(String path, Endpoint endpoint) {
  Assert.hasText(path, "path must not be empty");
  Assert.notNull(endpoint, "endpoint must not be null");
  this.path = path;
  this.endpoint = endpoint;
}

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

/**
 * Create a new {@code PropertySource} with the given name and source object.
 */
public PropertySource(String name, T source) {
  Assert.hasText(name, "Property source name must contain at least one character");
  Assert.notNull(source, "Property source must not be null");
  this.name = name;
  this.source = source;
}

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

/**
 * Creates a new instance of the {@link DefaultScopedObject} class.
 * @param beanFactory the {@link ConfigurableBeanFactory} that holds the scoped target object
 * @param targetBeanName the name of the target bean
 */
public DefaultScopedObject(ConfigurableBeanFactory beanFactory, String targetBeanName) {
  Assert.notNull(beanFactory, "BeanFactory must not be null");
  Assert.hasText(targetBeanName, "'targetBeanName' must not be empty");
  this.beanFactory = beanFactory;
  this.targetBeanName = targetBeanName;
}

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

/**
 * Create a new {@link ServerEndpointRegistration} instance from an
 * {@code javax.websocket.Endpoint} instance.
 * @param path the endpoint path
 * @param endpoint the endpoint instance
 */
public ServerEndpointRegistration(String path, Endpoint endpoint) {
  Assert.hasText(path, "Path must not be empty");
  Assert.notNull(endpoint, "Endpoint must not be null");
  this.path = path;
  this.endpoint = endpoint;
  this.endpointProvider = null;
}

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

@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
    throws BeanDefinitionStoreException {
  Assert.hasText(beanName, "'beanName' must not be empty");
  Assert.notNull(beanDefinition, "BeanDefinition must not be null");
  this.beanDefinitionMap.put(beanName, beanDefinition);
}

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

public LocalSimpSubscription(String id, String destination, LocalSimpSession session) {
  Assert.notNull(id, "Id must not be null");
  Assert.hasText(destination, "Destination must not be empty");
  Assert.notNull(session, "Session must not be null");
  this.id = id;
  this.destination = destination;
  this.session = session;
}

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

/**
 * Constructor.
 * @param userRegistry the registry with local and remote user registry information
 * @param brokerTemplate template for broadcasting local registry information
 * @param broadcastDestination the destination to broadcast to
 * @param scheduler the task scheduler to use
 */
public UserRegistryMessageHandler(MultiServerUserRegistry userRegistry,
    SimpMessagingTemplate brokerTemplate, String broadcastDestination, TaskScheduler scheduler) {
  Assert.notNull(userRegistry, "'userRegistry' is required");
  Assert.notNull(brokerTemplate, "'brokerTemplate' is required");
  Assert.hasText(broadcastDestination, "'broadcastDestination' is required");
  Assert.notNull(scheduler, "'scheduler' is required");
  this.userRegistry = userRegistry;
  this.brokerTemplate = brokerTemplate;
  this.broadcastDestination = broadcastDestination;
  this.scheduler = scheduler;
}

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

/**
 * Create a new {@code PropertySource} with the given name and source object.
 */
public PropertySource(String name, T source) {
  Assert.hasText(name, "Property source name must contain at least one character");
  Assert.notNull(source, "Property source must not be null");
  this.name = name;
  this.source = source;
}

代码示例来源:origin: codecentric/spring-boot-admin

protected InstanceEvent(InstanceId instance, long version, String type, Instant timestamp) {
    Assert.notNull(instance, "'instance' must not be null");
    Assert.notNull(timestamp, "'timestamp' must not be null");
    Assert.hasText(type, "'type' must not be empty");
    this.instance = instance;
    this.version = version;
    this.timestamp = timestamp;
    this.type = type;
  }
}

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

public DefaultToken(String key, long keyCreationTime, String extendedInformation) {
  Assert.hasText(key, "Key required");
  Assert.notNull(extendedInformation, "Extended information cannot be null");
  this.key = key;
  this.keyCreationTime = keyCreationTime;
  this.extendedInformation = extendedInformation;
}

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

public ObjectIdentityImpl(String type, Serializable identifier) {
  Assert.hasText(type, "Type required");
  Assert.notNull(identifier, "identifier required");
  this.identifier = identifier;
  this.type = type;
}

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

/**
 * Create a new {@link ServerEndpointRegistration} instance from an
 * {@code javax.websocket.Endpoint} class.
 * @param path the endpoint path
 * @param endpointClass the endpoint class
 */
public ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass) {
  Assert.hasText(path, "Path must not be empty");
  Assert.notNull(endpointClass, "Endpoint Class must not be null");
  this.path = path;
  this.endpoint = null;
  this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
}

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

@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
    throws BeanDefinitionStoreException {
  Assert.hasText(beanName, "'beanName' must not be empty");
  Assert.notNull(beanDefinition, "BeanDefinition must not be null");
  this.beanDefinitionMap.put(beanName, beanDefinition);
}

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

public void afterPropertiesSet() throws Exception {
    Assert.hasText(serverSecret, "Server secret required");
    Assert.notNull(serverInteger, "Server integer required");
    Assert.notNull(secureRandom, "SecureRandom instance required");
  }
}

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

public SessionInformation(Object principal, String sessionId, Date lastRequest) {
  Assert.notNull(principal, "Principal required");
  Assert.hasText(sessionId, "SessionId required");
  Assert.notNull(lastRequest, "LastRequest required");
  this.principal = principal;
  this.sessionId = sessionId;
  this.lastRequest = lastRequest;
}

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

private void validateAuthorities(Collection<? extends GrantedAuthority> authorities) {
    Assert.notNull(authorities, "Authorities list must not be null");

    for (GrantedAuthority authority : authorities) {
      Assert.notNull(authority, "Authorities list contains a null entry");
      Assert.hasText(authority.getAuthority(),
          "getAuthority() method must return a non-empty string");
    }
  }
}

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

public AbstractAclProvider(AclService aclService, String processConfigAttribute,
    List<Permission> requirePermission) {
  Assert.hasText(processConfigAttribute, "A processConfigAttribute is mandatory");
  Assert.notNull(aclService, "An AclService is mandatory");
  if (requirePermission == null || requirePermission.isEmpty()) {
    throw new IllegalArgumentException(
        "One or more requirePermission entries is mandatory");
  }
  this.aclService = aclService;
  this.processConfigAttribute = processConfigAttribute;
  this.requirePermission = requirePermission;
}

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

public void afterPropertiesSet() throws Exception {
  Assert.notNull(this.authenticationUserDetailsService,
      "An authenticationUserDetailsService must be set");
  Assert.notNull(this.ticketValidator, "A ticketValidator must be set");
  Assert.notNull(this.statelessTicketCache, "A statelessTicketCache must be set");
  Assert.hasText(
      this.key,
      "A Key is required so CasAuthenticationProvider can identify tokens it previously authenticated");
  Assert.notNull(this.messages, "A message source must be set");
}

代码示例来源:origin: alibaba/canal

protected void checkInfo(StoreInfo info) {
  Assert.notNull(info);
  Assert.hasText(info.getStoreName());
}

相关文章