Class PersistenceId
- java.lang.Object
-
- akka.persistence.typed.PersistenceId
-
public final class PersistenceId extends java.lang.Object
Unique identifier in the backend data store (journal and snapshot store) of the persistent actor.
-
-
Constructor Summary
Constructors Constructor Description PersistenceId()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PersistenceId
apply(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.static PersistenceId
apply(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.static java.lang.String
concat(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs a persistence idString
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.static java.lang.String
concat(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs a persistence idString
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.static java.lang.String
DefaultSeparator()
Default separator character used for concatenating atypeHint
withentityId
to construct unique persistenceId.java.lang.String
entityId()
java.lang.String
entityTypeHint()
boolean
equals(java.lang.Object obj)
static java.lang.String
extractEntityId(java.lang.String id)
Extract theentityId
from a persistence id String with the default separator|
.static java.lang.String
extractEntityType(java.lang.String id)
Extract theentityTypeHint
from a persistence id String with the default separator|
.int
hashCode()
java.lang.String
id()
static PersistenceId
of(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.static PersistenceId
of(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.static PersistenceId
ofUniqueId(java.lang.String id)
Constructs aPersistenceId
withid
as the full unique identifier.java.lang.String
toString()
static scala.Option<scala.Tuple2<java.lang.String,java.lang.String>>
unapply(PersistenceId persistenceId)
-
-
-
Method Detail
-
DefaultSeparator
public static java.lang.String DefaultSeparator()
Default separator character used for concatenating atypeHint
withentityId
to construct unique persistenceId. This must be same as in Lagom'sscaladsl.PersistentEntity
, for compatibility. No separator is used in Lagom'sjavadsl.PersistentEntity
so for compatibility with that the""
separator must be used instead.
-
apply
public static PersistenceId apply(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.Cluster Sharding is often used together with
EventSourcedBehavior
for the entities. ThePersistenceId
of theEventSourcedBehavior
can typically be constructed with:PersistenceId(entityContext.entityTypeKey.name, entityContext.entityId)
That format of the
PersistenceId
is not mandatory and only provided as a convenience of a "standardized" format.Another separator can be defined by using the
apply
that takes aseparator
parameter.The
|
separator is also used in Lagom'sscaladsl.PersistentEntity
but no separator is used in Lagom'sjavadsl.PersistentEntity
. For compatibility with Lagom'sjavadsl.PersistentEntity
you should use""
as the separator.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
contains|
-
apply
public static PersistenceId apply(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.Cluster Sharding is often used together with
EventSourcedBehavior
for the entities. ThePersistenceId
of theEventSourcedBehavior
can typically be constructed with:PersistenceId(entityContext.entityTypeKey.name, entityContext.entityId)
That format of the
PersistenceId
is not mandatory and only provided as a convenience of a "standardized" format.The default separator
|
is used by theapply
that doesn't take aseparator
parameter.The
|
separator is also used in Lagom'sscaladsl.PersistentEntity
but no separator is used in Lagom'sjavadsl.PersistentEntity
. For compatibility with Lagom'sjavadsl.PersistentEntity
you should use""
as the separator.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
containsseparator
-
of
public static PersistenceId of(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.Cluster Sharding is often used together with
EventSourcedBehavior
for the entities. ThePersistenceId
of theEventSourcedBehavior
can typically be constructed with:PersistenceId.of(entityContext.getEntityTypeKey().name(), entityContext.getEntityId())
That format of the
PersistenceId
is not mandatory and only provided as a convenience of a "standardized" format.Another separator can be defined by using the
PersistenceId.of
that takes aseparator
parameter.The
|
separator is also used in Lagom'sscaladsl.PersistentEntity
but no separator is used in Lagom'sjavadsl.PersistentEntity
. For compatibility with Lagom'sjavadsl.PersistentEntity
you should use""
as the separator.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
contains|
-
of
public static PersistenceId of(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceId
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.Cluster Sharding is often used together with
EventSourcedBehavior
for the entities. ThePersistenceId
of theEventSourcedBehavior
can typically be constructed with:PersistenceId.of(entityContext.getEntityTypeKey().name(), entityContext.getEntityId())
That format of the
PersistenceId
is not mandatory and only provided as a convenience of a "standardized" format.The default separator
|
is used by theapply
that doesn't take aseparator
parameter.The
|
separator is also used in Lagom'sscaladsl.PersistentEntity
but no separator is used in Lagom'sjavadsl.PersistentEntity
. For compatibility with Lagom'sjavadsl.PersistentEntity
you should use""
as the separator.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
containsseparator
-
concat
public static java.lang.String concat(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs a persistence idString
from the givenentityTypeHint
andentityId
by concatenating them with|
separator.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
contains|
-
concat
public static java.lang.String concat(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs a persistence idString
from the givenentityTypeHint
andentityId
by concatenating them with theseparator
.- Throws:
java.lang.IllegalArgumentException
- if theentityTypeHint
orentityId
containsseparator
-
ofUniqueId
public static PersistenceId ofUniqueId(java.lang.String id)
Constructs aPersistenceId
withid
as the full unique identifier.
-
extractEntityType
public static java.lang.String extractEntityType(java.lang.String id)
Extract theentityTypeHint
from a persistence id String with the default separator|
. If the separator|
is not found it return the empty String (""
).
-
extractEntityId
public static java.lang.String extractEntityId(java.lang.String id)
Extract theentityId
from a persistence id String with the default separator|
. If the separator|
is not found it return theid
.
-
unapply
public static scala.Option<scala.Tuple2<java.lang.String,java.lang.String>> unapply(PersistenceId persistenceId)
-
id
public java.lang.String id()
-
entityTypeHint
public java.lang.String entityTypeHint()
-
entityId
public java.lang.String entityId()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-