Enum Class UuidFormat
- All Implemented Interfaces:
Serializable,Comparable<UuidFormat>,Constable
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)
@MarshalledProp(uuidFormat=…)on the bean property.@Marshalled(uuidFormat=…)on the bean class.@MarshalledConfig(uuidFormat=…)on-annotated classes / methods.@Rest - Programmatic
MarshallingContext.Builder.uuidFormat(UuidFormat). - Environment variable
MarshallingContext.uuidFormat . - 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).
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(UUID value, UuidFormat format) Formats the specifiedUUIDusing this format.booleanReturnstrue if this format is numeric on the wire.static UUIDparse(String value, UuidFormat format) Parses the specified wire value into aUUID.static UuidFormatReturns the enum constant of this class with the specified name.static UuidFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NOT_SET
Sentinel meaning "no value configured" — falls through to the next-higher precedence level. -
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
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
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
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
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 nameNullPointerException- if the argument is null
-
format
- Parameters:
value- The value to format. Can benull (returnsnull ).- Returns:
- The formatted wire representation, or
null ifvalueisnull .
-
parse
Parses the specified wire value into aUUID.Lenient parsing — accepts any of the three textual shapes (
STANDARD/NO_DASHES/URN) regardless of theformathint. The hint is informational only.- Parameters:
value- The wire value. Can benull or blank (returnsnull ).format- The configured format hint (informational only — parsing is format-agnostic). Can benull (ignored; parsing is format-agnostic).- Returns:
- The parsed
UUID, ornull ifvalueisnull or blank. - Throws:
IllegalArgumentException- If the value does not match any supported UUID textual shape.
-
isNumeric
Returnstrue if this format is numeric on the wire.Always
false — every constant emits a textual representation.- Returns:
false .
-