Class 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 a PersistenceId from the given entityTypeHint and entityId by concatenating them with | separator.
      static PersistenceId apply​(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
      Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with the separator.
      static java.lang.String DefaultSeparator()
      Default separator character used for concatenating a typeHint with entityId to construct unique persistenceId.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      java.lang.String id()  
      static PersistenceId of​(java.lang.String entityTypeHint, java.lang.String entityId)
      Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with | separator.
      static PersistenceId of​(java.lang.String entityTypeHint, java.lang.String entityId, java.lang.String separator)
      Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with the separator.
      static PersistenceId ofUniqueId​(java.lang.String id)
      Constructs a PersistenceId with id as the full unique identifier.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PersistenceId

        public PersistenceId()
    • Method Detail

      • DefaultSeparator

        public static java.lang.String DefaultSeparator()
        Default separator character used for concatenating a typeHint with entityId to construct unique persistenceId. This must be same as in Lagom's scaladsl.PersistentEntity, for compatibility. No separator is used in Lagom's javadsl.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 a PersistenceId from the given entityTypeHint and entityId by concatenating them with | separator.

        Cluster Sharding is often used together with EventSourcedBehavior for the entities. The PersistenceId of the EventSourcedBehavior 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 a separator parameter.

        The | separator is also used in Lagom's scaladsl.PersistentEntity but no separator is used in Lagom's javadsl.PersistentEntity. For compatibility with Lagom's javadsl.PersistentEntity you should use "" as the separator.

        Throws:
        java.lang.IllegalArgumentException - if the entityTypeHint or entityId contains |
      • apply

        public static PersistenceId apply​(java.lang.String entityTypeHint,
                                          java.lang.String entityId,
                                          java.lang.String separator)
        Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with the separator.

        Cluster Sharding is often used together with EventSourcedBehavior for the entities. The PersistenceId of the EventSourcedBehavior 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 the apply that doesn't take a separator parameter.

        The | separator is also used in Lagom's scaladsl.PersistentEntity but no separator is used in Lagom's javadsl.PersistentEntity. For compatibility with Lagom's javadsl.PersistentEntity you should use "" as the separator.

        Throws:
        java.lang.IllegalArgumentException - if the entityTypeHint or entityId contains separator
      • of

        public static PersistenceId of​(java.lang.String entityTypeHint,
                                       java.lang.String entityId)
        Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with | separator.

        Cluster Sharding is often used together with EventSourcedBehavior for the entities. The PersistenceId of the EventSourcedBehavior 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 a separator parameter.

        The | separator is also used in Lagom's scaladsl.PersistentEntity but no separator is used in Lagom's javadsl.PersistentEntity. For compatibility with Lagom's javadsl.PersistentEntity you should use "" as the separator.

        Throws:
        java.lang.IllegalArgumentException - if the entityTypeHint or entityId contains |
      • of

        public static PersistenceId of​(java.lang.String entityTypeHint,
                                       java.lang.String entityId,
                                       java.lang.String separator)
        Constructs a PersistenceId from the given entityTypeHint and entityId by concatenating them with the separator.

        Cluster Sharding is often used together with EventSourcedBehavior for the entities. The PersistenceId of the EventSourcedBehavior 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 the apply that doesn't take a separator parameter.

        The | separator is also used in Lagom's scaladsl.PersistentEntity but no separator is used in Lagom's javadsl.PersistentEntity. For compatibility with Lagom's javadsl.PersistentEntity you should use "" as the separator.

        Throws:
        java.lang.IllegalArgumentException - if the entityTypeHint or entityId contains separator
      • ofUniqueId

        public static PersistenceId ofUniqueId​(java.lang.String id)
        Constructs a PersistenceId with id as the full unique identifier.
      • id

        public java.lang.String id()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object