Fzzy Config

Validated Collections

Fzzy Config has validation tools for lists, maps, and sets. Each of these constructs has builders and other intricacies that are best digested thoroughly by visiting the documentation:

Validated Collections

Validation Conversion

Any ValidatedField can be converted into a list or set implementation with it as backing validation using the toList() and toSet() methods, respectively. In addition, collections can be converted to ValidatedChoice using their toChoices() method

//wraps the vararg valued provided with a blank validated field (identifiers in this case). validation with actual bounds and logic can of course be used too
public ValidatedList<Identifier> listFromField = new ValidatedIdentifier().toList(Identifier.of("stick"), Identifier.of("blaze_rod"));

Static Initializers

ValidatedList and Set have a series of static methods that can be used to initialize a variety of collections of given common types, much in the same vein as the java List.of() or kotlin listOf().

public ValidatedList<Integer> validatedIntList = ValidatedList.ofInt(1, 2, 5, 10);
public ValidatedSet<Integer> validatedIntSet = ValidatedSet.ofInt(1, 2, 5, 10);

Map Builders

Validated Maps come with builders for simple and flexible creation. These builders are "staged", walking you through the steps you need to properly build it, so they are technically pseudo-builders.

public ValidatedMap<Integer, Boolean> myMap = (new ValidatedMap.Builder())
.keyHandler(new ValidatedInt(2, 100, 0)) //first comes the key handler. The default value for this will be the initial value stored in the key when a new entry is added.
.valueHandler(new ValidatedBoolean()) //next the value handler.
.defaults(Map.of(5, true, 10, false, 15, true)) //default map values can be set a variety of ways
.build(); //build!