Enum Class UuidFormat

java.lang.Object
java.lang.Enum<UuidFormat>
org.apache.juneau.marshall.UuidFormat
All Implemented Interfaces:
Serializable, Comparable<UuidFormat>, Constable

public enum UuidFormat extends Enum<UuidFormat>
Supported wire formats for UUID values.

Used by MarshallingContext.Builder.uuidFormat(UuidFormat), Marshalled.uuidFormat(), MarshalledProp.uuidFormat(), and MarshalledConfig.uuidFormat() to control how UUID values are written to text-based wire formats.

The default is STANDARD which preserves the historical wire output produced by UUID.toString() (8-4-4-4-12 hyphenated form).

Precedence (highest to lowest)
  1. @MarshalledProp(uuidFormat=…) on the bean property.
  2. @Marshalled(uuidFormat=…) on the bean class.
  3. @MarshalledConfig(uuidFormat=…) on @Rest-annotated classes / methods.
  4. Programmatic MarshallingContext.Builder.uuidFormat(UuidFormat).
  5. Environment variable MarshallingContext.uuidFormat.
  6. The default constant (STANDARD).
Parser leniency

Parsers SHALL accept any wire shape that the corresponding serializer can produce, regardless of the parser-side UuidFormat setting. Each constant accepts all three textual shapes (STANDARD / NO_DASHES / URN) — the configured constant is informational and is consulted only as a hint.

Binary serializers

Binary serializers (BSON / CBOR / MsgPack / Prototext) emit native 16-byte binary regardless of the configured UuidFormat; this setting only affects text-based serializers. BSON in particular uses binData subtype 4 (UUID).

  • Enum Constant Details

    • NOT_SET

      public static final UuidFormat NOT_SET
      Sentinel meaning "no value configured" — falls through to the next-higher precedence level.
    • STANDARD

      public static final UuidFormat STANDARD
      8-4-4-4-12 hyphenated form (the default).
      Example:

      550e8400-e29b-41d4-a716-446655440000

      Round-trips through UUID.toString() / UUID.fromString(String).

    • NO_DASHES

      public static final UuidFormat NO_DASHES
      Compact 32-hex-character form (no hyphens).
      Example:

      550e8400e29b41d4a716446655440000

      Useful for URL paths, database column keys, and other compact-token use cases where the standard hyphens add noise.

    • URN

      public static final UuidFormat URN
      RFC 4122 URN namespace form.
      Example:

      urn:uuid:550e8400-e29b-41d4-a716-446655440000

      Surfaces in JSON-LD, SOAP, and some semantic-web payloads.

  • Method Details

    • values

      public static UuidFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UuidFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • format

      public static String format(UUID value, UuidFormat format)
      Formats the specified UUID using this format.

      NOT_SET falls through to STANDARD.

      Parameters:
      value - The value to format. Can be null (returns null).
      Returns:
      The formatted wire representation, or null if value is null.
    • parse

      public static UUID parse(String value, UuidFormat format)
      Parses the specified wire value into a UUID.

      Lenient parsing — accepts any of the three textual shapes (STANDARD / NO_DASHES / URN) regardless of the format hint. The hint is informational only.

      Parameters:
      value - The wire value. Can be null or blank (returns null).
      format - The configured format hint (informational only — parsing is format-agnostic). Can be null (ignored; parsing is format-agnostic).
      Returns:
      The parsed UUID, or null if value is null or blank.
      Throws:
      IllegalArgumentException - If the value does not match any supported UUID textual shape.
    • isNumeric

      public boolean isNumeric()
      Returns true if this format is numeric on the wire.

      Always false — every constant emits a textual representation.

      Returns:
      false.