Example usage for org.springframework.util Assert noNullElements

List of usage examples for org.springframework.util Assert noNullElements

Introduction

In this page you can find the example usage for org.springframework.util Assert noNullElements.

Prototype

public static void noNullElements(@Nullable Collection<?> collection, Supplier<String> messageSupplier) 

Source Link

Document

Assert that a collection contains no null elements.

Usage

From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java

/**
 * Add queue(s) to this container's list of queues.
 * @param queues The queue(s) to add.//from   ww  w  .  ja  v a 2s  .  c o m
 */
public void addQueues(Queue... queues) {
    Assert.notNull(queues, "'queues' cannot be null");
    Assert.noNullElements(queues, "'queues' cannot contain null elements");
    String[] queueNames = new String[queues.length];
    for (int i = 0; i < queues.length; i++) {
        queueNames[i] = queues[i].getName();
    }
    this.addQueueNames(queueNames);
}

From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java

/**
 * Remove queue(s) from this container's list of queues.
 * @param queueNames The queue(s) to remove.
 * @return the boolean result of removal on the target {@code queueNames} List.
 *//*from   w w  w .  j av  a 2 s .co m*/
public boolean removeQueueNames(String... queueNames) {
    Assert.notNull(queueNames, "'queueNames' cannot be null");
    Assert.noNullElements(queueNames, "'queueNames' cannot contain null elements");
    Assert.isTrue(canRemoveLastQueue() || this.queueNames.size() - queueNames.length > 0,
            "Cannot remove the last queue");
    return this.queueNames.removeAll(Arrays.asList(queueNames));
}

From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java

/**
 * Remove queue(s) from this container's list of queues.
 * @param queues The queue(s) to remove.
 * @return the boolean result of removal on the target {@code queueNames} List.
 *//*from ww  w  .j a  v  a2s.c  o m*/
public boolean removeQueues(Queue... queues) {
    Assert.notNull(queues, "'queues' cannot be null");
    Assert.noNullElements(queues, "'queues' cannot contain null elements");
    String[] queueNames = new String[queues.length];
    for (int i = 0; i < queues.length; i++) {
        queueNames[i] = queues[i].getName();
    }
    return this.removeQueueNames(queueNames);
}

From source file:org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.java

/**
 * Set {@link MessagePostProcessor}s that will be applied after message reception, before
 * invoking the {@link MessageListener}. Often used to decompress data.  Processors are invoked in order,
 * depending on {@code PriorityOrder}, {@code Order} and finally unordered.
 * @param afterReceivePostProcessors the post processor.
 * @since 1.4.2//from   www. j  av a2s  . c  o  m
 */
public void setAfterReceivePostProcessors(MessagePostProcessor... afterReceivePostProcessors) {
    Assert.notNull(afterReceivePostProcessors, "'afterReceivePostProcessors' cannot be null");
    Assert.noNullElements(afterReceivePostProcessors, "'afterReceivePostProcessors' cannot have null elements");
    this.afterReceivePostProcessors = MessagePostProcessorUtils.sort(Arrays.asList(afterReceivePostProcessors));
}

From source file:org.springframework.integration.aws.inbound.SnsInboundChannelAdapter.java

public SnsInboundChannelAdapter(AmazonSNS amazonSns, String... path) {
    super(false);
    Assert.notNull(amazonSns, "'amazonSns' must not be null.");
    Assert.notNull(path, "'path' must not be null.");
    Assert.noNullElements(path, "'path' must not contain null elements.");
    this.notificationStatusResolver = new NotificationStatusResolver(amazonSns);
    RequestMapping requestMapping = new RequestMapping();
    requestMapping.setMethods(HttpMethod.POST);
    requestMapping.setHeaders("x-amz-sns-message-type");
    requestMapping.setPathPatterns(path);
    this.jackson2HttpMessageConverter
            .setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_PLAIN));
    super.setRequestMapping(requestMapping);
    super.setStatusCodeExpression(new ValueExpression<>(HttpStatus.NO_CONTENT));
    super.setMessageConverters(
            Collections.<HttpMessageConverter<?>>singletonList(this.jackson2HttpMessageConverter));
    super.setRequestPayloadType(HashMap.class);
}

From source file:org.springframework.integration.kafka.listener.KafkaMessageListenerContainer.java

public KafkaMessageListenerContainer(ConnectionFactory connectionFactory, Partition... partitions) {
    Assert.notNull(connectionFactory, "A connection factory must be supplied");
    Assert.notEmpty(partitions, "A list of partitions must be provided");
    Assert.noNullElements(partitions, "The list of partitions cannot contain null elements");
    this.kafkaTemplate = new KafkaTemplate(connectionFactory);
    this.partitions = partitions;
    this.topics = null;
}

From source file:org.springframework.integration.kafka.listener.KafkaMessageListenerContainer.java

public KafkaMessageListenerContainer(final ConnectionFactory connectionFactory, String... topics) {
    Assert.notNull(connectionFactory, "A connection factory must be supplied");
    Assert.notNull(topics, "A list of topics must be provided");
    Assert.noNullElements(topics, "The list of topics cannot contain null elements");
    this.kafkaTemplate = new KafkaTemplate(connectionFactory);
    this.topics = topics;
}

From source file:org.springframework.integration.stomp.support.StompHeaderMapper.java

public void setInboundHeaderNames(String[] inboundHeaderNames) { //NOSONAR - false positive
    Assert.notNull(inboundHeaderNames, "'inboundHeaderNames' must not be null.");
    Assert.noNullElements(inboundHeaderNames, "'inboundHeaderNames' must not contains null elements.");
    Arrays.sort(inboundHeaderNames);
    if (!Arrays.equals(STOMP_INBOUND_HEADER_NAMES, inboundHeaderNames)) {
        this.inboundHeaderNames = inboundHeaderNames;
    }/*from ww w .  jav  a 2 s . c om*/
}

From source file:org.springframework.integration.stomp.support.StompHeaderMapper.java

public void setOutboundHeaderNames(String[] outboundHeaderNames) { //NOSONAR - false positive
    Assert.notNull(outboundHeaderNames, "'outboundHeaderNames' must not be null.");
    Assert.noNullElements(outboundHeaderNames, "'outboundHeaderNames' must not contains null elements.");
    Arrays.sort(outboundHeaderNames);
    if (!Arrays.equals(STOMP_OUTBOUND_HEADER_NAMES, outboundHeaderNames)) {
        this.outboundHeaderNames = outboundHeaderNames;
    }/* w w w .j  a v  a 2s. c  om*/
}

From source file:org.springframework.security.web.server.util.matcher.MediaTypeServerWebExchangeMatcher.java

/**
 * Creates a new instance//from w w  w  .  j ava2 s . com
 * @param matchingMediaTypes the types to match on
 */
public MediaTypeServerWebExchangeMatcher(MediaType... matchingMediaTypes) {
    Assert.notEmpty(matchingMediaTypes, "matchingMediaTypes cannot be null");
    Assert.noNullElements(matchingMediaTypes, "matchingMediaTypes cannot contain null");
    this.matchingMediaTypes = Arrays.asList(matchingMediaTypes);
}