AMQP-685: Use Supplier variants of Spring-Framework's core Assert utility

This commit is contained in:
dreis2211
2016-12-04 22:44:59 +01:00
committed by Artem Bilan
parent 3b1b21f57e
commit ff06da68a2
7 changed files with 9 additions and 9 deletions

View File

@@ -63,7 +63,7 @@ public class RabbitListenerTestHarness extends RabbitListenerAnnotationBeanPostP
Map<String, Object> map = importMetadata.getAnnotationAttributes(RabbitListenerTest.class.getName());
this.attributes = AnnotationAttributes.fromMap(map);
Assert.notNull(this.attributes,
"@RabbitListenerTest is not present on importing class " + importMetadata.getClassName());
() -> "@RabbitListenerTest is not present on importing class " + importMetadata.getClassName());
}
@Override

View File

@@ -534,7 +534,7 @@ public class RabbitListenerAnnotationBeanPostProcessor
private void declareExchangeAndBinding(QueueBinding binding, String queueName) {
org.springframework.amqp.rabbit.annotation.Exchange bindingExchange = binding.exchange();
String exchangeName = resolveExpressionAsString(bindingExchange.value(), "@Exchange.exchange");
Assert.isTrue(StringUtils.hasText(exchangeName), "Exchange name required; binding queue " + queueName);
Assert.isTrue(StringUtils.hasText(exchangeName), () -> "Exchange name required; binding queue " + queueName);
String exchangeType = resolveExpressionAsString(bindingExchange.type(), "@Exchange.type");
String routingKey = resolveExpressionAsString(binding.key(), "@QueueBinding.key");
Exchange exchange;
@@ -620,7 +620,7 @@ public class RabbitListenerAnnotationBeanPostProcessor
typeName = typeClass.getName();
}
else {
Assert.isTrue(type instanceof String, "Type must resolve to a Class or String, but resolved to ["
Assert.isTrue(type instanceof String, () -> "Type must resolve to a Class or String, but resolved to ["
+ type.getClass().getName() + "]");
typeName = (String) type;
try {

View File

@@ -260,7 +260,7 @@ public class LocalizedQueueConnectionFactory implements ConnectionFactory, Routi
public ConnectionFactory getTargetConnectionFactory(Object key) {
String queue = ((String) key);
queue = queue.substring(1, queue.length() - 1);
Assert.isTrue(!queue.contains(","), "Cannot use LocalizedQueueConnectionFactory with more than one queue: " + key);
Assert.isTrue(!queue.contains(","), () -> "Cannot use LocalizedQueueConnectionFactory with more than one queue: " + key);
ConnectionFactory connectionFactory = determineConnectionFactory(queue);
if (connectionFactory == null) {
return this.defaultConnectionFactory;

View File

@@ -111,7 +111,7 @@ public final class SimpleResourceHolder {
resources.set(map);
}
Object oldValue = map.put(key, value);
Assert.isNull(oldValue, "Already value [" + oldValue + "] for key [" + key + "] bound to thread [" + Thread.currentThread().getName() + "]");
Assert.isNull(oldValue, () -> "Already value [" + oldValue + "] for key [" + key + "] bound to thread [" + Thread.currentThread().getName() + "]");
if (logger.isTraceEnabled()) {
logger.trace("Bound value [" + value + "] for key [" + key + "] to thread [" + Thread.currentThread().getName() + "]");
@@ -126,7 +126,7 @@ public final class SimpleResourceHolder {
*/
public static Object unbind(Object key) throws IllegalStateException {
Object value = unbindIfPossible(key);
Assert.notNull(value, "No value for key [" + key + "] bound to thread [" + Thread.currentThread().getName() + "]");
Assert.notNull(value, () -> "No value for key [" + key + "] bound to thread [" + Thread.currentThread().getName() + "]");
return value;
}

View File

@@ -1347,7 +1347,7 @@ public class RabbitTemplate extends RabbitAccessor implements BeanFactoryAware,
protected Message doSendAndReceiveWithFixed(final String exchange, final String routingKey, final Message message,
final CorrelationData correlationData) {
Assert.state(this.isListener, "RabbitTemplate is not configured as MessageListener - "
Assert.state(this.isListener, () -> "RabbitTemplate is not configured as MessageListener - "
+ "cannot use a 'replyAddress': " + this.replyAddress);
return this.execute(channel -> {
return doSendAndReceiveAsListener(exchange, routingKey, message, correlationData, channel);

View File

@@ -246,7 +246,7 @@ public abstract class AbstractRabbitListenerEndpoint implements RabbitListenerEn
private void setupMessageListener(MessageListenerContainer container) {
MessageListener messageListener = createMessageListener(container);
Assert.state(messageListener != null, "Endpoint [" + this + "] must provide a non null message listener");
Assert.state(messageListener != null, () -> "Endpoint [" + this + "] must provide a non null message listener");
container.setupMessageListener(messageListener);
}

View File

@@ -462,7 +462,7 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta
break;
}
}
Assert.state(found, "Listener expects us to be listening on '" + expectedQueueNames + "'; our queues: "
Assert.state(found, () -> "Listener expects us to be listening on '" + expectedQueueNames + "'; our queues: "
+ Arrays.asList(queueNames));
}
}