All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.getquill.util.LoadObject.scala Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
package io.getquill.util

import io.getquill.util.Messages._
import scala.reflect.macros.whitebox.Context
import scala.reflect.ClassTag

object LoadObject {

  def apply[T: ClassTag](c: Context)(typ: c.Type) = {
    LoadClass(typ.typeSymbol.fullName.trim + "$").toOption
      .map(cls => cls.getField("MODULE$").get(cls)) match {
        case Some(d: T) => d
        case other      => c.fail(s"Can't load object '${typ.typeSymbol.fullName}'.")
      }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy