summaryrefslogtreecommitdiffstats
path: root/container-test-jars/jersey-resources/src/main/scala/com/yahoo/container/test/jars/jersey/resources/TestResourceBase.scala
blob: 5ccd89b30aced902c364ed12055d71d356874482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.test.jars.jersey.resources

import javax.ws.rs.core.MediaType
import javax.ws.rs.{Produces, GET}

import scala.reflect.ClassTag

/**
 * @author tonytv
 */
class TestResourceBase {
  @GET
  @Produces(Array(MediaType.TEXT_PLAIN))
  def get() = TestResourceBase.content(getClass)
}

object TestResourceBase {
  def content(clazz: Class[_ <: TestResourceBase]): String =
    "Response from " + clazz.getName

  def content[T <: TestResourceBase](implicit classTag: ClassTag[T]): String = {
    val clazz = classTag.runtimeClass.asInstanceOf[Class[_ <: TestResourceBase]]
    content(clazz)
  }
}