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)
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 }
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.
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.
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.
TestDataGenerator for an example usage
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.
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:
you can extend this behavior by supplying the generator with an Emblematic and custom generators.
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.
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.
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.
holds types and zero values used by the transformers, and supplies the API for custom tranformers
holds types and zero values used by the visitors
holds types and zero values used by synchronous traversors