An object which takes a series of key-value pairs and combines them into an object using a series of fold-left style method calls.
An object which takes a series of key-value pairs and combines them into an object using a series of fold-left style method calls.
the type of keys used by the Parser that this Builder will be used by
the type of primitive value types used by the Parser that this Builder will be used by
possible ways this builder can fail
the type of object built by this Builder
4.0
A builder whose output is a cbor-formatted byte string.
A builder whose output is a cbor-formatted byte string.
Regarding numbers
I imagine giving this thing enough key-value pairs will result in an OutOfMemoryError when it tries to create the byte array, but I have yet to go about trying to detect and fast-fail in that situation, or creating a structure that is indistinguishable from a really long byte array
And beyond that, Cbor maps and arrays have a hard size limit of
2 ** 64 - 1
entries, even if the byte array size issue is overcome.
Well, assuming they're fixed arrays and not indefinite arrays, but
so far this only writes definite-length arrays.
4.0
3.0
A builder that creates maps.
A builder that creates maps.
4.0
A Builder which can be built piecewise.
A Builder which can be built piecewise.
the key types
the primitive value types
the type of object to build
case class Foo(a:String, b:Seq[JsonValue], c:String) val fooBuilder = (new PiecewiseBuilder[StringOrInt, JsonValue, Foo](new Foo("", Seq.empty, "")) .addDef(StringOrInt("a"), partitionedPrimitiveKeyDef({case JsonValueString(x) => Right(x)}, {(f:Foo, x:String) => f.copy(a = x)})) .addDef(StringOrInt("c"), partitionedPrimitiveKeyDef({case JsonValueString(x) => Right(x)}, {(f:Foo, x:String) => f.copy(c = x)})) .addDef(StringOrInt("b"), partitionedComplexKeyDef(new PrimitiveSeqBuilder[JsonValue], {(f:Foo, x:Seq[JsonValue]) => Right(f.copy(b = x))})) ) val jsonParser = new JsonParser jsonParser.parse(fooBuilder, """{"a":"","b":[]}""") // results in `Foo("", Seq.empty, "")` jsonParser.parse(fooBuilder, """{"a":"qwer","b":["z","x","c"],"c":"asdf"}""") // results in `Foo("qwer", Seq(JsonValueString("z"), JsonValueString("x"),JsonValueString("c")), "asdf")`
4.0
3.0
Inspired by https://github.com/scopt/scopt/
A builder whose output is a json-formatted string.
A builder whose output is a json-formatted string.
I imagine giving this thing enough key-value pairs will result in an OutOfMemoryError when it tries to create the string, but I have yet to go about trying to detect and fast-fail in that situation, or creating a structure that is indistinguishable from a really long Seq[Char]
4.0
3.0
A Builder that will build a Vector of values, where each inner value is a primitive value.
A Builder that will build a Vector of values, where each inner value is a primitive value.
This builder ignores keys completely, and adds elements to the sequence in encounter order.
#apply will return a left if the value is a complex value.
the type of primitive values encountered
the type of failure to return if this encounters a complex value
4.0
3.0
A Builder that will build a Vector of values, where each inner value is produced by the parameter builder.
A Builder that will build a Vector of values, where each inner value is produced by the parameter builder.
This builder ignores keys completely, and adds elements to the sequence in encounter order.
#apply will return a left if the value is a primitive value.
the type of keys encountered
the type of primitive values encountered
the type of complex values produced by the childBuilder
4.0
A Builder that will always return a failure on call to apply or finish
A Builder that will always return a failure on call to apply or finish
Mostly useful when a function wants a builder even though you 'know' the result must be primitive
4.0
Holds MapChildBuilder and several MapBuilder factory methods
Holds MapChildBuilder and several MapBuilder factory methods
3.0
KeyDef and several implementations
KeyDef and several implementations
4.0
3.0
PrettyParams and two implementations of it.
PrettyParams and two implementations of it.
3.0
4.0
4.0
Contains the various built-in builders.
Most built-in builders either build a serialized form (json, cbor), build a generic collection class (seq, map) or build a class that conforms to a stereotype (java bean, case class)