JackFredLib
Home
  • 🏑Home
  • 🐘Setup with Gradle
  • πŸ“…Supported Versions
  • JackFredLib: Base
    • 🧱Overview
    • β˜‘οΈCodecs
  • JackFredLib: Colour
    • 🎨Overview
    • 🟒Colours
    • 🌈Gradients
  • JackFredLib: Extra Command Source Data
    • ⌨️Overview
  • JackFredLib: GPS
    • πŸ›°οΈOverview
    • πŸ—ΊοΈUsing Coordinates
    • πŸ”Refining Further
  • JackFredLib: Lying
    • πŸ€₯Overview
  • JackFredLIb: Toasts
    • 🍞Overview
  • JackFredLib: Config
    • βš™οΈOverview
Powered by GitBook
On this page
  • firstInList()
  • forEnum()
  • filtering()
  • oneOf()
  • mutableList(), mutableSet(), mutableMap()
  1. JackFredLib: Base

Codecs

JackFredLib also contains some helper methods when working with DataFixerUpper's Codecs:

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()

Creates an codec that decodes/encodes an Enum value. Represents this as a String with the Enum's name constant.

filtering()

Modifies the decoding stage of a codec so that it only succeeds if passing a predicate. Does not modify encoding.

Codec<Integer> EVEN_INTEGER = JFLCodecs.filtering(Codec.INT, i -> i % 2 == 0);

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.

Codec<Integer> SEARCH_RANGES = JFLCodecs.oneOf(Codec.INT, List.of(2, 4, 8, 16, 32, 64));

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.

PreviousOverviewNextOverview

Last updated 1 year ago

β˜‘οΈ