diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorContext.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorContext.java index 783ed5c8..033d4b7f 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorContext.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorContext.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Collection; import java.util.Map; @@ -52,6 +53,7 @@ public interface ActorContext { * * @return the {@link ActorRef} instance that references the Actor */ + @Nonnull ActorRef getSelf(); /** @@ -74,12 +76,14 @@ public interface ActorContext { * * @param state the new {@link ActorState} to set (and store) */ - void setState(ActorState state); + @SuppressWarnings("rawtypes") + void setState(@Nonnull ActorState state); /** * * @return the {@link ActorSystem} this actor is part of */ + @Nonnull ActorSystem getActorSystem(); /** @@ -93,6 +97,7 @@ public interface ActorContext { * * @return the collection of {@link PersistentSubscription}s or and empty collection if there are none */ + @Nonnull Collection getSubscriptions(); /** @@ -103,5 +108,6 @@ public interface ActorContext { * (class)Name and as a value the Set of subscribed actors. If there are no subscribers and empty Map will * be returned */ + @Nonnull Map> getSubscribers(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorLifecycleListener.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorLifecycleListener.java index fafab370..4bb8bcb1 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorLifecycleListener.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorLifecycleListener.java @@ -18,10 +18,12 @@ package org.elasticsoftware.elasticactors; import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; /** * @author Joost van de Wijgerd */ +@ParametersAreNonnullByDefault public interface ActorLifecycleListener { Class getActorClass(); diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRef.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRef.java index 775dabe0..61acde5b 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRef.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRef.java @@ -20,6 +20,9 @@ import org.elasticsoftware.elasticactors.concurrent.ActorCompletableFuture; import org.reactivestreams.Publisher; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * This is the main entry point for the ElasticActors API. When a {@link org.elasticsoftware.elasticactors.serialization.Message} * needs to be send to an {@link ElasticActor} first the {@link ActorRef} needs to be obtained. An Actor Reference @@ -41,6 +44,7 @@ * @author Joost van de Wijgerd */ public interface ActorRef { + @Nonnull String getActorCluster(); /** * The path of an actor is the Shard (or Node) where the actor is located. It looks like: @@ -48,6 +52,7 @@ public interface ActorRef { * * @return the actor path as a string */ + @Nonnull String getActorPath(); /** @@ -59,6 +64,7 @@ public interface ActorRef { * @see ActorSystem#serviceActorFor(String) * @return the actor id for this {@link ActorRef} */ + @Nonnull String getActorId(); /** @@ -68,7 +74,7 @@ public interface ActorRef { * @param sender the sender, this can be self, but it can also be another {@link ActorRef} * @throws MessageDeliveryException when something is wrong with the Messaging Subsystem */ - void tell(Object message, ActorRef sender) throws MessageDeliveryException; + void tell(@Nonnull Object message,@Nullable ActorRef sender) throws MessageDeliveryException; /** * Equivalent to calling ActorRef.tell(message,getSelf()) @@ -77,7 +83,7 @@ public interface ActorRef { * @throws IllegalStateException if the method is not called withing a {@link ElasticActor} lifecycle or on(Message) method * @throws MessageDeliveryException when somthing is wrong with the Messaging Subsystem */ - void tell(Object message) throws IllegalStateException, MessageDeliveryException; + void tell(@Nonnull Object message) throws IllegalStateException, MessageDeliveryException; /** * Send a message to an {@link ElasticActor} and request a response. diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRefGroup.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRefGroup.java index 5737bf1d..8f8684b9 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRefGroup.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorRefGroup.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nullable; import java.util.Collection; /** @@ -30,7 +31,7 @@ public interface ActorRefGroup { * @param sender the sender, this can be self, but it can also be another {@link ActorRef} * @throws MessageDeliveryException when something is wrong with the Messaging Subsystem */ - void tell(Object message, ActorRef sender) throws MessageDeliveryException; + void tell(Object message, @Nullable ActorRef sender) throws MessageDeliveryException; /** * Equivalent to calling ActorRefGroup.tell(message,getSelf()) @@ -41,9 +42,11 @@ public interface ActorRefGroup { */ void tell(Object message) throws IllegalStateException, MessageDeliveryException; + @SuppressWarnings("unused") Collection getMembers(); + @SuppressWarnings("unused") ActorRefGroup withMembersAdded(ActorRef... membersToAdd); - + @SuppressWarnings("unused") ActorRefGroup withMembersRemoved(ActorRef... membersToRemove); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorState.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorState.java index 966956ca..88b0cfa8 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorState.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorState.java @@ -19,6 +19,9 @@ import org.elasticsoftware.elasticactors.serialization.SerializationFramework; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Tagging interface for the state object of an {@link ElasticActor}. The interface has a generic * type Body that should normally be the same type as the implementing class. The reason behind this @@ -34,6 +37,7 @@ public interface ActorState { * * @return the body (the actual state) */ + @Nonnull Body getBody(); /** @@ -41,6 +45,7 @@ public interface ActorState { * * @return the type of the SerializationFramework that should be used to serialize this state class */ + @Nonnull Class getSerializationFramework(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystem.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystem.java index 0f6b36ae..5d8d744f 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystem.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystem.java @@ -20,6 +20,7 @@ import org.elasticsoftware.elasticactors.cluster.ActorSystemEventListenerRegistry; import org.elasticsoftware.elasticactors.scheduler.Scheduler; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Collection; @@ -40,6 +41,7 @@ public interface ActorSystem { * * @return the name of this {@link ActorSystem} */ + @Nonnull String getName(); /** @@ -56,6 +58,7 @@ public interface ActorSystem { * @return the {@link ActorRef} pointing to the newly created actor * @throws Exception when something unexpected happens */ + @Nonnull ActorRef actorOf(String actorId, Class actorClass) throws Exception; @@ -78,6 +81,7 @@ public interface ActorSystem { * @return the {@link ActorRef} pointing to the newly created actor * @throws Exception when something unexpected happens */ + @Nonnull ActorRef actorOf(String actorId, String actorClassName) throws Exception; /** @@ -95,6 +99,7 @@ public interface ActorSystem { * @return the {@link ActorRef} pointing to the newly created actor * @throws Exception when something unexpected happens */ + @Nonnull ActorRef actorOf(String actorId, Class actorClass, ActorState initialState) throws Exception; /** @@ -117,8 +122,10 @@ public interface ActorSystem { * @return the {@link ActorRef} pointing to the newly created actor * @throws Exception when something unexpected happens */ + @Nonnull ActorRef actorOf(String actorId, String actorClassName, ActorState initialState) throws Exception; + @Nonnull ActorRef actorOf(String actorId, String actorClassName, ActorState initialState, ActorRef creatorRef) throws Exception; /** @@ -135,6 +142,7 @@ public interface ActorSystem { * @throws Exception when something unexpected happens * @return the {@link ActorRef} pointing to the newly created actor */ + @Nonnull ActorRef tempActorOf(Class actorClass,@Nullable ActorState initialState) throws Exception; /** @@ -148,6 +156,7 @@ public interface ActorSystem { * @param actorId the id of the (Standard) Actor to reference * @return the {@link ActorRef} to the Actor (not guaranteed to exist!) */ + @Nonnull ActorRef actorFor(String actorId); /** @@ -158,6 +167,7 @@ public interface ActorSystem { * @param actorId the id of the Service Actor to reference * @return the {@link ActorRef} to the Service Actor */ + @Nonnull ActorRef serviceActorFor(String actorId); /** @@ -171,6 +181,7 @@ public interface ActorSystem { * @param actorId the id of the Service Actor to reference * @return the {@link ActorRef} to the Service Actor */ + @Nonnull ActorRef serviceActorFor(String nodeId, String actorId); /** @@ -179,6 +190,7 @@ public interface ActorSystem { * * @return the configured {@link Scheduler} */ + @Nonnull Scheduler getScheduler(); /** @@ -187,6 +199,7 @@ public interface ActorSystem { * * @return the parent of this {@link ActorSystem} */ + @Nonnull ActorSystems getParent(); /** @@ -204,6 +217,7 @@ public interface ActorSystem { * * @return the configuration object */ + @Nonnull ActorSystemConfiguration getConfiguration(); /** @@ -216,6 +230,7 @@ public interface ActorSystem { * * @return the {@link org.elasticsoftware.elasticactors.cluster.ActorSystemEventListenerRegistry} for this {@link org.elasticsoftware.elasticactors.ActorSystem} */ + @Nonnull ActorSystemEventListenerRegistry getEventListenerRegistry(); /** @@ -230,6 +245,7 @@ public interface ActorSystem { * @throws IllegalArgumentException if one of the members is not a Persistent Actor * (i.e. not created with {@link #actorOf(String, Class, ActorState)}, {@link #actorOf(String, Class)} or {@link #actorFor(String)} } */ + @Nonnull ActorRefGroup groupOf(Collection members) throws IllegalArgumentException; } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystemConfiguration.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystemConfiguration.java index bf522130..52636b06 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystemConfiguration.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystemConfiguration.java @@ -17,6 +17,9 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * @author Joost van de Wijgerd */ @@ -26,6 +29,7 @@ public interface ActorSystemConfiguration { * * @return the name of this {@link ActorSystem} */ + @Nonnull String getName(); /** @@ -123,6 +127,7 @@ public interface ActorSystemConfiguration { * * @return the version of the ActorSystem */ + @Nonnull String getVersion(); /** @@ -136,6 +141,7 @@ public interface ActorSystemConfiguration { * @return the property value associated with the given key, or {@code null} if the key cannot be resolved. * @see #getRequiredProperty(Class, String, Class) */ + @Nullable T getProperty(Class component,String key, Class targetType); /** @@ -150,6 +156,7 @@ public interface ActorSystemConfiguration { * @return the property value associated with the given key, or {@code defaultValue} if the key cannot be resolved. * @see #getRequiredProperty(Class,String, Class) */ + @Nonnull T getProperty(Class component,String key, Class targetType, T defaultValue); /** @@ -163,7 +170,9 @@ public interface ActorSystemConfiguration { * @return the property value associated with the given key, converted to the given {@code targetType} (never {@code null}). * @throws IllegalStateException if the given key cannot be resolved */ - T getRequiredProperty(Class component,String key, Class targetType) throws IllegalStateException; + @SuppressWarnings("unused") + @Nonnull + T getRequiredProperty(Class component,String key, Class targetType) throws IllegalStateException; } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystems.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystems.java index 4b532ec3..7061c639 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystems.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ActorSystems.java @@ -19,6 +19,7 @@ import org.elasticsoftware.elasticactors.cluster.RebalancingEventListener; +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -33,6 +34,7 @@ public interface ActorSystems { * * @return the name of the local ElasticActors cluster */ + @Nonnull String getClusterName(); /** @@ -41,6 +43,7 @@ public interface ActorSystems { * @param actorSystemName the name of the {@link ActorSystem} or null to get the default * @return the local {@link ActorSystem} instance */ + @Nonnull ActorSystem get(@Nullable String actorSystemName); /** @@ -51,6 +54,7 @@ public interface ActorSystems { * @param actorSystemName the {@link ActorSystem} name in the remote cluster or null to get the default * @return the remote {@link ActorSystem} instance or null if it doesn't exist / is not configured */ + @Nullable ActorSystem getRemote(String clusterName,@Nullable String actorSystemName); /** @@ -62,6 +66,7 @@ public interface ActorSystems { * @return the remote {@link ActorSystem} instance or null if it doesn't exist / is not configured * @throws IllegalArgumentException if there is more than one match */ + @Nullable ActorSystem getRemote(String actorSystemName); /** diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ElasticActor.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ElasticActor.java index 2e3e39b5..b77554c2 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ElasticActor.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ElasticActor.java @@ -20,6 +20,7 @@ import org.elasticsoftware.elasticactors.serialization.SerializationFramework; import org.reactivestreams.Subscriber; +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -60,6 +61,8 @@ public interface ElasticActor { * @return the {@link ActorState} object after being processed * @throws Exception when something unexpected happens */ + @SuppressWarnings("rawtypes") + @Nonnull ActorState preActivate(String previousVersion,String currentVersion,byte[] serializedForm,SerializationFramework serializationFramework) throws Exception; /** diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/InitialStateProvider.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/InitialStateProvider.java index d165e7fb..b7fd598a 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/InitialStateProvider.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/InitialStateProvider.java @@ -17,6 +17,8 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; + /** * Used to provide an actor's initial state for instances managed by the framework. * Implementations must have a no-args constructor. @@ -33,6 +35,7 @@ public ActorState getInitialState( } } + @Nonnull ActorState getInitialState(String actorId, Class stateClass) throws Exception; } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/ManagedActorsRegistry.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/ManagedActorsRegistry.java index c1e36766..08f988ee 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/ManagedActorsRegistry.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/ManagedActorsRegistry.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; import java.util.List; /** @@ -34,6 +35,7 @@ public interface ManagedActorsRegistry { * * @return the classes that are annotated with {@link SingletonActor} */ + @Nonnull List>> getSingletonActorClasses(); /** @@ -41,5 +43,6 @@ public interface ManagedActorsRegistry { * * @return the classes that are annotated with {@link ManagedActor} */ + @Nonnull List>> getManagedActorClasses(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/MessageHandlersRegistry.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/MessageHandlersRegistry.java index 0bbc2a05..838abd04 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/MessageHandlersRegistry.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/MessageHandlersRegistry.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; import java.util.List; /** @@ -36,5 +37,6 @@ public interface MessageHandlersRegistry { * @param methodActor actor type for which to get {@link PluggableMessageHandlers} for * @return classes that are annotated with {@link PluggableMessageHandlers} for the actor type */ - public List> getMessageHandlers(Class methodActor); + @Nonnull + List> getMessageHandlers(Class methodActor); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/PersistentSubscription.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/PersistentSubscription.java index ffb877a8..6641752b 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/PersistentSubscription.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/PersistentSubscription.java @@ -19,12 +19,16 @@ import org.reactivestreams.Subscription; +import javax.annotation.Nonnull; + /** * @author Joost van de Wijgerd */ public interface PersistentSubscription extends Subscription { + @Nonnull ActorRef getPublisherRef(); + @Nonnull String getMessageName(); boolean isCancelled(); diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/SubscriberContext.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/SubscriberContext.java index d98464f1..9d9e6e0d 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/SubscriberContext.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/SubscriberContext.java @@ -17,17 +17,24 @@ package org.elasticsoftware.elasticactors; +import javax.annotation.Nonnull; + /** * @author Joost van de Wijgerd */ public interface SubscriberContext { + @Nonnull ActorRef getSelf(); + @Nonnull ActorRef getPublisher(); + @Nonnull T getState(Class stateClass); + @Nonnull ActorSystem getActorSystem(); + @Nonnull PersistentSubscription getSubscription(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorRefFactory.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorRefFactory.java index d5f01171..65be0418 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorRefFactory.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorRefFactory.java @@ -19,9 +19,12 @@ import org.elasticsoftware.elasticactors.ActorRef; +import javax.annotation.Nonnull; + /** * @author Joost van de Wijgerd */ public interface ActorRefFactory { - ActorRef create(String refSpec); + @Nonnull + ActorRef create(@Nonnull String refSpec); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorSystemEventListenerRegistry.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorSystemEventListenerRegistry.java index 0ed799ad..0900b42f 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorSystemEventListenerRegistry.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/ActorSystemEventListenerRegistry.java @@ -19,11 +19,14 @@ import org.elasticsoftware.elasticactors.ActorRef; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import java.io.IOException; /** * @author Joost van de Wijgerd */ +@ParametersAreNonnullByDefault public interface ActorSystemEventListenerRegistry { /** * @@ -34,7 +37,7 @@ public interface ActorSystemEventListenerRegistry { * @throws java.lang.IllegalStateException when this method ios not called in the context of an actor * @throws IOException when the message serialization fails */ - public void register(ActorRef receiver, ActorSystemEvent event, Object message) throws IOException; + void register(ActorRef receiver, ActorSystemEvent event, Object message) throws IOException; /** * Deregisters the activation hook (if any) for the calling actor. Only works while being called in the context of @@ -46,5 +49,5 @@ public interface ActorSystemEventListenerRegistry { * @param event The type of event to unsubscribe from * @throws java.lang.IllegalStateException when this method not called in the context of an actor */ - public void deregister(ActorRef receiver, ActorSystemEvent event); + void deregister(ActorRef receiver, ActorSystemEvent event); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/scheduler/ScheduledMessageRefFactory.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/scheduler/ScheduledMessageRefFactory.java index c8582fac..7a4b6017 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/scheduler/ScheduledMessageRefFactory.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/cluster/scheduler/ScheduledMessageRefFactory.java @@ -19,9 +19,11 @@ import org.elasticsoftware.elasticactors.scheduler.ScheduledMessageRef; +import javax.annotation.Nonnull; + /** * @author Joost van de Wijgerd */ public interface ScheduledMessageRefFactory { - ScheduledMessageRef create(String refSpec); + @Nonnull ScheduledMessageRef create(@Nonnull String refSpec); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/package-info.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/package-info.java new file mode 100644 index 00000000..b9d546d8 --- /dev/null +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2013 - 2023 The Original Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +@ParametersAreNonnullByDefault +package org.elasticsoftware.elasticactors; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/ScheduledMessageRef.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/ScheduledMessageRef.java index c7025e8b..e26421c2 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/ScheduledMessageRef.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/ScheduledMessageRef.java @@ -24,9 +24,10 @@ * @author Joost van de Wijgerd */ public interface ScheduledMessageRef { + @SuppressWarnings("unused") String REFSPEC_FORMAT = "message://%s/%s/shards/%d/%d/%s"; void cancel() throws Exception; - public long getFireTime(); + long getFireTime(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/Scheduler.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/Scheduler.java index 5c7a759e..de4a7cd5 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/Scheduler.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/scheduler/Scheduler.java @@ -19,11 +19,14 @@ import org.elasticsoftware.elasticactors.ActorRef; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import java.util.concurrent.TimeUnit; /** * @author Joost van de Wijgerd */ +@ParametersAreNonnullByDefault public interface Scheduler { /** * Schedules a particular message to be send once @@ -34,6 +37,7 @@ public interface Scheduler { * @param timeUnit the {@link TimeUnit} to interpret the delay parameter * @return the serializable reference to the scheduled message that can be stored and used to manage it */ + @Nonnull ScheduledMessageRef scheduleOnce( Object message, ActorRef receiver, diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/Deserializer.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/Deserializer.java index a4891301..5b44a486 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/Deserializer.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/Deserializer.java @@ -17,13 +17,15 @@ package org.elasticsoftware.elasticactors.serialization; +import javax.annotation.Nonnull; import java.io.IOException; /** * @author Joost van de Wijgerd */ public interface Deserializer { - O deserialize(I serializedObject) throws IOException; + @Nonnull + O deserialize(@Nonnull I serializedObject) throws IOException; /** * Whether this deserializer is safe from side effects on the serialized object. diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageDeserializer.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageDeserializer.java index 0d9a15f4..d690edbf 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageDeserializer.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageDeserializer.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors.serialization; +import javax.annotation.Nonnull; import java.io.IOException; import java.nio.ByteBuffer; @@ -24,8 +25,10 @@ * @author Joost van de Wijgerd */ public interface MessageDeserializer extends Deserializer { + @Nonnull @Override - O deserialize(ByteBuffer serializedObject) throws IOException; + O deserialize(@Nonnull ByteBuffer serializedObject) throws IOException; + @Nonnull Class getMessageClass(); } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageSerializer.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageSerializer.java index f0ea82eb..1512cd45 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageSerializer.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/MessageSerializer.java @@ -17,6 +17,7 @@ package org.elasticsoftware.elasticactors.serialization; +import javax.annotation.Nonnull; import java.io.IOException; import java.nio.ByteBuffer; @@ -24,6 +25,7 @@ * @author Joost van de Wijgerd */ public interface MessageSerializer extends Serializer { + @Nonnull @Override - ByteBuffer serialize(I object) throws IOException; + ByteBuffer serialize(@Nonnull I object) throws IOException; } diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/SerializationFramework.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/SerializationFramework.java index ca0dc507..6b0de352 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/SerializationFramework.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/serialization/SerializationFramework.java @@ -20,11 +20,13 @@ import org.elasticsoftware.elasticactors.ActorState; import org.elasticsoftware.elasticactors.ElasticActor; +import javax.annotation.ParametersAreNonnullByDefault; import java.nio.ByteBuffer; /** * @author Joost van de Wijgerd */ +@ParametersAreNonnullByDefault public interface SerializationFramework { /** * Register a message class with the framework diff --git a/main/api/src/main/java/org/elasticsoftware/elasticactors/state/PersistenceAdvisor.java b/main/api/src/main/java/org/elasticsoftware/elasticactors/state/PersistenceAdvisor.java index ee1a9185..c5c636fd 100644 --- a/main/api/src/main/java/org/elasticsoftware/elasticactors/state/PersistenceAdvisor.java +++ b/main/api/src/main/java/org/elasticsoftware/elasticactors/state/PersistenceAdvisor.java @@ -17,11 +17,13 @@ package org.elasticsoftware.elasticactors.state; +import javax.annotation.Nonnull; + /** * @author Joost van de Wijgerd */ public interface PersistenceAdvisor { - boolean shouldUpdateState(Object message); + boolean shouldUpdateState(@Nonnull Object message); - boolean shouldUpdateState(ActorLifecycleStep lifecycleStep); + boolean shouldUpdateState(@Nonnull ActorLifecycleStep lifecycleStep); }