diff options
author | Kevin Wright <kevin.wright@bradyplc.com> | 2018-02-01 08:30:38 +0000 |
---|---|---|
committer | Kevin Wright <kevin.wright@bradyplc.com> | 2018-02-01 08:30:38 +0000 |
commit | a346b10556f8958834c14588e3443d3922d66f89 (patch) | |
tree | 261d69b43c4e2ee1fae83b9b22c4001e1fb3145f /core/shared/src/main/scala/interface.scala | |
parent | 4d1bf3ad68b3def3bbdc7ac8c45cb1a72c2c4e09 (diff) | |
download | magnolia-a346b10556f8958834c14588e3443d3922d66f89.tar.gz magnolia-a346b10556f8958834c14588e3443d3922d66f89.tar.bz2 magnolia-a346b10556f8958834c14588e3443d3922d66f89.zip |
Added annotation capture to params
Added test for annotation capture
Updated to lamdafied syntax for SAM type construction
Minor changes to permit compilation under JDK 9
Added Kevin Wright as a contributor
Diffstat (limited to 'core/shared/src/main/scala/interface.scala')
-rw-r--r-- | core/shared/src/main/scala/interface.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/shared/src/main/scala/interface.scala b/core/shared/src/main/scala/interface.scala index 846eee9..427c84c 100644 --- a/core/shared/src/main/scala/interface.scala +++ b/core/shared/src/main/scala/interface.scala @@ -25,6 +25,8 @@ trait Subtype[Typeclass[_], Type] { /** partial function defined the subset of values of `Type` which have the type of this subtype */ def cast: PartialFunction[Type, SType] + + override def toString: String = s"Subtype(${typeName.full})" } /** represents a parameter of a case class @@ -89,6 +91,10 @@ trait Param[Typeclass[_], Type] { * @param param the instance of the case class to be dereferenced * @return the parameter value */ def dereference(param: Type): PType + + def annotations: Seq[Any] + + override def toString: String = s"Param($label)" } /** represents a case class or case object and the context required to construct a new typeclass @@ -110,6 +116,7 @@ abstract class CaseClass[Typeclass[_], Type] private[magnolia] ( parametersArray: Array[Param[Typeclass, Type]] ) { + override def toString: String = s"CaseClass(${typeName.full}, ${parameters.mkString(",")})" /** constructs a new instance of the case class type * * This method will be implemented by the Magnolia macro to make it possible to construct @@ -128,7 +135,7 @@ abstract class CaseClass[Typeclass[_], Type] private[magnolia] ( /** constructs a new instance of the case class type * - * Like [[construct]] this method is implemented by Magnolia and let's you construct case class + * Like [[construct]] this method is implemented by Magnolia and lets you construct case class * instances generically in user code, without knowing their type concretely. * * `rawConstruct`, however, is more low-level in that it expects you to provide a [[Seq]] @@ -152,7 +159,6 @@ abstract class CaseClass[Typeclass[_], Type] private[magnolia] ( * * Instances of `SealedTrait` provide access to all of the component subtypes of the sealed trait * which form a coproduct, and to the fully-qualified name of the sealed trait. - * * @param typeName the name of the sealed trait * @param subtypesArray an array of [[Subtype]] instances for each subtype in the sealed trait * @tparam Typeclass type constructor for the typeclass being derived @@ -160,6 +166,8 @@ abstract class CaseClass[Typeclass[_], Type] private[magnolia] ( final class SealedTrait[Typeclass[_], Type](val typeName: TypeName, subtypesArray: Array[Subtype[Typeclass, Type]]) { + override def toString: String = s"SealedTrait($typeName, Array[${subtypes.mkString(",")}])" + /** a sequence of all the subtypes of this sealed trait */ def subtypes: Seq[Subtype[Typeclass, Type]] = subtypesArray |