ca.ibodrov.mica.api.model.EntityId Maven / Gradle / Ivy
The newest version!
package ca.ibodrov.mica.api.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.UUID;
import static com.fasterxml.jackson.annotation.JsonCreator.Mode.DELEGATING;
import static java.util.Objects.requireNonNull;
public record EntityId(UUID id) {
@JsonCreator(mode = DELEGATING)
public EntityId {
requireNonNull(id);
}
@Override
@JsonValue
public UUID id() {
return id;
}
public String toExternalForm() {
return id.toString();
}
public static EntityId fromString(String s) {
return new EntityId(UUID.fromString(s));
}
@Override
public String toString() {
return "EntityId=" + id;
}
}