Class ProjectArtifactContentReader
java.lang.Object
org.bonitasoft.plugin.analyze.content.ProjectArtifactContentReader
- All Implemented Interfaces:
ArtifactContentReader
Reads the content of a maven project folder.
Java classes are loaded from build directory.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bonitasoft.plugin.analyze.content.ArtifactContentReader
ArtifactContentReader.ArtifactFileType, ArtifactContentReader.Entry -
Constructor Summary
ConstructorsConstructorDescriptionProjectArtifactContentReader(org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering, List<org.apache.maven.project.MavenProject> reactorProjects) -
Method Summary
Modifier and TypeMethodDescriptiondetectImplementationHierarchy(String className, org.apache.maven.artifact.Artifact artifact, Consumer<ClassNotFoundException> exceptionHandler) Detect the implementation hierarchy of a java class in the artifact.Get the concerned artifact file type.booleanhasEntryWithPath(org.apache.maven.artifact.Artifact artifact, Path entryPath) Test whether the artifact has a content entry at the given relative path.<R,A> R readEntries(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Collector<ArtifactContentReader.Entry, A, R> reader) Read the (compiled) content of the artifact entries which satisfy the path predicate.voidreadEntry(org.apache.maven.artifact.Artifact artifact, Path entryPath, Consumer<InputStream> reader) Read the (compiled) content of the artifact entry at the given relative path.<T> Optional<T>readFirstEntry(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Function<ArtifactContentReader.Entry, T> reader) Read the (compiled) content of the first artifact entry which satisfy the path predicate.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bonitasoft.plugin.analyze.content.ArtifactContentReader
appliesTo, findEntry, findEntryWithName, hasEntryWithPath, logIOException, readEntries
-
Constructor Details
-
Method Details
-
getArtifactFileType
Description copied from interface:ArtifactContentReaderGet the concerned artifact file type.- Specified by:
getArtifactFileTypein interfaceArtifactContentReader- Returns:
- the artifact file type
-
hasEntryWithPath
Description copied from interface:ArtifactContentReaderTest whether the artifact has a content entry at the given relative path.- Specified by:
hasEntryWithPathin interfaceArtifactContentReader- Parameters:
artifact- the artifact to test (with adequate file type)entryPath- the relative path of the entry to test- Returns:
- true when there is a valid entry
-
readEntry
public void readEntry(org.apache.maven.artifact.Artifact artifact, Path entryPath, Consumer<InputStream> reader) throws IllegalArgumentException, IOException Description copied from interface:ArtifactContentReaderRead the (compiled) content of the artifact entry at the given relative path.The input stream is closed automatically, so you do not have to worry about it.
- Specified by:
readEntryin interfaceArtifactContentReader- Parameters:
artifact- the artifact to read (with adequate file type)entryPath- the relative path of the entry to readreader- the reading job which will consume the entry content- Throws:
IllegalArgumentException- when entry not foundIOException- exception reading artifact content
-
readFirstEntry
public <T> Optional<T> readFirstEntry(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Function<ArtifactContentReader.Entry, T> reader) throws IOExceptionDescription copied from interface:ArtifactContentReaderRead the (compiled) content of the first artifact entry which satisfy the path predicate.You must close the requested input stream in the reader.
- Specified by:
readFirstEntryin interfaceArtifactContentReader- Parameters:
artifact- the artifact to read (with adequate file type)predicateOnPath- the predicate to test on the entry pathreader- the reading job which will eventually consume the valid entry content and transform it- Returns:
- the result of the reading job, empty when no valid entry was found
- Throws:
IOException- exception reading artifact content
-
readEntries
public <R,A> R readEntries(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Collector<ArtifactContentReader.Entry, A, throws IOExceptionR> reader) Description copied from interface:ArtifactContentReaderRead the (compiled) content of the artifact entries which satisfy the path predicate.You must close the requested input stream in the reader.
- Specified by:
readEntriesin interfaceArtifactContentReader- Parameters:
artifact- the artifact to read (with adequate file type)predicateOnPath- the predicate to test on the entry pathreader- the reading job which will eventually consume each valid entry content and collect the result- Returns:
- the result collected by the reader
- Throws:
IOException- exception reading artifact content
-
detectImplementationHierarchy
public Set<String> detectImplementationHierarchy(String className, org.apache.maven.artifact.Artifact artifact, Consumer<ClassNotFoundException> exceptionHandler) throws UnsupportedOperationException Description copied from interface:ArtifactContentReaderDetect the implementation hierarchy of a java class in the artifact.Some implementations may not support this method for their artifact file type.
- Specified by:
detectImplementationHierarchyin interfaceArtifactContentReader- Parameters:
className- the name of the class to analyzeartifact- the artifact to read (with adequate file type)exceptionHandler- handles any ClassNotFoundException while loading classes- Returns:
- set of class names in the implementation's parent hierarchy
- Throws:
UnsupportedOperationException- when the implementation does not support this method
-