Package me.ahoo.cosid.jackson
Annotation Interface AsString
Writes a
long / Long id as JSON text and reads it back (07-runtime-and-spring.md ยง5).
The text is either the codec of a runtime generator (generator(), which needs a CosIdJacksonModule
bound to the runtime) or an inline codec():
@AsString long id; // radix 62, 11 digits, padded (as in 4.x)
@AsString(generator = "order") long orderId; // the codec of generator "order"
@AsString(codec = Codec.TO_STRING) long a; // decimal text
@AsString(radix = 36, width = 13, padStart = false) long b;
@AsString(codec = Codec.FRIENDLY, layout = Preset.SNOWFLAKE_S, zone = "Asia/Shanghai") long c;
@AsString(codec = Codec.FRIENDLY, timeBits = 41, nodeBits = 5, seqBits = 17) long d;
Reading also accepts a JSON number that the codec could have written, and reads an empty string as null.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe inline codecs (the 4.xAsString.Type).static enumTheLayoutpresets of a friendly id. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe inline codec.longAsString.Codec.FRIENDLY: the epoch in milliseconds.A generator of the bound runtime whose codec writes the text; set, the inline attributes must stay unset.AsString.Codec.FRIENDLY: the layout preset, or the base oftimeBits(),nodeBits(),seqBits()andepoch()when they are set.intAsString.Codec.FRIENDLY: the node bits.booleanAsString.Codec.RADIXandAsString.Codec.FRIENDLY: pads to the full width with leading zeros.intAsString.Codec.RADIX: the radix, 2 to 62.intAsString.Codec.FRIENDLY: the sequence bits.intintAsString.Codec.FRIENDLY: the time zone of the date and time.
-
Element Details
-
generator
String generatorA generator of the bound runtime whose codec writes the text; set, the inline attributes must stay unset.- Returns:
- the generator name, empty for the inline
codec()
- Default:
""
-
codec
AsString.Codec codecThe inline codec.- Returns:
- the codec
- Default:
RADIX
-
radix
int radixAsString.Codec.RADIX: the radix, 2 to 62.- Returns:
- the radix
- Default:
62
-
width
int width- Returns:
- the width
- Default:
0
-
padStart
boolean padStartAsString.Codec.RADIXandAsString.Codec.FRIENDLY: pads to the full width with leading zeros.- Returns:
- whether to pad
- Default:
true
-
layout
AsString.Preset layoutAsString.Codec.FRIENDLY: the layout preset, or the base oftimeBits(),nodeBits(),seqBits()andepoch()when they are set.- Returns:
- the preset
- Default:
SNOWFLAKE_MS
-
timeBits
int timeBits- Returns:
- the bits,
0for the preset's
- Default:
0
-
nodeBits
int nodeBitsAsString.Codec.FRIENDLY: the node bits.- Returns:
- the bits,
-1for the preset's
- Default:
-1
-
seqBits
int seqBitsAsString.Codec.FRIENDLY: the sequence bits.- Returns:
- the bits,
0for the preset's
- Default:
0
-
epoch
long epochAsString.Codec.FRIENDLY: the epoch in milliseconds.- Returns:
- the epoch,
-1for the preset's
- Default:
-1L
-
zone
String zoneAsString.Codec.FRIENDLY: the time zone of the date and time.- Returns:
- the zone id, empty for the system default
- Default:
""
-