All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cloudstate.javasupport.impl.crdt.CrdtStateTransformer.scala Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
package io.cloudstate.javasupport.impl.crdt

import io.cloudstate.javasupport.impl.AnySupport
import io.cloudstate.protocol.crdt.CrdtState

private[crdt] object CrdtStateTransformer {

  def create(state: CrdtState, anySupport: AnySupport): InternalCrdt = {
    val crdt = state.state match {
      case CrdtState.State.Gcounter(_) =>
        new GCounterImpl
      case CrdtState.State.Pncounter(_) =>
        new PNCounterImpl
      case CrdtState.State.Gset(_) =>
        new GSetImpl[Any](anySupport)
      case CrdtState.State.Orset(_) =>
        new ORSetImpl[Any](anySupport)
      case CrdtState.State.Flag(_) =>
        new FlagImpl
      case CrdtState.State.Lwwregister(_) =>
        new LWWRegisterImpl[Any](anySupport)
      case CrdtState.State.Ormap(_) =>
        new ORMapImpl[Any, InternalCrdt](anySupport)
      case CrdtState.State.Vote(_) =>
        new VoteImpl
    }
    crdt.applyState(state.state)
    crdt
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy