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

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

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

Assert.notNull介绍

[英]Assert that an object is not null .

Assert.notNull(clazz);

[中]断言对象不是null

Assert.notNull(clazz);

代码示例

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

/**
 * Set the {@link BeanWiringInfoResolver} to use.
 * <p>The default behavior is to look for a bean with the same name as the class.
 * As an alternative, consider using annotation-driven bean wiring.
 * @see ClassNameBeanWiringInfoResolver
 * @see org.springframework.beans.factory.annotation.AnnotationBeanWiringInfoResolver
 */
public void setBeanWiringInfoResolver(BeanWiringInfoResolver beanWiringInfoResolver) {
  Assert.notNull(beanWiringInfoResolver, "BeanWiringInfoResolver must not be null");
  this.beanWiringInfoResolver = beanWiringInfoResolver;
}

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

/**
 * A constructor accepting a {@link WebSocketServerFactory}.
 * @param factory the pre-configured factory to use
 */
public JettyRequestUpgradeStrategy(WebSocketServerFactory factory) {
  Assert.notNull(factory, "WebSocketServerFactory must not be null");
  this.factory = factory;
}

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

/**
 * Construct a new ReplaceOverride.
 * @param methodName the name of the method to override
 * @param methodReplacerBeanName the bean name of the MethodReplacer
 */
public ReplaceOverride(String methodName, String methodReplacerBeanName) {
  super(methodName);
  Assert.notNull(methodName, "Method replacer bean name must not be null");
  this.methodReplacerBeanName = methodReplacerBeanName;
}

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

/**
 * Construct a qualifier to match against an annotation of the
 * given type name.
 * <p>The type name may match the fully-qualified class name of
 * the annotation or the short class name (without the package).
 * @param typeName the name of the annotation type
 */
public AutowireCandidateQualifier(String typeName) {
  Assert.notNull(typeName, "Type name must not be null");
  this.typeName = typeName;
}

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

/**
 * Constructor accepting an existing {@link WebSocketContainer} instance.
 * <p>For XML configuration, see {@link WebSocketContainerFactoryBean}. For Java
 * configuration, use {@code ContainerProvider.getWebSocketContainer()} to obtain
 * the {@code WebSocketContainer} instance.
 */
public StandardWebSocketClient(WebSocketContainer webSocketContainer) {
  Assert.notNull(webSocketContainer, "WebSocketContainer must not be null");
  this.webSocketContainer = webSocketContainer;
}

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

public JettyWebSocketHandlerAdapter(WebSocketHandler webSocketHandler, JettyWebSocketSession wsSession) {
  Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
  Assert.notNull(wsSession, "WebSocketSession must not be null");
  this.webSocketHandler = webSocketHandler;
  this.wsSession = wsSession;
}

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

/**
 * A scheduler instance to use for scheduling SockJS heart-beats.
 */
public SockJsServiceRegistration setTaskScheduler(TaskScheduler scheduler) {
  Assert.notNull(scheduler, "TaskScheduler is required");
  this.scheduler = scheduler;
  return this;
}

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

public EndpointConnectionManager(Endpoint endpoint, String uriTemplate, Object... uriVariables) {
  super(uriTemplate, uriVariables);
  Assert.notNull(endpoint, "endpoint must not be null");
  this.endpoint = endpoint;
  this.endpointProvider = null;
}

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

@Override
public void addEmbeddedValueResolver(StringValueResolver valueResolver) {
  Assert.notNull(valueResolver, "StringValueResolver must not be null");
  this.embeddedValueResolvers.add(valueResolver);
}

代码示例来源: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

@Override
public boolean containsBeanDefinition(String beanName) {
  Assert.notNull(beanName, "Bean name must not be null");
  return this.beanDefinitionMap.containsKey(beanName);
}

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

/**
 * Create a new {@code DefaultNamespaceHandlerResolver} using the
 * supplied mapping file location.
 * @param classLoader the {@link ClassLoader} instance used to load mapping resources
 * may be {@code null}, in which case the thread context ClassLoader will be used)
 * @param handlerMappingsLocation the mapping file location
 */
public DefaultNamespaceHandlerResolver(@Nullable ClassLoader classLoader, String handlerMappingsLocation) {
  Assert.notNull(handlerMappingsLocation, "Handler mappings location must not be null");
  this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
  this.handlerMappingsLocation = handlerMappingsLocation;
}

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

@Override
@Nullable
public Scope getRegisteredScope(String scopeName) {
  Assert.notNull(scopeName, "Scope identifier must not be null");
  return this.scopes.get(scopeName);
}

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

protected ServerContainer getContainer(HttpServletRequest request) {
  ServletContext servletContext = request.getServletContext();
  String attrName = "javax.websocket.server.ServerContainer";
  ServerContainer container = (ServerContainer) servletContext.getAttribute(attrName);
  Assert.notNull(container, "No 'javax.websocket.server.ServerContainer' ServletContext attribute. " +
      "Are you running in a Servlet container that supports JSR-356?");
  return container;
}

代码示例来源: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 EndpointConnectionManager(Class<? extends Endpoint> endpointClass, String uriTemplate, Object... uriVars) {
  super(uriTemplate, uriVars);
  Assert.notNull(endpointClass, "endpointClass must not be null");
  this.endpoint = null;
  this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass);
}

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

@Override
public int loadBeanDefinitions(String... locations) throws BeanDefinitionStoreException {
  Assert.notNull(locations, "Location array must not be null");
  int count = 0;
  for (String location : locations) {
    count += loadBeanDefinitions(location);
  }
  return count;
}

代码示例来源: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-framework

@Override
public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
    String uriTemplate, Object... uriVars) {
  Assert.notNull(uriTemplate, "'uriTemplate' must not be null");
  URI uri = UriComponentsBuilder.fromUriString(uriTemplate).buildAndExpand(uriVars).encode().toUri();
  return doHandshake(webSocketHandler, null, uri);
}

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

@Override
public ListenableFuture<WebSocketSession> doHandshake(
    WebSocketHandler handler, String uriTemplate, Object... uriVars) {
  Assert.notNull(uriTemplate, "uriTemplate must not be null");
  URI uri = UriComponentsBuilder.fromUriString(uriTemplate).buildAndExpand(uriVars).encode().toUri();
  return doHandshake(handler, null, uri);
}

相关文章