public interface IdCodec
Turns a
long id into text and back (03-core-model.md ยง1).
Codecs compose: the codec list of a generator applies in the order it is written, the first item turning the id
into text and the rest decorating that text, such as withPrefix(String).
-
Method Summary
Modifier and TypeMethodDescriptionlongDecodes text produced byencode(long).encode(long id) Encodes an id (R1-core-16).default IdCodecwithPrefix(String prefix) Prependsprefixto the encoded text.default IdCodecwithSuffix(String suffix) Appendssuffixto the encoded text.
-
Method Details
-
encode
Encodes an id (R1-core-16).- Parameters:
id- the id- Returns:
- the text, never null
- Throws:
IllegalArgumentException- if the codec cannot encodeid: one outside its range, such as a negative id, or one wider than the digits of a fixed-width radix; a codec never truncates
-
decode
Decodes text produced byencode(long).- Parameters:
text- the text- Returns:
- the id
- Throws:
IllegalArgumentException- if the text is not an encoded id
-
withPrefix
Prependsprefixto the encoded text.- Parameters:
prefix- the prefix- Returns:
- the decorated codec
-
withSuffix
Appendssuffixto the encoded text.- Parameters:
suffix- the suffix- Returns:
- the decorated codec
-