Skip to content

Commit

Permalink
Code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
renedewaele committed Oct 30, 2016
1 parent 27aab3d commit 63d487a
Show file tree
Hide file tree
Showing 151 changed files with 542 additions and 650 deletions.
6 changes: 0 additions & 6 deletions amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@
<artifactId>axon-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.rabbitmq</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public interface AMQPMessageConverter {

/**
* Creates an AMQPMessage from given <code>eventMessage</code>.
* Creates an AMQPMessage from given {@code eventMessage}.
*
* @param eventMessage The EventMessage to create the AMQP Message from
* @return an AMQP Message containing the data and characteristics of the Message to send to the AMQP Message
Expand All @@ -38,7 +38,7 @@ public interface AMQPMessageConverter {
AMQPMessage createAMQPMessage(EventMessage eventMessage);

/**
* Reconstruct an EventMessage from the given <code>messageBody</code> and <code>headers</code>.
* Reconstruct an EventMessage from the given {@code messageBody} and {@code headers}.
*
* @param messageBody The body of the AMQP Message
* @param headers The headers attached to the AMQP Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DefaultAMQPMessageConverter implements AMQPMessageConverter {
private final boolean durable;

/**
* Initializes the AMQPMessageConverter with the given <code>serializer</code>, using a {@link
* Initializes the AMQPMessageConverter with the given {@code serializer}, using a {@link
* PackageRoutingKeyResolver} and requesting durable dispatching.
*
* @param serializer The serializer to serialize the Event Message's payload and Meta Data with
Expand All @@ -53,16 +53,16 @@ public DefaultAMQPMessageConverter(Serializer serializer) {
}

/**
* Initializes the AMQPMessageConverter with the given <code>serializer</code>, <code>routingKeyResolver</code> and
* requesting durable dispatching when <code>durable</code> is <code>true</code>.
* Initializes the AMQPMessageConverter with the given {@code serializer}, {@code routingKeyResolver} and
* requesting durable dispatching when {@code durable} is {@code true}.
*
* @param serializer The serializer to serialize the Event Message's payload and Meta Data with
* @param routingKeyResolver The strategy to use to resolve routing keys for Event Messages
* @param durable Whether to request durable message dispatching
*/
public DefaultAMQPMessageConverter(Serializer serializer, RoutingKeyResolver routingKeyResolver, boolean durable) {
Assert.notNull(serializer, "Serializer may not be null");
Assert.notNull(routingKeyResolver, "RoutingKeyResolver may not be null");
Assert.notNull(serializer, () -> "Serializer may not be null");
Assert.notNull(routingKeyResolver, () -> "RoutingKeyResolver may not be null");
this.serializer = serializer;
this.routingKeyResolver = routingKeyResolver;
this.durable = durable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public interface RoutingKeyResolver {

/**
* Returns the Routing Key to use when sending the given <code>eventMessage</code> to the Message Broker.
* Returns the Routing Key to use when sending the given {@code eventMessage} to the Message Broker.
*
* @param eventMessage The EventMessage to resolve the routing key for
* @return the routing key for the event message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void afterPropertiesSet() throws Exception {
*/
public void setTransactional(boolean transactional) {
Assert.isTrue(!waitForAck || !transactional,
"Cannot set transactional behavior when 'waitForServerAck' is enabled.");
() -> "Cannot set transactional behavior when 'waitForServerAck' is enabled.");
isTransactional = transactional;
}

Expand All @@ -266,7 +266,7 @@ public void setTransactional(boolean transactional) {
*/
public void setWaitForPublisherAck(boolean waitForPublisherAck) {
Assert.isTrue(!waitForPublisherAck || !isTransactional,
"Cannot set 'waitForPublisherAck' when using transactions.");
() -> "Cannot set 'waitForPublisherAck' when using transactions.");
this.waitForAck = waitForPublisherAck;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.axonframework.commandhandling.model.inspection.ModelInspector;
import org.axonframework.common.Assert;
import org.axonframework.common.Registration;
import org.axonframework.messaging.MessageHandler;
import org.axonframework.messaging.annotation.ClasspathParameterResolverFactory;
import org.axonframework.messaging.annotation.MessageHandlingMember;
import org.axonframework.messaging.annotation.ParameterResolverFactory;
import org.axonframework.messaging.MessageHandler;

import java.util.*;

Expand Down Expand Up @@ -99,9 +99,9 @@ public AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> r
public AggregateAnnotationCommandHandler(Repository<T> repository,
CommandTargetResolver commandTargetResolver,
AggregateModel<T> aggregateModel) {
Assert.notNull(aggregateModel, "aggregateModel may not be null");
Assert.notNull(repository, "repository may not be null");
Assert.notNull(commandTargetResolver, "commandTargetResolver may not be null");
Assert.notNull(aggregateModel, () -> "aggregateModel may not be null");
Assert.notNull(repository, () -> "repository may not be null");
Assert.notNull(commandTargetResolver, () -> "commandTargetResolver may not be null");
this.repository = repository;
this.commandTargetResolver = commandTargetResolver;
this.handlers = initializeHandlers(aggregateModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import org.axonframework.commandhandling.model.inspection.ModelInspector;
import org.axonframework.common.Assert;
import org.axonframework.common.Registration;
import org.axonframework.messaging.MessageHandler;
import org.axonframework.messaging.annotation.ClasspathParameterResolverFactory;
import org.axonframework.messaging.annotation.ParameterResolverFactory;
import org.axonframework.messaging.MessageHandler;

import java.util.ArrayDeque;
import java.util.Collection;
Expand Down Expand Up @@ -58,7 +58,7 @@ public AnnotationCommandHandlerAdapter(Object annotatedCommandHandler) {
@SuppressWarnings("unchecked")
public AnnotationCommandHandlerAdapter(Object annotatedCommandHandler,
ParameterResolverFactory parameterResolverFactory) {
Assert.notNull(annotatedCommandHandler, "annotatedCommandHandler may not be null");
Assert.notNull(annotatedCommandHandler, () -> "annotatedCommandHandler may not be null");
this.modelInspector = ModelInspector.inspectAggregate((Class<Object>)annotatedCommandHandler.getClass(),
parameterResolverFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public AsynchronousCommandBus() {
* @param executor The executor that processes Command dispatching threads
*/
public AsynchronousCommandBus(Executor executor) {
Assert.notNull(executor, "executor may not be null");
Assert.notNull(executor, () -> "executor may not be null");
this.executor = executor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public MetaDataCommandTargetResolver(String identifierKey, String versionKey) {
@Override
public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) {
String identifier = (String) command.getMetaData().get(identifierKey);
Assert.notNull(identifier, "The MetaData for the command does not exist or contains a null value");
Assert.notNull(identifier, () -> "The MetaData for the command does not exist or contains a null value");
Long version = (Long) (versionKey == null ? null : command.getMetaData().get(versionKey));
return new VersionedAggregateIdentifier(identifier, version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public CommandHandlerInvoker(EventStore eventStore, Cache cache, int segmentId)
@SuppressWarnings("unchecked")
public static <T> DisruptorRepository<T> getRepository(Class<?> type) {
final CommandHandlerInvoker invoker = CURRENT_INVOKER.get();
Assert.state(invoker != null, "The repositories of a DisruptorCommandBus are only available "
Assert.state(invoker != null, () -> "The repositories of a DisruptorCommandBus are only available "
+ "in the invoker thread");
return invoker.repositories.get(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public DisruptorCommandBus(EventStore eventStore) {
*/
@SuppressWarnings("unchecked")
public DisruptorCommandBus(EventStore eventStore, DisruptorConfiguration configuration) {
Assert.notNull(eventStore, "eventStore may not be null");
Assert.notNull(configuration, "configuration may not be null");
Assert.notNull(eventStore, () -> "eventStore may not be null");
Assert.notNull(configuration, () -> "configuration may not be null");
Executor executor = configuration.getExecutor();
if (executor == null) {
executorService = Executors.newCachedThreadPool(new AxonThreadFactory(DISRUPTOR_THREAD_GROUP));
Expand Down Expand Up @@ -201,7 +201,7 @@ public <C> void dispatch(CommandMessage<C> command) {
@Override
@SuppressWarnings("unchecked")
public <C, R> void dispatch(CommandMessage<C> command, CommandCallback<? super C, R> callback) {
Assert.state(started, "CommandBus has been shut down. It is not accepting any Commands");
Assert.state(started, () -> "CommandBus has been shut down. It is not accepting any Commands");
CommandMessage<? extends C> commandToDispatch = command;
for (MessageDispatchInterceptor<? super CommandMessage<?>> interceptor : dispatchInterceptors) {
commandToDispatch = (CommandMessage) interceptor.handle(commandToDispatch);
Expand All @@ -219,7 +219,7 @@ public <C, R> void dispatch(CommandMessage<C> command, CommandCallback<? super C
* @param <R> The expected return type of the command
*/
<C, R> void doDispatch(CommandMessage<C> command, CommandCallback<? super C, R> callback) {
Assert.state(!disruptorShutDown, "Disruptor has been shut down. Cannot dispatch or re-dispatch commands");
Assert.state(!disruptorShutDown, () -> "Disruptor has been shut down. Cannot dispatch or re-dispatch commands");
final MessageHandler<? super CommandMessage<?>> commandHandler = commandHandlers.get(command.getCommandName());
if (commandHandler == null) {
throw new NoHandlerForCommandException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public WaitStrategy getWaitStrategy() {
* @see com.lmax.disruptor.YieldingWaitStrategy YieldingWaitStrategy
*/
public DisruptorConfiguration setWaitStrategy(WaitStrategy waitStrategy) { //NOSONAR (setter may hide field)
Assert.notNull(waitStrategy, "waitStrategy must not be null");
Assert.notNull(waitStrategy, () -> "waitStrategy must not be null");
this.waitStrategy = waitStrategy;
return this;
}
Expand Down Expand Up @@ -241,7 +241,7 @@ public RollbackConfiguration getRollbackConfiguration() {
*/
public DisruptorConfiguration setRollbackConfiguration(
RollbackConfiguration rollbackConfiguration) { //NOSONAR (setter may hide field)
Assert.notNull(rollbackConfiguration, "rollbackConfiguration may not be null");
Assert.notNull(rollbackConfiguration, () -> "rollbackConfiguration may not be null");
this.rollbackConfiguration = rollbackConfiguration;
return this;
}
Expand Down Expand Up @@ -346,7 +346,7 @@ public CommandTargetResolver getCommandTargetResolver() {
* @return {@code this} for method chaining
*/
public DisruptorConfiguration setCommandTargetResolver(CommandTargetResolver newCommandTargetResolver) {
Assert.notNull(newCommandTargetResolver, "newCommandTargetResolver may not be null");
Assert.notNull(newCommandTargetResolver, () -> "newCommandTargetResolver may not be null");
this.commandTargetResolver = newCommandTargetResolver;
return this;
}
Expand All @@ -370,7 +370,7 @@ public int getInvokerThreadCount() {
* @return {@code this} for method chaining
*/
public DisruptorConfiguration setInvokerThreadCount(int count) {
Assert.isTrue(count > 0, "InvokerCount must be at least 1");
Assert.isTrue(count > 0, () -> "InvokerCount must be at least 1");
this.invokerThreadCount = count;
return this;
}
Expand All @@ -394,7 +394,7 @@ public int getPublisherThreadCount() {
* @return {@code this} for method chaining
*/
public DisruptorConfiguration setPublisherThreadCount(int count) {
Assert.isTrue(count > 0, "PublisherCount must be at least 1");
Assert.isTrue(count > 0, () -> "PublisherCount must be at least 1");
this.publisherThreadCount = count;
return this;
}
Expand Down Expand Up @@ -482,7 +482,7 @@ public ProducerType getProducerType() {
* @return {@code this} for method chaining
*/
public DisruptorConfiguration setProducerType(ProducerType producerType) {
Assert.notNull(producerType, "producerType must not be null");
Assert.notNull(producerType, () -> "producerType must not be null");
this.producerType = producerType;
return this;
}
Expand All @@ -503,7 +503,7 @@ public MessageMonitor<? super CommandMessage<?>> getMessageMonitor() {
* @return {@code this} for method chaining
*/
public DisruptorConfiguration setMessageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor) {
Assert.notNull(messageMonitor, "messageMonitor must not be null");
Assert.notNull(messageMonitor, () -> "messageMonitor must not be null");
this.messageMonitor = messageMonitor;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public abstract class AbstractCommandGateway {
*/
protected AbstractCommandGateway(CommandBus commandBus, RetryScheduler retryScheduler,
List<MessageDispatchInterceptor<? super CommandMessage<?>>> messageDispatchInterceptors) {
Assert.notNull(commandBus, "commandBus may not be null");
Assert.notNull(commandBus, () -> "commandBus may not be null");
this.commandBus = commandBus;
if (messageDispatchInterceptors != null && !messageDispatchInterceptors.isEmpty()) {
this.dispatchInterceptors = new ArrayList<>(messageDispatchInterceptors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public CommandGatewayFactory(CommandBus commandBus, RetryScheduler retrySchedule
*/
public CommandGatewayFactory(CommandBus commandBus, RetryScheduler retryScheduler,
List<MessageDispatchInterceptor<CommandMessage<?>>> messageDispatchInterceptors) {
Assert.notNull(commandBus, "commandBus may not be null");
Assert.notNull(commandBus, () -> "commandBus may not be null");
this.retryScheduler = retryScheduler;
this.commandBus = commandBus;
if (messageDispatchInterceptors != null && !messageDispatchInterceptors.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class IntervalRetryScheduler implements RetryScheduler {
* @param maxRetryCount The maximum number of retries allowed for a single command
*/
public IntervalRetryScheduler(ScheduledExecutorService executor, int interval, int maxRetryCount) {
Assert.notNull(executor, "executor may not be null");
Assert.notNull(executor, () -> "executor may not be null");
this.retryExecutor = executor;
this.retryInterval = interval;
this.maxRetryCount = maxRetryCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class AbstractRepository<T, A extends Aggregate<T>> implements R
* @param aggregateType The type of aggregate stored in this repository
*/
protected AbstractRepository(Class<T> aggregateType) {
Assert.notNull(aggregateType, "aggregateType may not be null");
Assert.notNull(aggregateType, () -> "aggregateType may not be null");
this.aggregateType = aggregateType;
this.aggregateModel = ModelInspector.inspectAggregate(aggregateType);
}
Expand All @@ -65,8 +65,8 @@ protected AbstractRepository(Class<T> aggregateType) {
* @param parameterResolverFactory The parameter resolver factory used to resolve parameters of annotated handlers
*/
protected AbstractRepository(Class<T> aggregateType, ParameterResolverFactory parameterResolverFactory) {
Assert.notNull(aggregateType, "aggregateType may not be null");
Assert.notNull(parameterResolverFactory, "parameterResolverFactory may not be null");
Assert.notNull(aggregateType, () -> "aggregateType may not be null");
Assert.notNull(parameterResolverFactory, () -> "parameterResolverFactory may not be null");
this.aggregateType = aggregateType;
this.aggregateModel = ModelInspector.inspectAggregate(aggregateType, parameterResolverFactory);
}
Expand All @@ -75,11 +75,11 @@ protected AbstractRepository(Class<T> aggregateType, ParameterResolverFactory pa
public A newInstance(Callable<T> factoryMethod) throws Exception {
A aggregate = doCreateNew(factoryMethod);
aggregate.execute(root -> Assert.isTrue(aggregateType.isInstance(root),
"Unsuitable aggregate for this repository: wrong type"));
() -> "Unsuitable aggregate for this repository: wrong type"));
UnitOfWork<?> uow = CurrentUnitOfWork.get();
Map<String, Aggregate<T>> aggregates = uow.root().getOrComputeResource(aggregatesKey, s -> new HashMap<>());
Assert.isTrue(aggregates.putIfAbsent(aggregate.identifierAsString(), aggregate) == null,
"The Unit of Work already has an Aggregate with the same identifier");
() -> "The Unit of Work already has an Aggregate with the same identifier");
uow.onRollback(u -> aggregates.remove(aggregate.identifierAsString()));
prepareForCommit(aggregate);

Expand Down Expand Up @@ -194,19 +194,23 @@ protected Class<T> getAggregateType() {

/**
* Perform action that needs to be done directly after updating an aggregate and committing the aggregate's
* uncommitted events.
* uncommitted events. No op by default.
*
* @param aggregate The aggregate instance being saved
*/
@SuppressWarnings("UnusedParameters")
protected void postSave(A aggregate) {
//no op by default
}

/**
* Perform action that needs to be done directly after deleting an aggregate and committing the aggregate's
* uncommitted events.
* uncommitted events. No op by default.
*
* @param aggregate The aggregate instance being saved
*/
@SuppressWarnings("UnusedParameters")
protected void postDelete(A aggregate) {
//no op by default
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public GenericJpaRepository(EntityManagerProvider entityManagerProvider, Class<T
public GenericJpaRepository(EntityManagerProvider entityManagerProvider, Class<T> aggregateType, EventBus eventBus,
LockFactory lockFactory) {
super(aggregateType, lockFactory);
Assert.notNull(entityManagerProvider, "entityManagerProvider may not be null");
Assert.notNull(entityManagerProvider, () -> "entityManagerProvider may not be null");
this.entityManagerProvider = entityManagerProvider;
this.eventBus = eventBus;
}
Expand Down
Loading

0 comments on commit 63d487a

Please sign in to comment.