Package

com.rayrobdod.json

builder

Permalink

package builder

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)

Source
package.scala
Linear Supertypes
Content Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. builder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Builder[-Key, -Value, Subject] extends AnyRef

    Permalink

    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.

    Key

    the type of keys used by the Parser that this Builder will be used by

    Value

    the type of primitive value types used by the Parser that this Builder will be used by

    Subject

    the type of object built by this Builder

    Version

    3.0

    See also

    com.rayrobdod.json.parser.Parser

  2. final class CborBuilder extends Builder[CborValue, CborValue, Seq[Byte]]

    Permalink

    A builder whose output is a cbor-formatted byte string.

    A builder whose output is a cbor-formatted byte string.

    Since

    3.0

    See also

    http://tools.ietf.org/html/rfc7049

  3. final class MapBuilder[K, V, Inner] extends Builder[K, V, Map[K, Either[Inner, V]]]

    Permalink

    A builder that creates maps.

    A builder that creates maps.

    Version

    3.0

  4. final class PiecewiseBuilder[Key, Value, Subject] extends Builder[Key, Value, Subject]

    Permalink

    A Builder which can be built piecewise.

    A Builder which can be built piecewise.

    Key

    the key types

    Value

    the primitive value types

    Subject

    the type of object to build

    Example:
    1. 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")`
    Since

    3.0

    See also

    Inspired by https://github.com/scopt/scopt/

  5. final class PrettyJsonBuilder extends Builder[StringOrInt, JsonValue, String]

    Permalink

    A builder whose output is a json-formatted string.

    A builder whose output is a json-formatted string.

    Since

    3.0

    See also

    http://json.org/

  6. final class PrimitiveSeqBuilder[Value] extends Builder[Any, Value, Seq[Value]]

    Permalink

    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.

    Value

    the type of primitive values encountered

    Since

    3.0

  7. final class SeqBuilder[-Key, -Value, Inner] extends Builder[Key, Value, Seq[Inner]]

    Permalink

    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.

    Key

    the type of keys encountered

    Value

    the type of primitive values encountered

    Inner

    the type of complex values produced by the childBuilder

    Version

    3.0

Value Members

  1. object MapBuilder

    Permalink

    Holds MapChildBuilder and several MapBuilder factory methods

    Holds MapChildBuilder and several MapBuilder factory methods

    Since

    3.0

  2. object PiecewiseBuilder

    Permalink

    KeyDef and several implementations

    KeyDef and several implementations

    Since

    3.0

  3. object PrettyJsonBuilder

    Permalink

    PrettyParams and two implementations of it.

    PrettyParams and two implementations of it.

    Since

    3.0

Inherited from AnyRef

Inherited from Any

Ungrouped