Class PersistenceId
- java.lang.Object
-
- org.apache.pekko.persistence.typed.PersistenceId
-
public final class PersistenceId extends java.lang.ObjectUnique 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 PersistenceIdapply(java.lang.String entityTypeHint, java.lang.String entityId)Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with|separator.static PersistenceIdapply(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with theseparator.static java.lang.StringDefaultSeparator()Default separator character used for concatenating atypeHintwithentityIdto construct unique persistenceId.java.lang.StringentityId()java.lang.StringentityTypeHint()booleanequals(java.lang.Object obj)static java.lang.StringextractEntityId(java.lang.String id)Extract theentityIdfrom a persistence id String with the default separator|.static java.lang.StringextractEntityType(java.lang.String id)Extract theentityTypeHintfrom a persistence id String with the default separator|.inthashCode()java.lang.Stringid()static PersistenceIdof(java.lang.String entityTypeHint, java.lang.String entityId)Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with|separator.static PersistenceIdof(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with theseparator.static PersistenceIdofUniqueId(java.lang.String id)Constructs aPersistenceIdwithidas the full unique identifier.java.lang.StringtoString()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 atypeHintwithentityIdto construct unique persistenceId.
-
apply
public static PersistenceId apply(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with|separator.Cluster Sharding is often used together with
EventSourcedBehaviorfor the entities. ThePersistenceIdof theEventSourcedBehaviorcan typically be constructed with:PersistenceId(entityContext.entityTypeKey.name, entityContext.entityId)That format of the
PersistenceIdis not mandatory and only provided as a convenience of a "standardized" format.Another separator can be defined by using the
applythat takes aseparatorparameter.- Throws:
java.lang.IllegalArgumentException- if theentityTypeHintorentityIdcontains|
-
apply
public static PersistenceId apply(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with theseparator.Cluster Sharding is often used together with
EventSourcedBehaviorfor the entities. ThePersistenceIdof theEventSourcedBehaviorcan typically be constructed with:PersistenceId(entityContext.entityTypeKey.name, entityContext.entityId)That format of the
PersistenceIdis not mandatory and only provided as a convenience of a "standardized" format.The default separator
|is used by theapplythat doesn't take aseparatorparameter.- Throws:
java.lang.IllegalArgumentException- if theentityTypeHintorentityIdcontainsseparator
-
of
public static PersistenceId of(java.lang.String entityTypeHint, java.lang.String entityId)
Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with|separator.Cluster Sharding is often used together with
EventSourcedBehaviorfor the entities. ThePersistenceIdof theEventSourcedBehaviorcan typically be constructed with:PersistenceId.of(entityContext.getEntityTypeKey().name(), entityContext.getEntityId())That format of the
PersistenceIdis not mandatory and only provided as a convenience of a "standardized" format.Another separator can be defined by using the
PersistenceId.ofthat takes aseparatorparameter.- Throws:
java.lang.IllegalArgumentException- if theentityTypeHintorentityIdcontains|
-
of
public static PersistenceId of(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
Constructs aPersistenceIdfrom the givenentityTypeHintandentityIdby concatenating them with theseparator.Cluster Sharding is often used together with
EventSourcedBehaviorfor the entities. ThePersistenceIdof theEventSourcedBehaviorcan typically be constructed with:PersistenceId.of(entityContext.getEntityTypeKey().name(), entityContext.getEntityId())That format of the
PersistenceIdis not mandatory and only provided as a convenience of a "standardized" format.The default separator
|is used by theapplythat doesn't take aseparatorparameter.- Throws:
java.lang.IllegalArgumentException- if theentityTypeHintorentityIdcontainsseparator
-
ofUniqueId
public static PersistenceId ofUniqueId(java.lang.String id)
Constructs aPersistenceIdwithidas the full unique identifier.
-
extractEntityType
public static java.lang.String extractEntityType(java.lang.String id)
Extract theentityTypeHintfrom 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 theentityIdfrom 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:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-