Class NestedClassSelector
- java.lang.Object
-
- org.junit.platform.engine.discovery.NestedClassSelector
-
- All Implemented Interfaces:
DiscoverySelector
@API(status=STABLE, since="1.6") public class NestedClassSelector extends java.lang.Object implements DiscoverySelector
ADiscoverySelector
that selects a nestedClass
or class name enclosed in other classes so thatTestEngines
can discover tests or containers based on classes.If Java
Class
references are provided for the nested class or the enclosing classes, the selector will return those classes and their class names accordingly. If class names are provided, the selector will only attempt to lazily load classes ifgetEnclosingClasses()
orgetNestedClass()
is invoked.In this context, Java
Class
means anything that can be referenced as aClass
on the JVM — for example, classes from other JVM languages such Groovy, Scala, etc.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoader
classLoader
private java.util.List<ClassSelector>
enclosingClassSelectors
private ClassSelector
nestedClassSelector
-
Constructor Summary
Constructors Constructor Description NestedClassSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName)
NestedClassSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.ClassLoader
getClassLoader()
Get theClassLoader
used to load the selected nested class.java.util.List<java.lang.Class<?>>
getEnclosingClasses()
Get the list ofClass
enclosing the selected nestedClass
.java.util.List<java.lang.String>
getEnclosingClassNames()
Get the names of the classes enclosing the selected nested class.java.lang.Class<?>
getNestedClass()
Get the selected nestedClass
.java.lang.String
getNestedClassName()
Get the name of the selected nested class.int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
classLoader
private final java.lang.ClassLoader classLoader
-
enclosingClassSelectors
private final java.util.List<ClassSelector> enclosingClassSelectors
-
nestedClassSelector
private final ClassSelector nestedClassSelector
-
-
Constructor Detail
-
NestedClassSelector
NestedClassSelector(java.lang.ClassLoader classLoader, java.util.List<java.lang.String> enclosingClassNames, java.lang.String nestedClassName)
-
NestedClassSelector
NestedClassSelector(java.util.List<java.lang.Class<?>> enclosingClasses, java.lang.Class<?> nestedClass)
-
-
Method Detail
-
getClassLoader
@API(status=EXPERIMENTAL, since="1.10") public java.lang.ClassLoader getClassLoader()
Get theClassLoader
used to load the selected nested class.- Returns:
- the
ClassLoader
; potentiallynull
- Since:
- 1.10
-
getEnclosingClassNames
public java.util.List<java.lang.String> getEnclosingClassNames()
Get the names of the classes enclosing the selected nested class.
-
getEnclosingClasses
public java.util.List<java.lang.Class<?>> getEnclosingClasses()
Get the list ofClass
enclosing the selected nestedClass
.If the
Class
were not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the list of enclosingClass
and throws aPreconditionViolationException
if the classes cannot be loaded.
-
getNestedClassName
public java.lang.String getNestedClassName()
Get the name of the selected nested class.
-
getNestedClass
public java.lang.Class<?> getNestedClass()
Get the selected nestedClass
.If the
Class
were not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the nestedClass
and throws aPreconditionViolationException
if the class cannot be loaded.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-