Add FunctionConverters, FutureConverters and ObjectConverters
This commit is contained in:
parent
dfa0b0ded1
commit
07df607192
70 changed files with 1041 additions and 339 deletions
|
|
@ -381,7 +381,7 @@ private[pekko] final case class PublishedEventImpl(
|
|||
replicatedMetaData: Option[ReplicatedPublishedEventMetaData])
|
||||
extends PublishedEvent
|
||||
with InternalProtocol {
|
||||
import scala.compat.java8.OptionConverters._
|
||||
import pekko.util.OptionConverters._
|
||||
|
||||
def tags: Set[String] = payload match {
|
||||
case t: Tagged => t.tags
|
||||
|
|
@ -398,5 +398,5 @@ private[pekko] final case class PublishedEventImpl(
|
|||
case _ => this
|
||||
}
|
||||
|
||||
override def getReplicatedMetaData: Optional[ReplicatedPublishedEventMetaData] = replicatedMetaData.asJava
|
||||
override def getReplicatedMetaData: Optional[ReplicatedPublishedEventMetaData] = replicatedMetaData.toJava
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@ package org.apache.pekko.persistence.typed.javadsl
|
|||
import java.util.Objects
|
||||
import java.util.function.{ BiFunction, Function => JFunction, Predicate, Supplier }
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.persistence.typed.internal._
|
||||
import pekko.util.FunctionConverters._
|
||||
import pekko.util.OptionVal
|
||||
|
||||
/**
|
||||
|
|
@ -107,7 +106,7 @@ final class CommandHandlerBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forNullState(): CommandHandlerBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.isNull(s))
|
||||
val predicate = ((s: State) => Objects.isNull(s)).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -123,7 +122,7 @@ final class CommandHandlerBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forNonNullState(): CommandHandlerBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.nonNull(s))
|
||||
val predicate = ((s: State) => Objects.nonNull(s)).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -141,7 +140,7 @@ final class CommandHandlerBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forAnyState(): CommandHandlerBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(_ => true)
|
||||
val predicate = ((_: State) => true).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@ package org.apache.pekko.persistence.typed.javadsl
|
|||
import java.util.Objects
|
||||
import java.util.function.{ BiFunction, Function => JFunction, Predicate, Supplier }
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.persistence.typed.internal._
|
||||
import pekko.util.FunctionConverters._
|
||||
import pekko.util.OptionVal
|
||||
|
||||
/* Note that this is a copy of CommandHandler.scala to support ReplyEffect
|
||||
|
|
@ -117,7 +116,7 @@ final class CommandHandlerWithReplyBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forNullState(): CommandHandlerWithReplyBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.isNull(s))
|
||||
val predicate = ((s: State) => Objects.isNull(s)).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -133,7 +132,7 @@ final class CommandHandlerWithReplyBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forNonNullState(): CommandHandlerWithReplyBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.nonNull(s))
|
||||
val predicate = ((s: State) => Objects.nonNull(s)).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -151,7 +150,7 @@ final class CommandHandlerWithReplyBuilder[Command, Event, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forAnyState(): CommandHandlerWithReplyBuilderByState[Command, Event, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(_ => true)
|
||||
val predicate = ((_: State) => true).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, Event, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@ package org.apache.pekko.persistence.typed.javadsl
|
|||
import java.util.Objects
|
||||
import java.util.function.{ BiFunction, Function => JFunction, Predicate, Supplier }
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.util.OptionVal
|
||||
import pekko.util.FunctionConverters._
|
||||
|
||||
/**
|
||||
* FunctionalInterface for reacting on events having been persisted
|
||||
|
|
@ -108,7 +107,7 @@ final class EventHandlerBuilder[State, Event]() {
|
|||
* @return A new, mutable, EventHandlerBuilderByState
|
||||
*/
|
||||
def forNullState(): EventHandlerBuilderByState[State, State, Event] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.isNull(s))
|
||||
val predicate = ((s: State) => Objects.isNull(s)).asJava
|
||||
val builder = EventHandlerBuilderByState.builder[State, Event](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -124,7 +123,7 @@ final class EventHandlerBuilder[State, Event]() {
|
|||
* @return A new, mutable, EventHandlerBuilderByState
|
||||
*/
|
||||
def forNonNullState(): EventHandlerBuilderByState[State, State, Event] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.nonNull(s))
|
||||
val predicate = ((s: State) => Objects.nonNull(s)).asJava
|
||||
val builder = EventHandlerBuilderByState.builder[State, Event](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -142,7 +141,7 @@ final class EventHandlerBuilder[State, Event]() {
|
|||
* @return A new, mutable, EventHandlerBuilderByState
|
||||
*/
|
||||
def forAnyState(): EventHandlerBuilderByState[State, State, Event] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(_ => true)
|
||||
val predicate = ((_: State) => true).asJava
|
||||
val builder = EventHandlerBuilderByState.builder[State, Event](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@ package org.apache.pekko.persistence.typed.javadsl
|
|||
import java.time.Duration
|
||||
import java.util.Optional
|
||||
|
||||
import scala.compat.java8.OptionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.japi.function.Function3
|
||||
import pekko.persistence.typed.SnapshotAdapter
|
||||
import pekko.util.JavaDurationConverters._
|
||||
import pekko.util.OptionConverters._
|
||||
|
||||
/**
|
||||
* Helper functions for migration from PersistentFSM to Persistence Typed
|
||||
|
|
@ -38,5 +37,5 @@ object PersistentFSMMigration {
|
|||
*/
|
||||
def snapshotAdapter[State](adapt: Function3[String, Any, Optional[Duration], State]): SnapshotAdapter[State] =
|
||||
pekko.persistence.typed.scaladsl.PersistentFSMMigration.snapshotAdapter((stateId, snapshot, timer) =>
|
||||
adapt.apply(stateId, snapshot, timer.map(_.asJava).asJava))
|
||||
adapt.apply(stateId, snapshot, timer.map(_.asJava).toJava))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,11 @@ import java.util.function.Predicate
|
|||
import java.util.function.Supplier
|
||||
import java.util.function.{ Function => JFunction }
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.persistence.typed.state.internal._
|
||||
import pekko.util.OptionVal
|
||||
import pekko.util.FunctionConverters._
|
||||
|
||||
/**
|
||||
* FunctionalInterface for reacting on commands
|
||||
|
|
@ -110,7 +109,7 @@ final class CommandHandlerBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forNullState(): CommandHandlerBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.isNull(s))
|
||||
val predicate: Predicate[State] = ((s: State) => Objects.isNull(s)).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -126,7 +125,7 @@ final class CommandHandlerBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forNonNullState(): CommandHandlerBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.nonNull(s))
|
||||
val predicate: Predicate[State] = ((s: State) => Objects.nonNull(s)).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -144,7 +143,7 @@ final class CommandHandlerBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerBuilderByState
|
||||
*/
|
||||
def forAnyState(): CommandHandlerBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(_ => true)
|
||||
val predicate: Predicate[State] = ((_: State) => true).asJava
|
||||
val builder = CommandHandlerBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
|
|||
|
|
@ -19,12 +19,11 @@ import java.util.function.Predicate
|
|||
import java.util.function.Supplier
|
||||
import java.util.function.{ Function => JFunction }
|
||||
|
||||
import scala.compat.java8.FunctionConverters._
|
||||
|
||||
import org.apache.pekko
|
||||
import pekko.annotation.InternalApi
|
||||
import pekko.persistence.typed.state.internal._
|
||||
import pekko.util.OptionVal
|
||||
import pekko.util.FunctionConverters._
|
||||
|
||||
/* Note that this is a copy of CommandHandler.scala to support ReplyEffect
|
||||
* s/Effect/ReplyEffect/
|
||||
|
|
@ -118,7 +117,7 @@ final class CommandHandlerWithReplyBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forNullState(): CommandHandlerWithReplyBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.isNull(s))
|
||||
val predicate: Predicate[State] = ((s: State) => Objects.isNull(s)).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -134,7 +133,7 @@ final class CommandHandlerWithReplyBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forNonNullState(): CommandHandlerWithReplyBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(s => Objects.nonNull(s))
|
||||
val predicate: Predicate[State] = ((s: State) => Objects.nonNull(s)).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
@ -152,7 +151,7 @@ final class CommandHandlerWithReplyBuilder[Command, State]() {
|
|||
* @return A new, mutable, CommandHandlerWithReplyBuilderByState
|
||||
*/
|
||||
def forAnyState(): CommandHandlerWithReplyBuilderByState[Command, State, State] = {
|
||||
val predicate: Predicate[State] = asJavaPredicate(_ => true)
|
||||
val predicate: Predicate[State] = ((_: State) => true).asJava
|
||||
val builder = CommandHandlerWithReplyBuilderByState.builder[Command, State](predicate)
|
||||
builders = builder :: builders
|
||||
builder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue