@API(status=STABLE, since="1.0") public class ClassSource extends Object implements TestSource
TestSource
with
an optional file position.
If a Java Class
reference is provided, the ClassSource
will contain that Class
and its class name accordingly. If a class
name is provided, the ClassSource
will contain the class name and
will only attempt to lazily load the Class
if getJavaClass()
is invoked.
In this context, Java Class
means anything that can be referenced
as a Class
on the JVM — for example, classes from other JVM
languages such Groovy, Scala, etc.
ClassSelector
,
Serialized FormModifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static ClassSource |
from(Class<?> javaClass)
Create a new
ClassSource using the supplied class. |
static ClassSource |
from(Class<?> javaClass,
FilePosition filePosition)
|
static ClassSource |
from(String className)
Create a new
ClassSource using the supplied class name. |
static ClassSource |
from(String className,
FilePosition filePosition)
Create a new
ClassSource using the supplied class name and
file position. |
String |
getClassName()
Get the class name of this source.
|
Class<?> |
getJavaClass()
Get the Java class of this source.
|
Optional<FilePosition> |
getPosition()
|
int |
hashCode() |
String |
toString() |
public static ClassSource from(String className)
ClassSource
using the supplied class name.className
- the class name; must not be null
or blankpublic static ClassSource from(String className, FilePosition filePosition)
ClassSource
using the supplied class name and
file position.className
- the class name; must not be null
or blankfilePosition
- the position in the source file; may be null
public static ClassSource from(Class<?> javaClass)
ClassSource
using the supplied class.javaClass
- the Java class; must not be null
public static ClassSource from(Class<?> javaClass, FilePosition filePosition)
javaClass
- the Java class; must not be null
filePosition
- the position in the Java source file; may be null
public final String getClassName()
getJavaClass()
,
getPosition()
public final Class<?> getJavaClass()
If the Class
was not provided, but only the name, this method
attempts to lazily load the Class
based on its name and throws a
PreconditionViolationException
if the class cannot be loaded.
getClassName()
,
getPosition()
public final Optional<FilePosition> getPosition()
getClassName()
,
getJavaClass()
Copyright © 2024. All rights reserved.