fromString static method

TracingUUID fromString(
  1. String? uuid,
  2. TraceIdRepresentation representation
)

Implementation

static TracingUUID fromString(
    String? uuid, TraceIdRepresentation representation) {
  if (uuid == null) {
    return TracingUUID(BigInt.zero);
  }

  switch (representation) {
    case TraceIdRepresentation.decimal:
      final value = BigInt.tryParse(uuid);
      if (value != null) {
        return TracingUUID(value);
      }
      break;
    case TraceIdRepresentation.hex:
    case TraceIdRepresentation.hex16Chars:
    case TraceIdRepresentation.hex32Chars:
      final value = BigInt.tryParse(uuid, radix: 16);
      if (value != null) {
        return TracingUUID(value);
      }
      break;
  }

  return TracingUUID(BigInt.zero);
}