Package org.apache.spark.util
Interface SparkClassUtils
public interface SparkClassUtils
-
Method Summary
Modifier and TypeMethodDescription<C> Class<C>
classForName
(String className, boolean initialize, boolean noSparkClassLoader) Preferred alternative to Class.forName(className), as well as Class.forName(className, initialize, loader) with current thread's ContextClassLoader.boolean
classIsLoadable
(String clazz) Determines whether the provided class is loadable in the current thread.boolean
classIsLoadableAndAssignableFrom
(String clazz, Class<?> targetClass) Determines whether the provided class is loadable in the current thread and assignable from the target class.Return the class name of the given object, removing all dollar signsgetSimpleName
(Class<?> cls) Safer than Class obj's getSimpleName which may throw Malformed class name error in scala.random()
Remove trailing dollar signs from qualified class name, and return the trailing part after the last dollar sign in the middlestripPackages
(String fullyQualifiedName) Remove the packages from full qualified class name
-
Method Details
-
random
Random random() -
getSparkClassLoader
ClassLoader getSparkClassLoader() -
getContextOrSparkClassLoader
ClassLoader getContextOrSparkClassLoader() -
classForName
Preferred alternative to Class.forName(className), as well as Class.forName(className, initialize, loader) with current thread's ContextClassLoader.- Parameters:
className
- (undocumented)initialize
- (undocumented)noSparkClassLoader
- (undocumented)- Returns:
- (undocumented)
-
classIsLoadable
Determines whether the provided class is loadable in the current thread. -
classIsLoadableAndAssignableFrom
Determines whether the provided class is loadable in the current thread and assignable from the target class.- Parameters:
clazz
- the fully qualified class name of the class to check for loadability and inheritance fromparent
targetClass
- the target class which the class represented. If target is null, only checks if the class is loadable- Returns:
- true if
clazz
is loadable and assignable fromtarget
, otherwise false
-
getFormattedClassName
Return the class name of the given object, removing all dollar signs -
getSimpleName
Safer than Class obj's getSimpleName which may throw Malformed class name error in scala. This method mimics scalatest's getSimpleNameOfAnObjectsClass.- Parameters:
cls
- (undocumented)- Returns:
- (undocumented)
-
stripPackages
Remove the packages from full qualified class name- Parameters:
fullyQualifiedName
- (undocumented)- Returns:
- (undocumented)
-
stripDollars
Remove trailing dollar signs from qualified class name, and return the trailing part after the last dollar sign in the middle- Parameters:
s
- (undocumented)- Returns:
- (undocumented)
-