Class

argus.macros

ModelBuilder

Related Doc: package macros

Permalink

class ModelBuilder[U <: Universe] extends AnyRef

Helper to build the model class for a given schema.

U

wats dis? We need an explicit type to help the type checker see that our path-dependent type of Universe, is actually the same as the one used in the main macro class. ¯\_(ツ)_/¯. #loltypes

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ModelBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ModelBuilder(u: U)

    Permalink

    u

    The reflection universe. Can support macro and runtime reflection

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val IntrinsicType: List[Product with Serializable with SimpleType]

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. val helpers: ASTHelpers[u.type]

    Permalink
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. def mkAnyWrapper(path: List[String], name: String): (U.Tree, List[U.Tree])

    Permalink

    If there's no schema specified what do we do? It seems this leaves the json open to be anything.

    If there's no schema specified what do we do? It seems this leaves the json open to be anything. The best we can do is make it an Any type, but to stop things getting too far out of control we wrap it in a type so that we can maintain some control over the encoding/decodng (and allow for customization).

    path

    The package path to where this is type is defined.

    name

    The name of the wrapper class.

  15. def mkCaseClassDef(path: List[String], name: String, fields: List[Field], requiredFields: Option[List[String]]): (U.Tree, List[U.Tree])

    Permalink

    Main workhorse.

    Main workhorse. Creates case-classes from given fields.

  16. def mkDef(path: List[String], name: String, schema: Root): (U.Tree, List[U.Tree])

    Permalink

    Creates a Class/Type definition (i.e.

    Creates a Class/Type definition (i.e. creates a case class or type alias).

    name

    The name of the class/type to that is created

  17. def mkEnumDef(path: List[String], baseName: String, enum: List[String]): (U.Tree, List[U.Tree])

    Permalink

    Makes a representation of an enumeration type.

    Makes a representation of an enumeration type. We model this as a "sum type" in scala, where each enum is an object that inherits from the base trait. The base trait is sealed so that it can be used for pattern matching.

    baseName

    Name of the enum (becomes the name of the base trait)

    enum

    List of all possible enum values (encoded as a string containing their json representation)

    returns

    List[Tree] containing all the definitions

  18. def mkIntrinsicType(st: SimpleType): U.Tree

    Permalink

    Make a type from a SimpleType, when st is a built in type (i.e.

    Make a type from a SimpleType, when st is a built in type (i.e. Boolean, Int, Double, String, or Null)

  19. def mkSchemaDef(name: String, schema: Root, path: List[String] = Nil): (U.Tree, List[U.Tree])

    Permalink

    Makes all definitions required to define the given schema

    Makes all definitions required to define the given schema

    name

    The name of the root type that represents this schema

    schema

    The schema to generate from.

    path

    A package path for where this is defined. Defaults to Nil.

    returns

    A tuple containing the type of the root element that is generated, and all definitions required to support it

  20. def mkType(path: List[String], schema: Root, defaultName: String): (U.Tree, List[U.Tree])

    Permalink

    Extracts a type from the given Schema, using schema.typ or schema.$ref.

    Extracts a type from the given Schema, using schema.typ or schema.$ref. Usually this means referencing an existing type, be it a $ref or an intrinsic type.

    However since Schemas can contain nested anonymous types, sometimes as a side-effect we will also create new types (via mkDef()). In this case we name the anon type based on the given defaultName

    returns

    A tuple containing the Ident of the type, and a Tree of any addition class definitions that needed to be generated.

  21. def mkTypeAlias(path: List[String], name: String, toType: U.Tree): (U.Tree, List[U.Tree])

    Permalink

    Creates type alias definitions

    Creates type alias definitions

    returns

    A tuple containing the created type, and a type alias definition

  22. def mkUnionTypeDef(path: List[String], baseName: String, schemas: List[Root]): (U.Tree, List[U.Tree])

    Permalink

    Json allows type disjunctions, that is: parameters that can take on instances of A OR B.

    Json allows type disjunctions, that is: parameters that can take on instances of A OR B. This is modelled in scala using "sum types". Sum types wrap the allowed types (e.g. TypA(a: A), TypB(b: B)), and a common sealed base trait (e.g. Typ) to represent the union.

    baseName

    The name of the Union wrapper

    schemas

    A list of allowed sub-types

    returns

    A list of definitions created to support the union type.

  23. def mkValDef(path: List[String], field: Field, optional: Boolean): (U.ValDef, List[U.Tree])

    Permalink

    Makes a value definition (e.g.

    Makes a value definition (e.g. val i: Int). These are used for constructing parameter lists and declaring local objects

  24. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  25. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  28. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  29. val u: U

    Permalink

    The reflection universe.

    The reflection universe. Can support macro and runtime reflection

  30. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped