Codecs
JackFredLib also contains some helper methods when working with DataFixerUpper's Codecs:
firstInList()
firstInList()
Takes a list of codecs of a type, and returns a codec that tries them in sequential order until one does not error. Useful for very simple data migrations or data with simplified forms.
forEnum()
forEnum()
Creates an codec that decodes/encodes an Enum value. Represents this as a String with the Enum's name constant.
filtering()
filtering()
Modifies the decoding stage of a codec so that it only succeeds if passing a predicate. Does not modify encoding.
oneOf()
oneOf()
Modifies the decoding stage of a codec so that the decoded value is only allowed to be one of a set few values. A shallow copy is made of the given collection.
mutableList(), mutableSet(), mutableMap()
mutableList(), mutableSet(), mutableMap()
Modifiers for various collection codecs that make the resultant collections mutable, instance of the default Immutable collections. Can save needing to 'Post-Process' decoded data structures.
Last updated