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

scalikejdbc.ClassNameUtil.scala Maven / Gradle / Ivy

package scalikejdbc

private[scalikejdbc] object ClassNameUtil {

  /**
   * Returns the canonical name of a given class. If getCanonicalName doesn't return expected value, this method returns the value came from getName instead.
   * @param clazz a given class object
   */
  def getClassName(clazz: Class[_]): String = {
    val canonicalName: Option[String] = try {
      Option(clazz.getCanonicalName)
    } catch {
      case e: InternalError if e.getMessage == "Malformed class name" => None
    }
    canonicalName match {
      case Some(className) => className
      case _ => clazz.getName
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy