This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def matchExhaustivelyImplImpl[T: Type]( | |
self: Expr[T], | |
expr: Expr[T => Any], | |
m: Expr[Mirror.Of[T]] | |
)(using q: Quotes): Expr[Any] = | |
import q.reflect.{*, given} | |
val expectedCases = m match | |
case '{ $m: Mirror.ProductOf[s] } => Seq(TypeRepr.of[T]) | |
case '{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main { | |
def main(args: Array[String]) = { | |
implicit val showInt = new Show[Int] { | |
override def show(a: Int): String = a.toString | |
} | |
| |
implicit val readInt = new Read[Int] { | |
override def read(s: String): Int = s.toInt | |
} | |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun <A : Annotation> getAnnotationsByType(annotationType: Class<A>): Array<out A> { | |
require(annotationType.isAnnotation) { "Not an annotation type: $annotationType" } | |
/* If the annotation class we are interested in is repeatable, then the annotation class must itself | |
be annotated with the java.lang.annotation.Repeatable meta-annotation. For the repeatable annotation class | |
there must be another annotation class whose property is an array of the repeatable annotation. Example: | |
``` | |
@Repeatable(value = Foos::class) | |
annotation class Foo // Foo is the contained class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.simpleframework.xml.Attribute; | |
import org.simpleframework.xml.Element; | |
import org.simpleframework.xml.ElementList; | |
import org.simpleframework.xml.Namespace; | |
import org.simpleframework.xml.NamespaceList; | |
import org.simpleframework.xml.Root; | |
import org.simpleframework.xml.Text; | |
import java.util.List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* example implementation of GenericRecyclerAdapter.Item | |
**/ | |
public class ExampleItem extends GenericRecyclerAdapter.Item { | |
public String title; | |
public ExampleItem(String title) | |
{ | |
this.title = title; | |
} |