Object

fm.common

ClassUtil

Related Doc: package common

Permalink

object ClassUtil extends Logging

This contains utility methods for scanning Classes or Files on the classpath.

Originally we used the classpath scanning functionality in the Spring Framework and then later switched to the Reflections library (https://code.google.com/p/reflections/) to avoid the dependency on Spring. At some point we ran into issues with the Reflections library not properly detecting classes so I ended up writing this as a replacement.

Linear Supertypes
Logging, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClassUtil
  2. Logging
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def canCreateInstanceOf(cls: Class[_]): Boolean

    Permalink

    Can an instance of this class be created using a zero-args constructor?

  6. def canCreateInstanceOfOrIsObject(cls: Class[_]): Boolean

    Permalink

    Can an instance of this class be created using a zero-args constructor?

  7. def classExists(cls: String, classLoader: ClassLoader): Boolean

    Permalink

    Check if a class exists.

  8. def classExists(cls: String): Boolean

    Permalink

    Check if a class exists.

  9. def classForName(cls: String, classLoader: ClassLoader): Class[_]

    Permalink
  10. def classForName(cls: String): Class[_]

    Permalink
  11. def classpathContentLength(file: File, classLoader: ClassLoader): Long

    Permalink

    Lookup the legnth for a resource on the classpath

  12. def classpathContentLength(file: File): Long

    Permalink

    Lookup the legnth for a resource on the classpath

  13. def classpathContentLength(file: String, classLoader: ClassLoader): Long

    Permalink

    Lookup the legnth for a resource on the classpath

  14. def classpathContentLength(file: String): Long

    Permalink

    Lookup the legnth for a resource on the classpath

  15. def classpathDirExists(file: File, classLoader: ClassLoader): Boolean

    Permalink

    Check if a directory exists on the classpath

  16. def classpathDirExists(file: File): Boolean

    Permalink

    Check if a directory exists on the classpath

  17. def classpathDirExists(file: String, classLoader: ClassLoader): Boolean

    Permalink

    Check if a directory exists on the classpath

  18. def classpathDirExists(file: String): Boolean

    Permalink

    Check if a directory exists on the classpath

  19. def classpathFileExists(file: File, classLoader: ClassLoader): Boolean

    Permalink

    Check if a file exists on the classpath

  20. def classpathFileExists(file: File): Boolean

    Permalink

    Check if a file exists on the classpath

  21. def classpathFileExists(file: String, classLoader: ClassLoader): Boolean

    Permalink

    Check if a file exists on the classpath

  22. def classpathFileExists(file: String): Boolean

    Permalink

    Check if a file exists on the classpath

  23. def classpathLastModified(file: File, classLoader: ClassLoader): Long

    Permalink

    Lookup the lastModified timestamp for a resource on the classpath

  24. def classpathLastModified(file: File): Long

    Permalink

    Lookup the lastModified timestamp for a resource on the classpath

  25. def classpathLastModified(file: String, classLoader: ClassLoader): Long

    Permalink

    Lookup the lastModified timestamp for a resource on the classpath

  26. def classpathLastModified(file: String): Long

    Permalink

    Lookup the lastModified timestamp for a resource on the classpath

  27. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  28. def companionObject(cls: Class[_]): AnyRef

    Permalink
  29. def companionObjectAs[T <: AnyRef](cls: Class[_], asCls: Class[T]): T

    Permalink
  30. def companionObjectAs[T <: AnyRef](cls: Class[_])(implicit arg0: ClassTag[T]): T

    Permalink
  31. def companionObjectClass(cls: Class[_]): Class[_]

    Permalink

    Lookup the companion object class for a class

  32. def companionObjectClass(cls: String, classLoader: ClassLoader): Class[_]

    Permalink

    Lookup the companion object class for a class

  33. def companionObjectClass(cls: String): Class[_]

    Permalink

    Lookup the companion object class for a class

  34. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  35. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  36. def findAnnotatedClasses[T <: Annotation](basePackage: String, annotationClass: Class[T], classLoader: ClassLoader): Set[Class[_]]

    Permalink

    Find all classes annotated with a Java Annotation.

    Find all classes annotated with a Java Annotation.

    Note: This loads ALL classes under the basePackage!

  37. def findAnnotatedClasses[T <: Annotation](basePackage: String, annotationClass: Class[T]): Set[Class[_]]

    Permalink

    Find all classes annotated with a Java Annotation.

    Find all classes annotated with a Java Annotation.

    Note: This loads ALL classes under the basePackage!

  38. def findClassNames(basePackage: String, classLoader: ClassLoader): Set[String]

    Permalink

    Find all class names under the base package (includes anonymous/inner/objects etc...)

  39. def findClassNames(basePackage: String): Set[String]

    Permalink

    Find all class names under the base package (includes anonymous/inner/objects etc...)

  40. def findClasspathFiles(basePackage: String, classLoader: ClassLoader): Set[File]

    Permalink

    Recursively Find files on the classpath given a base package.

  41. def findClasspathFiles(basePackage: String): Set[File]

    Permalink

    Recursively Find files on the classpath given a base package.

  42. def findImplementingClasses[T](basePackage: String, clazz: Class[T], classLoader: ClassLoader): Set[Class[_ <: T]]

    Permalink

    Find all concrete classes that extend a trait/interface/class.

    Find all concrete classes that extend a trait/interface/class.

    Note: This loads ALL classes under the basePackage and uses Class.isAssignableFrom for checking.

  43. def findImplementingClasses[T](basePackage: String, clazz: Class[T]): Set[Class[_ <: T]]

    Permalink

    Find all concrete classes that extend a trait/interface/class.

    Find all concrete classes that extend a trait/interface/class.

    Note: This loads ALL classes under the basePackage and uses Class.isAssignableFrom for checking.

  44. def findImplementingObjects[T <: AnyRef](basePackage: String, clazz: Class[T], classLoader: ClassLoader): Set[T]

    Permalink

    Finds all Scala Objects that extends a trait/interface/class.

    Finds all Scala Objects that extends a trait/interface/class.

    Note: This loads ALL classes under the basePackage and uses Class.isAssignableFrom for checking.

  45. def findImplementingObjects[T <: AnyRef](basePackage: String, clazz: Class[T]): Set[T]

    Permalink

    Finds all Scala Objects that extends a trait/interface/class.

    Finds all Scala Objects that extends a trait/interface/class.

    Note: This loads ALL classes under the basePackage and uses Class.isAssignableFrom for checking.

  46. def findLoadedClass(cls: String, classLoader: ClassLoader): Option[Class[_]]

    Permalink
  47. def findLoadedClass(cls: String): Option[Class[_]]

    Permalink
  48. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  49. def getClassForName(cls: String, classLoader: ClassLoader): Option[Class[_]]

    Permalink
  50. def getClassForName(cls: String): Option[Class[_]]

    Permalink
  51. def getCompanionObject(cls: Class[_]): Option[AnyRef]

    Permalink
  52. def getCompanionObjectAs[T <: AnyRef](cls: Class[_], asCls: Class[T]): Option[T]

    Permalink
  53. def getCompanionObjectAs[T <: AnyRef](cls: Class[_])(implicit arg0: ClassTag[T]): Option[T]

    Permalink
  54. def getCompanionObjectClass(cls: Class[_]): Option[Class[_]]

    Permalink
  55. def getCompanionObjectClass(cls: String, classLoader: ClassLoader): Option[Class[_]]

    Permalink

    Lookup the companion object class for a class

  56. def getCompanionObjectClass(cls: String): Option[Class[_]]

    Permalink

    Lookup the companion object class for a class

  57. def getNewInstanceOrObject[T <: AnyRef](cls: Class[T]): Option[T]

    Permalink

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

  58. def getNewInstanceOrObjectAs[T <: AnyRef](cls: Class[_], asCls: Class[T]): Option[T]

    Permalink

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

    cls

    The class to create an instance of (or to get the Object instance for)

    asCls

    The return type

  59. def getNewInstanceOrObjectAs[T <: AnyRef](cls: Class[_])(implicit arg0: ClassTag[T]): Option[T]

    Permalink
  60. def getScalaObject(objectCls: Class[_]): Option[AnyRef]

    Permalink

    Returns the Scala object instance for this class (if it is the class of a Scala object)

  61. def getScalaObjectAs[T <: AnyRef](objectCls: Class[_], asCls: Class[T]): Option[T]

    Permalink

    Returns the Scala object instance for this class (if it is the class of a Scala object)

  62. def getScalaObjectAs[T <: AnyRef](objectCls: Class[_])(implicit arg0: ClassTag[T]): Option[T]

    Permalink

    Returns the Scala object instance for this class (if it is the class of a Scala object)

  63. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  64. def isClassLoaded(cls: String, classLoader: ClassLoader): Boolean

    Permalink

    Check if a class is loaded

  65. def isClassLoaded(cls: String): Boolean

    Permalink

    Check if a class is loaded

  66. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  67. def isScalaObject(cls: Class[_]): Boolean

    Permalink

    Is this the class for a Scala Object?

  68. def isScalaObject(cls: String, classLoader: ClassLoader): Boolean

    Permalink

    Does this class represent a Scala object

    Does this class represent a Scala object

    cls

    The fully qualified name of the class to check (Note: should end with a '$' character)

  69. def isScalaObject(cls: String): Boolean

    Permalink

    Does this class represent a Scala object

    Does this class represent a Scala object

    cls

    The fully qualified name of the class to check (Note: should end with a '$' character)

  70. def listClasspathFiles(basePackage: String, classLoader: ClassLoader): Set[File]

    Permalink

    Similar to File.listFiles() (i.e.

    Similar to File.listFiles() (i.e. a non-recursive findClassPathFiles)

  71. def listClasspathFiles(basePackage: String): Set[File]

    Permalink

    Similar to File.listFiles() (i.e.

    Similar to File.listFiles() (i.e. a non-recursive findClassPathFiles)

  72. lazy val logger: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  73. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  74. def newInstanceOrObject[T <: AnyRef](cls: Class[T]): T

    Permalink

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

  75. def newInstanceOrObjectAs[T <: AnyRef](cls: Class[_], asCls: Class[T]): T

    Permalink

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

  76. def newInstanceOrObjectAs[T <: AnyRef](cls: Class[_])(implicit arg0: ClassTag[T]): T

    Permalink

    Creates a new instance of a class using a 0-args constructor or returns the Scala object instance of this class

  77. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  78. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  79. def requireClass(cls: String, msg: ⇒ String, classLoader: ClassLoader): Unit

    Permalink

    Check if a class exists.

    Check if a class exists. If it does not then a ClassNotFoundException is thrown.

  80. def requireClass(cls: String, msg: ⇒ String): Unit

    Permalink

    Check if a class exists.

    Check if a class exists. If it does not then a ClassNotFoundException is thrown.

  81. def scalaObject(objectCls: Class[_]): AnyRef

    Permalink

    Returns the Scala object instance for this class

  82. def scalaObjectAs[T <: AnyRef](objectCls: Class[_], asCls: Class[T]): T

    Permalink

    Returns the Scala object instance for this class

  83. def scalaObjectAs[T <: AnyRef](objectCls: Class[_])(implicit arg0: ClassTag[T]): T

    Permalink

    Returns the Scala object instance for this class

  84. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  85. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  86. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  87. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  88. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Logging

Inherited from AnyRef

Inherited from Any

Ungrouped