Interface HasId

All Known Implementing Classes:
Id

public interface HasId
Interface for exposing a string-based representation of an object's identifier.

Implementing HasId enables objects with strongly typed IDs—such as UserId, ProjectId, or value objects—to participate in systems that require plain string identifiers, such as serialization, logging, or infrastructure-level APIs.

Use Cases

  • Allows conversion of strongly typed IDs to a standardized String format
  • Used in infrastructure components like MatchConstraint or document indexing where a plain string ID is required
  • Improves type-safety in domain models while maintaining compatibility with external systems

Example


 @Value
 public class UserId implements HasId {
     UUID value;

     @Override
     public String getId() {
         return value.toString();
     }
 }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the stringified identifier of this object.
  • Method Details

    • getId

      String getId()
      Returns the stringified identifier of this object.

      This is typically used for serialization or ID-based lookups.

      Returns:
      a non-null, plain string representation of the identifier