Package edu.hm.hafner.analysis
Class Report
java.lang.Object
edu.hm.hafner.analysis.Report
- All Implemented Interfaces:
Serializable,Iterable<Issue>
A report contains a set of unique
issues: it contains no duplicate elements, i.e. it models the
mathematical set abstraction. This report provides a total ordering on its elements. I.e., the issues
in this report are ordered by their index: the first added issue is at position 0, the second added issues is at
position 1, and so on.
Additionally, this report provides methods to find and filter issues based on different properties. In order to
create issues use the provided builder class.
- Author:
- Ullrich Hafner
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds a combined filter based on several include and exclude filters.static interfacePrints a summary of anIssue.static classPrints issues to the "standard" output stream. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the specified issue to the end of this report.Appends all the specified issues to the end of this report, preserving the order of the array elements.Appends the specifiedreportsto this report.addAll(Collection<? extends Issue> issues) Appends all of the specified issues to the end of this report, preserving the order of the array elements.copy()Returns a shallow copy of this issue container.Returns a new empty issue container with the same properties as this container.booleanFinds all issues that match the specified criterion.Returns the issue with the specified ID.findByProperty(Predicate<? super Issue> criterion) Finds all issues that match the specified criterion.get()Returns the issues in this report.get(int index) Returns the issue with the specified index.Returns the absolute paths of the affected files for all issues.Returns the used categories for all issues.intgetCounter(String key) Returns the specified custom counter of this report.intReturns the number of duplicates.Returns the effective ID of this report.Returns the effective ID of this report.Returns the error messages that have been reported since the creation of this set of issues.getFiles()Returns the affected files for all issues.Returns the folders for all affected files of the issues.getId()Returns the info messages that have been reported since the creation of this set of issues.Returns the affected modules for all issues.getName()getNameOfOrigin(String origin) Returns a human-readable name for the specifiedoriginof this report.Returns the names of all report files that are the origin for the issues of thisReport(and all contained sub-reports).Returns the affected packages for all issues.<T> Set<T>getProperties(Function<? super Issue, T> propertiesMapper) Returns the different values for a given property for all issues.getPropertyCount(Function<? super Issue, T> propertiesMapper) Returns the number of occurrences for every existing value of a given property for all issues.Returns the severities of all issues.intgetSize()Returns the number of issues in this report.intReturns the number of issues with the specifiedSeverity.intReturns the number of issues with the specifiedseverity.getTools()Returns the names of the tools that did report the issues.getTypes()Returns the used types for all issues.groupByProperty(String propertyName) Groups issues by a specified property.booleanReturns whether this report contains issues with different categories.booleanhasCounter(String key) Returns whether the specified custom counter of this report is defined.booleanReturns whether error messages have been reported.booleanhasFiles()Returns whether this report contains more than one affected file.booleanReturns whether this report contains more than one folder with affected files.inthashCode()booleanReturns whether this report contains affected files from more than one module.booleanReturns whether this report contains affected files from more than one package.booleanReturns whether this report contains issues of different severities.booleanhasTools()Returns whether this report contains issues created by different tools.booleanhasTypes()Returns whether this report contains issues with different types.booleanisEmpty()Returns whether this report is empty.booleanReturns whether this report is not empty.iterator()voidLogs the specified error message.voidlogException(Exception exception, String format, Object... args) Logs the specified exception.voidLogs the specified information message.voidprint(Report.IssuePrinter issuePrinter) Prints all issues of the report.protected ObjectCalled after de-serialization to improve the memory usage and to initialize fields that have been introduced after the first release.voidsetCounter(String key, int value) Sets the specified custom counter for this report.voidSets the origin of all issues in this report.voidsetOriginReportFile(String originReportFile) intsize()Returns the number of issues in this container.stream()Creates a new sequentialStreamofIssueinstances.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Report
public Report()Creates an emptyReport. -
Report
Creates an emptyReportwith the specified ID and name.- Parameters:
id- the ID of the reportname- a human-readable name for the report
-
Report
Creates an emptyReportwith the specified ID and name. Link the report with the specified source file that is the origin of the issues.- Parameters:
id- the ID of the reportname- a human-readable name for the reportoriginReportFile- the specified source file * that is the origin of the issues.
-
Report
Creates a newReportthat is an aggregation of the specifiedreports. The created report will contain the issues of all specified reports, in the same order. The properties of the specified reports will also be copied.- Parameters:
reports- the reports to append- See Also:
-
copyIssuesAndProperties(Report, Report)
-
Report
Creates a newReportthat is an aggregation of the specifiedreports. The created report will contain the issues of all specified reports, in the same order. The properties of the specified reports will also be copied.- Parameters:
reports- the initial set of issues- See Also:
-
copyIssuesAndProperties(Report, Report)
-
-
Method Details
-
getId
-
getEffectiveId
Returns the effective ID of this report. This ID is the unique ID of all containing sub-reports. If this ID is not unique, then theDEFAULT_IDwill be returned.- Returns:
- the effective ID of all sub-reports
-
getName
-
setOrigin
Sets the origin of all issues in this report. Calling this method will associate all containing issues and issues in sub-reports using the specified ID and name.- Parameters:
originId- the ID of the reportoriginName- a human-readable name for the report
-
getEffectiveName
Returns the effective ID of this report. This ID is the unique ID of all containing sub-reports. If this ID is not unique, then theDEFAULT_IDwill be returned.- Returns:
- the effective ID of all sub-reports
-
getOriginReportFile
-
setOriginReportFile
-
getOriginReportFiles
Returns the names of all report files that are the origin for the issues of thisReport(and all contained sub-reports).- Returns:
- the names of all report files
-
add
Appends the specified issue to the end of this report. Duplicates will be skipped (the number of skipped elements is available using the methodgetDuplicatesSize().- Parameters:
issue- the issue to append- Returns:
- this
-
addAll
Appends all the specified issues to the end of this report, preserving the order of the array elements. Duplicates will be skipped (the number of skipped elements is available using the methodgetDuplicatesSize()).- Parameters:
issue- the first issue to appendadditionalIssues- the additional issue to append- Returns:
- this
- See Also:
-
addAll
Appends all of the specified issues to the end of this report, preserving the order of the array elements. Duplicates will be skipped (the number of skipped elements is available using the methodgetDuplicatesSize().- Parameters:
issues- the issues to append- Returns:
- this
- See Also:
-
addAll
Appends the specifiedreportsto this report. This report will then contain the issues of all specified reports, in the same order. The properties of the specified reports will also be copied.- Parameters:
reports- the reports to append- Returns:
- this
- See Also:
-
copyIssuesAndProperties(Report, Report)
-
readResolve
Called after de-serialization to improve the memory usage and to initialize fields that have been introduced after the first release.- Returns:
- this
-
findById
Returns the issue with the specified ID.- Parameters:
issueId- the ID of the issue- Returns:
- the found issue
- Throws:
edu.hm.hafner.util.NoSuchElementException- if there is no such issue found
-
findByProperty
Finds all issues that match the specified criterion.- Parameters:
criterion- the filter criterion- Returns:
- the found issues
-
filter
Finds all issues that match the specified criterion.- Parameters:
criterion- the filter criterion- Returns:
- the found issues
-
iterator
-
stream
Creates a new sequentialStreamofIssueinstances.- Returns:
- a new
Stream
-
get
Returns the issues in this report. This will include the issues of any sub-reports.- Returns:
- all issues in this report
-
get
Returns the issue with the specified index.- Parameters:
index- the index- Returns:
- the issue at the specified index
- Throws:
IndexOutOfBoundsException- if there is no element for the given index
-
size
public int size()Returns the number of issues in this container.- Returns:
- total number of issues
-
isEmpty
public boolean isEmpty()Returns whether this report is empty.- Returns:
trueif this report is empty,falseotherwise- See Also:
-
isNotEmpty
public boolean isNotEmpty()Returns whether this report is not empty.- Returns:
trueif this report is not empty,falseotherwise- See Also:
-
getSize
public int getSize()Returns the number of issues in this report.- Returns:
- total number of issues
-
getDuplicatesSize
public int getDuplicatesSize()Returns the number of duplicates. Every issue that has been added to this report, but already is part of this report (based onequals(Object)) is counted as a duplicate. Duplicates are not stored in this report.- Returns:
- total number of duplicates
-
getSizeOf
Returns the number of issues with the specifiedseverity.- Parameters:
severity- the severity of the issues- Returns:
- total number of issues
-
getSizeOf
Returns the number of issues with the specifiedSeverity.- Parameters:
severity- the severity of the issues- Returns:
- total number of issues
-
toString
-
print
Prints all issues of the report.- Parameters:
issuePrinter- prints a summary of anIssue
-
getModules
Returns the affected modules for all issues.- Returns:
- the affected modules
-
hasModules
public boolean hasModules()Returns whether this report contains affected files from more than one module.- Returns:
trueif the number of modules is greater than 1,falseotherwise
-
getPackages
Returns the affected packages for all issues.- Returns:
- the affected packages
-
hasPackages
public boolean hasPackages()Returns whether this report contains affected files from more than one package.- Returns:
trueif the number of packages is greater than 1,falseotherwise
-
getFolders
Returns the folders for all affected files of the issues.- Returns:
- the affected packages
-
hasFolders
public boolean hasFolders()Returns whether this report contains more than one folder with affected files.- Returns:
trueif the number of folders is greater than 1,falseotherwise
-
getAbsolutePaths
Returns the absolute paths of the affected files for all issues.- Returns:
- the affected files
-
getFiles
Returns the affected files for all issues.- Returns:
- the affected files
-
hasFiles
public boolean hasFiles()Returns whether this report contains more than one affected file.- Returns:
trueif the number of affected files is greater than 1,falseotherwise
-
getCategories
Returns the used categories for all issues.- Returns:
- the used categories
-
hasCategories
public boolean hasCategories()Returns whether this report contains issues with different categories.- Returns:
trueif the number of categories is greater than 1,falseotherwise
-
getTypes
Returns the used types for all issues.- Returns:
- the used types
-
hasTypes
public boolean hasTypes()Returns whether this report contains issues with different types.- Returns:
trueif the number of types is greater than 1,falseotherwise
-
getTools
Returns the names of the tools that did report the issues.- Returns:
- the tools
-
hasTools
public boolean hasTools()Returns whether this report contains issues created by different tools.- Returns:
trueif the number of tools is greater than 1,falseotherwise
-
getSeverities
Returns the severities of all issues.- Returns:
- the severities
-
hasSeverities
public boolean hasSeverities()Returns whether this report contains issues of different severities.- Returns:
trueif the number of severities is greater than 1,falseotherwise
-
getProperties
Returns the different values for a given property for all issues.- Type Parameters:
T- type of the property- Parameters:
propertiesMapper- the properties mapper that selects the property- Returns:
- the set of different values
- See Also:
-
getPropertyCount
Returns the number of occurrences for every existing value of a given property for all issues.- Type Parameters:
T- type of the property- Parameters:
propertiesMapper- the properties mapper that selects the property to evaluate- Returns:
- a mapping of: property value to the number of issues for that value
- See Also:
-
groupByProperty
Groups issues by a specified property. Returns the results as a mapping of property values to a new set ofReportfor this value.- Parameters:
propertyName- the property to that selects the property to evaluate- Returns:
- a mapping of: property value to the number of issues for that value
- See Also:
-
copy
Returns a shallow copy of this issue container.- Returns:
- a new issue container that contains the same elements in the same order
-
copyEmptyInstance
Returns a new empty issue container with the same properties as this container. The new issue container is empty and does not contain issues.- Returns:
- a new issue container that contains the same properties but no issues
-
logInfo
Logs the specified information message. Use this method to log any useful information when composing this report.- Parameters:
format- A format stringargs- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.- See Also:
-
logError
Logs the specified error message. Use this method to log any error when composing this report.- Parameters:
format- A format stringargs- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.- See Also:
-
logException
Logs the specified exception. Use this method to log any exception when composing this report.- Parameters:
exception- the exception to logformat- A format stringargs- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero.- See Also:
-
getInfoMessages
Returns the info messages that have been reported since the creation of this set of issues.- Returns:
- the info messages
-
getErrorMessages
Returns the error messages that have been reported since the creation of this set of issues.- Returns:
- the error messages
-
hasErrors
public boolean hasErrors()Returns whether error messages have been reported.- Returns:
trueif there are error messages,falseotherwise
-
equals
-
hashCode
public int hashCode() -
getNameOfOrigin
Returns a human-readable name for the specifiedoriginof this report.- Parameters:
origin- the origin to get the human-readable name for- Returns:
- the name, or an empty string if no such name has been set
-
setCounter
Sets the specified custom counter for this report.- Parameters:
key- the unique key for this countervalue- the value to set
-
getCounter
Returns the specified custom counter of this report.- Parameters:
key- the unique key for this counter- Returns:
- the value of the specified counter, or 0 if the counter has not been set or is undefined
-
hasCounter
Returns whether the specified custom counter of this report is defined.- Parameters:
key- the unique key for this counter- Returns:
trueif the counter has been set,falseotherwise
-