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

  8. final class BeanBuilder[Value, A] extends Builder[String, Value, A]

    Permalink

    A builder that builds a JavaBean

    A builder that builds a JavaBean

    As with anything that works with java beans, this requires the class to have a zero-argument constructor and will interact with methods of the form setX.

    Value

    the parser's primitive values

    A

    the type of object to build

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) Terribly un type-safe. Either create a new Builder subclass or an instance of PiecewiseBuilder

    Version

    3.0

  9. final class CaseClassBuilder[Value, A <: Product] extends Builder[String, Value, A]

    Permalink

    A builder that builds a Case Class

    A builder that builds a Case Class

    Value

    the primitive values produced by the parser

    A

    the type of object to build

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) Terribly un type-safe. Either create a new Builder subclass or an instance of PiecewiseBuilder

    Version

    3.0

  10. final class CborArrayBuilder extends Builder[Any, CborValue, Seq[Byte]]

    Permalink

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

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

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) use CborBuilder instead

    Version

    3.0

  11. final class CborObjectBuilder extends Builder[CborValue, CborValue, Seq[Byte]]

    Permalink

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

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

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) use CborBuilder(true) instead

    Version

    3.0

  12. final class MinifiedJsonArrayBuilder extends Builder[Any, JsonValue, String]

    Permalink

    A builder whose output is an minified json array string.

    A builder whose output is an minified json array string.

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) use PrettyJsonBuilder(PrettyJsonBuilder.MinifiedPrettyParams) instead

    Version

    3.0

  13. final class MinifiedJsonObjectBuilder extends Builder[String, JsonValue, String]

    Permalink

    A builder whose output is an minified json object string.

    A builder whose output is an minified json object string.

    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) use PrettyJsonBuilder(PrettyJsonBuilder.MinifiedPrettyParams) instead

    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