classSimpleName (internals/JavaReflectionUtil.scala)

scalikejdbc · scalikejdbc-orm/src/main/scala/scalikejdbc/orm/internals/JavaReflectionUtil.scala · Apache-2.0
database

Module exposing: classSimpleName, getterNames, getter

// Source: https://github.com/scalikejdbc/scalikejdbc | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package scalikejdbc.orm.internals

import java.lang.reflect.Modifier

/**
 * Java reflection API utils.
 */
object JavaReflectionUtil {

  /**
   * Returns the simple name of the object's class even if invoked on the Scala REPL.
   *
   * @param obj target object
   * @return simple class name
   */
  def classSimpleName(obj: Any): String = {
    try obj.getClass.getSimpleName
    catch {
      case _: InternalError =>
        // working on the Scala REPL
        val clazz = obj.getClass
        val classOfClazz = clazz.getClass
        val getSimpleBinaryName = classOfClazz.getDe

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key