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 DiscoverySelectorADiscoverySelectorthat selects a nestedClassor class name enclosed in other classes so thatTestEnginescan discover tests or containers based on classes.If Java
Classreferences 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
Classmeans anything that can be referenced as aClasson the JVM — for example, classes from other JVM languages such Groovy, Scala, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNestedClassSelector.IdentifierParser
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoaderclassLoaderprivate java.util.List<ClassSelector>enclosingClassSelectorsprivate ClassSelectornestedClassSelector
-
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 booleanequals(java.lang.Object o)java.lang.ClassLoadergetClassLoader()Get theClassLoaderused to load the selected nested class.java.util.List<java.lang.Class<?>>getEnclosingClasses()Get the list ofClassenclosing 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.StringgetNestedClassName()Get the name of the selected nested class.inthashCode()java.util.Optional<DiscoverySelectorIdentifier>toIdentifier()Return the identifier of this selector.java.lang.StringtoString()
-
-
-
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=MAINTAINED, since="1.13.3") public java.lang.ClassLoader getClassLoader()Get theClassLoaderused 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 ofClassenclosing the selected nestedClass.If the
Classwere not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the list of enclosingClassand throws aPreconditionViolationExceptionif 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
Classwere not provided, but only the name of the nested class and its enclosing classes, this method attempts to lazily load the nestedClassand throws aPreconditionViolationExceptionif the class cannot be loaded.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toIdentifier
public java.util.Optional<DiscoverySelectorIdentifier> toIdentifier()
Description copied from interface:DiscoverySelectorReturn the identifier of this selector.The returned identifier must be parsable by a corresponding
DiscoverySelectorIdentifierParser.The default implementation returns
Optional.empty(). Can be overridden by concrete implementations.- Specified by:
toIdentifierin interfaceDiscoverySelector- Returns:
- an
Optionalcontaining the identifier of this selector; nevernullbut potentially empty if the selector does not support identifiers
-
-