@API(status=STABLE,
since="1.0")
public class ClasspathResourceSource
extends java.lang.Object
implements TestSource
TestSource
with an optional position.ClasspathResourceSelector,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASSPATH_SCHEME
URI scheme for classpath
resources: "classpath" |
private java.lang.String |
classpathResourceName |
private FilePosition |
filePosition |
private static long |
serialVersionUID |
| Modifier | Constructor and Description |
|---|---|
private |
ClasspathResourceSource(java.lang.String classpathResourceName) |
private |
ClasspathResourceSource(java.lang.String classpathResourceName,
FilePosition filePosition) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
static ClasspathResourceSource |
from(java.lang.String classpathResourceName)
Create a new
ClasspathResourceSource using the supplied classpath
resource name. |
static ClasspathResourceSource |
from(java.lang.String classpathResourceName,
FilePosition filePosition)
Create a new
ClasspathResourceSource using the supplied classpath
resource name and FilePosition. |
static ClasspathResourceSource |
from(java.net.URI uri)
Create a new
ClasspathResourceSource from the supplied URI. |
java.lang.String |
getClasspathResourceName()
Get the name of the source classpath resource.
|
java.util.Optional<FilePosition> |
getPosition()
Get the
FilePosition, if available. |
int |
hashCode() |
java.lang.String |
toString() |
private static final long serialVersionUID
public static final java.lang.String CLASSPATH_SCHEME
URI scheme for classpath
resources: "classpath"private final java.lang.String classpathResourceName
private final FilePosition filePosition
private ClasspathResourceSource(java.lang.String classpathResourceName)
private ClasspathResourceSource(java.lang.String classpathResourceName,
FilePosition filePosition)
public static ClasspathResourceSource from(java.lang.String classpathResourceName)
ClasspathResourceSource using the supplied classpath
resource name.
The name of a classpath resource must follow the semantics
for resource paths as defined in ClassLoader.getResource(String).
If the supplied classpath resource name is prefixed with a slash
(/), the slash will be removed.
classpathResourceName - the name of the classpath resource; never
null or blankClassLoader.getResource(String),
ClassLoader.getResourceAsStream(String),
ClassLoader.getResources(String)public static ClasspathResourceSource from(java.lang.String classpathResourceName, FilePosition filePosition)
ClasspathResourceSource using the supplied classpath
resource name and FilePosition.
The name of a classpath resource must follow the semantics
for resource paths as defined in ClassLoader.getResource(String).
If the supplied classpath resource name is prefixed with a slash
(/), the slash will be removed.
classpathResourceName - the name of the classpath resource; never
null or blankfilePosition - the position in the classpath resource; may be nullpublic static ClasspathResourceSource from(java.net.URI uri)
ClasspathResourceSource from the supplied URI.
The path component of the URI (excluding
the query) will be used as the classpath resource name. The
query component of the URI, if present,
will be used to retrieve the FilePosition via
FilePosition.fromQuery(String).
uri - the URI for the classpath resource; never nullClasspathResourceSource; never nullPreconditionViolationException - if the supplied URI is
null or if the scheme of the supplied URI is not equal
to the CLASSPATH_SCHEMECLASSPATH_SCHEMEpublic java.lang.String getClasspathResourceName()
The name of a classpath resource follows the semantics for
resource paths as defined in ClassLoader.getResource(String).
ClassLoader.getResource(String),
ClassLoader.getResourceAsStream(String),
ClassLoader.getResources(String)public final java.util.Optional<FilePosition> getPosition()
FilePosition, if available.public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object