Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minor] Code refactored #504

Merged
merged 4 commits into from Feb 20, 2017
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -90,7 +90,9 @@ private[cassandra] final class CassandraAutoReadSideHandler[Event <: AggregateEv

override protected def invoke(handler: Handler[Event], element: EventStreamElement[Event]): Future[immutable.Seq[BoundStatement]] = {
for {
statements <- (handler.asInstanceOf[EventStreamElement[Event] => Future[immutable.Seq[BoundStatement]]].apply(element))
statements <- handler
.asInstanceOf[EventStreamElement[Event] => Future[immutable.Seq[BoundStatement]]]
.apply(element)
} yield statements :+ offsetDao.bindSaveOffset(element.offset)
}

@@ -92,16 +92,16 @@ private[lagom] class PersistentEntityActor[C, E, S](

def initEmpty(): Unit =
if (!initialized) {
val inital = entity.initialBehavior(Optional.empty[S])
entity.internalSetCurrentBehavior(inital)
val initial = entity.initialBehavior(Optional.empty[S])
entity.internalSetCurrentBehavior(initial)
initialized = true
}

{
case SnapshotOffer(_, snapshot) =>
if (!initialized) {
val inital = entity.initialBehavior(Optional.ofNullable(snapshot.asInstanceOf[S]))
entity.internalSetCurrentBehavior(inital)
val initial = entity.initialBehavior(Optional.ofNullable(snapshot.asInstanceOf[S]))
entity.internalSetCurrentBehavior(initial)
initialized = true
}

@@ -70,7 +70,7 @@ private[lagom] class ReadSideActor[Event <: AggregateEvent[Event]](

case Done =>
val handler = processorFactory().buildHandler()
handler.prepare(tag).toScala.map(Start(_)) pipeTo self
handler.prepare(tag).toScala.map(Start) pipeTo self
context become active(handler, tag)

case Status.Failure(e) =>
@@ -101,7 +101,7 @@ final class PubSubRef[T](val topic: TopicId[T], mediator: ActorRef, system: Acto
* This method is especially useful when writing tests that require that a subscriber
* is known before sending messages to a topic.
*/
def hasAnySubscribers(): CompletionStage[java.lang.Boolean] = {
def hasAnySubscribers: CompletionStage[java.lang.Boolean] = {
import scala.compat.java8.FutureConverters._
import system.dispatcher
implicit val timeout = hasAnySubscribersTimeout
@@ -115,6 +115,6 @@ final class PubSubRef[T](val topic: TopicId[T], mediator: ActorRef, system: Acto
protected def writeReplace(): AnyRef =
throw new NotSerializableException(s"${getClass.getName} is not serializable. Send the entityId instead.")

override def toString(): String = s"PubSubRef($topic)"
override def toString: String = s"PubSubRef($topic)"

}
@@ -95,7 +95,7 @@ final class PubSubRef[T] private[lagom] (val topic: TopicId[T], mediator: ActorR
* This method is especially useful when writing tests that require that a subscriber
* is known before sending messages to a topic.
*/
def hasAnySubscribers(): Future[Boolean] = {
def hasAnySubscribers: Future[Boolean] = {

This comment has been minimized.

Copy link
@jroper

jroper Feb 20, 2017

Member

The Scala style guides use case for omission of parentheses on zero arity methods is for pure functions - functions with no side effects. This function causes messages to be sent over the network, hence it rightly has parentheses.

import system.dispatcher

import scala.compat.java8.FutureConverters._
@@ -113,7 +113,7 @@ class ClusteredPubSubSpec extends MultiNodeSpec(ClusteredPubSubConfig)
enterBarrier("subscription-established-2")

ref2.publisher.runWith(
Source(List("a", "b", "c", "d", "e").map(Notification(_))))
Source(List("a", "b", "c", "d", "e").map(Notification)))
}

enterBarrier("after-2")
@@ -12,7 +12,7 @@ import com.lightbend.lagom.javadsl.api.ServiceInfo
*/
@Singleton
class ServiceInfoProvider(primaryServiceInterface: Class[_], secondaryServices: Array[Class[_]]) extends Provider[ServiceInfo] {
@Inject private var serverBuilder: JavadslServerBuilder = _
@Inject private val serverBuilder: JavadslServerBuilder = _

This comment has been minimized.

Copy link
@jroper

jroper Feb 20, 2017

Member

serverBuilder must be mutable, since it gets injected by Guice after instantiation.

override lazy val get = {
serverBuilder.createServiceInfo(primaryServiceInterface, secondaryServices)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.