Package

emblem.emblematic.traversors

sync

Permalink

package sync

holds types and zero values used by synchronous traversors

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

Type Members

  1. trait CustomGenerator[A] extends AnyRef

    Permalink

    a custom generator for things of type A.

    a custom generator for things of type A. the apply method takes a type parameter that is tighter than A, and acquires a TypeKey for that type, so it can customize its behavior based on the type requested.

    the apply method also takes a Generator as argument, so that it can call back into to the calling Generator to generate complex values.

    example usage:

    // always generates a 5-element list
    val listCustomGenerator = new CustomGenerator[List[Any]] {
      def apply[B <: List[_] : TypeKey](generator: Generator): B = {
        val eltTypeKey = typeKey[B].typeArgs.head
        val eltList = List.fill(5) { generator.generate(eltTypeKey) }
        eltList.asInstanceOf[B]
      }
    }
    val generator = new TestDataGenerator(customGeneratorPool = CustomGeneratorPool.empty + listCustomGenerator)
  2. type CustomGeneratorPool = TypeKeyMap[Any, CustomGenerator]

    Permalink

    a TypeKeyMap for generator functions

  3. trait CustomVisitor[A] extends AnyRef

    Permalink

    a custom visitor for elements of type A.

    a custom visitor for elements of type A. the apply method takes a type parameter that is tighter than A, and acquires a TypeKey for that type, so it can customize its behavior based on the type requested.

    the apply method also takes a Visitor as argument, so that it can call back into to the calling Visitor to visit complex values.

    example usage:

    // only visit the first five elements of a list
    val listCustomVisitor = new CustomVisitor[List[Any]] {
      def apply[B <: List[_] : TypeKey](visitor: Visitor, list: B): Unit = {
        val elementTypeKey = typeKey[B].typeArgs.head
        def visitFive[C : TypeKey]: Unit =
          list.asInstanceOf[List[C]].take(5).foreach { element => visitor.visit(element) }
        visitFive(elementTypeKey)
      }
    }
    
    val visitor = new Visitor {
      override protected val customVisitors: CustomVisitorPool = CustomVisitorPool.empty + listCustomVisitor
    }
  4. class Differ extends AnyRef

    Permalink

    recursively computes a sequence of diffs between two different values of the same type.

    recursively computes a sequence of diffs between two different values of the same type.

    we kind of have to bail on traversing sets, since there is no obvious way to pull out matching pairs of elements from the lhs and rhs sets. if the sets have differing sizes, then we report the difference in size. if the sets are otherwise different, then we report the sets as different.

    we similarly do not attempt to differentiate between Union values representing different constituent types. we just report that the type doesn't match.

  5. class EmblematicToJsonTranslator extends Traversor

    Permalink

    translates emblematic types into json4s AST.

    translates emblematic types into json4s AST.

    non top-level emblems with a single property will be inlined in the JSON. does not inline unions.

  6. trait Generator extends AnyRef

    Permalink

    recursively generates a data structure by type.

    recursively generates a data structure by type.

    you can generate arbritrary data to your liking by implementing the protected vals and defs in this interface. as of yet, i haven't been able to generate the scaladoc for those protected methods. sorry about that.

    See also

    TestDataGenerator for an example usage

  7. class JsonToEmblematicTranslator extends Traversor

    Permalink

    translates json4s AST into emblematic types.

    translates json4s AST into emblematic types.

    expects JSON for non top-level emblems with a single property to inline those emblems. does not expect inlined unions.

  8. class TestDataGenerator extends Generator

    Permalink

    generates test data for a pool of extractors, a pool of emblems, and some custom generators.

    generates test data for a pool of extractors, a pool of emblems, and some custom generators. you can generate any kind of data you like by providing the appropriate TypeKey to TestDataGenerator.generate. or you can use the provided methods for generating specific kinds of data. if the generator does not know how to generate for the type you requested, it will throw a emblem.exceptions.CouldNotGenerateException.

    out of the box, a TestDataGenerator knows how to generate the following basic and collection types:

    • boolean
    • char
    • double
    • float
    • int
    • long
    • string
    • list
    • option
    • set

    you can extend this behavior by supplying the generator with an Emblematic and custom generators.

  9. trait Transformer extends AnyRef

    Permalink

    synchronously tranforms a recursive data structure.

    synchronously tranforms a recursive data structure. the input and the output of the transformation have the same type.

    you can transform arbritrary data to your liking by implementing the protected vals and defs in this interface.

    the only usage example as of now, longevity.testUtil.PersistedToUnpersistedTransformer, lives outside of emblem project, in sibling project longevity. it might give you some ideas in how to use, but then so will other traversors in this directory.

  10. trait Traversor extends AnyRef

    Permalink

    synchronously traverses a recursive data structure.

    synchronously traverses a recursive data structure. the inputs and the outputs of the traversal are abstract here, and specified by the implementing class. this forms a generic pattern for visiting, generating, and transforming data.

    you can traverse arbritrary data to your liking by implementing the protected vals and defs in this interface.

  11. trait Visitor extends AnyRef

    Permalink

    recursively visits a data structure by type.

    recursively visits a data structure by type.

    you can visit arbritrary data to your liking by implementing the protected vals and defs in this interface. as yet, i haven't been able to generate the scaladoc for those protected methods. sorry about that.

    WARNING: as of yet, this code is completely untested, and there is no example usage for you to follow.

Value Members

  1. object CustomGenerator

    Permalink
  2. object CustomGeneratorPool

    Permalink
  3. object Differ

    Permalink
  4. object Transformer

    Permalink

    holds types and zero values used by the transformers, and supplies the API for custom tranformers

  5. object Visitor

    Permalink

    holds types and zero values used by the visitors

Inherited from AnyRef

Inherited from Any

Ungrouped