Interface RevisionRange
-
- All Superinterfaces:
VCSModelElement
public interface RevisionRange extends VCSModelElement
This class represents the state transition between two revisions. The "from" revision (if any) is available withgetPredecessorRevision()
. The "to" revision is available withgetRevision()
. A single range may subsume several commits to merge commits on, for instance, a monthly basis.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.List<FileChange>
getAddedFiles()
Returns all files that have been added.java.util.List<Commit>
getCommits()
Returns the commits that have been applied togetPredecessorRevision()
so thatgetRevision()
results from it.default java.util.List<FileChange>
getFileChanges()
Returns all files that have changed betweengetPredecessorRevision()
andgetRevision()
.default java.util.List<FileChange>
getFileChangesByPrefix(java.lang.String prefix)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or new relative path start withprefix
.default java.util.List<FileChange>
getFileChangesByRegex(java.lang.String regex)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or new relative path matchregex
.default java.util.List<FileChange>
getFileChangesBySuffix(java.lang.String suffix)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or the new relative path end withsuffix
.default java.util.List<Issue>
getIssues()
Returns the issues referenced by the commits of this range.default Commit
getLatestCommit()
Returns the latest commit ofgetCommits()
.default java.util.List<FileChange>
getModifiedFiles()
Returns all files that have been modified.int
getOrdinal()
Returns the ordinal of this range.java.util.Optional<Revision>
getPredecessorRevision()
Returns the "from" revision the file changes of this range belong to.default java.util.List<FileChange>
getRelocatedFiles()
Returns all files that have been relocated.default java.util.List<FileChange>
getRemovedFiles()
Returns all files that have been removed.Revision
getRevision()
Returns the "to" revision the file changes of this range belong to.default void
ifFirst(java.util.function.Consumer<RevisionRange> action)
Runs the given action if this range is the first one.default void
ifNotFirst(java.util.function.Consumer<RevisionRange> action)
Runs the given action if this range is not the first one.default boolean
isFirst()
Returns whether this range is the first one.default RevisionRange
merge(RevisionRange predecessor)
Merges this range intopredecessor
and returns a new instance that represents the state transition frompredecessor.getPredecessorRevision()
tothis.getRevision()
.-
Methods inherited from interface de.unibremen.informatik.st.libvcs4j.VCSModelElement
getVCSEngine
-
-
-
-
Method Detail
-
getOrdinal
int getOrdinal()
Returns the ordinal of this range. Ordinals are used to identify individual ranges with a serial number when processing a VCS. The origin is 1.- Returns:
- The ordinal of this range (
>= 1
).
-
getRevision
Revision getRevision()
Returns the "to" revision the file changes of this range belong to.- Returns:
- The "to" revision the file changes of this range belong to.
-
getPredecessorRevision
java.util.Optional<Revision> getPredecessorRevision()
Returns the "from" revision the file changes of this range belong to.- Returns:
- The "from" revision the file changes of this range belong to or an
empty
Optional
if this is the first range.
-
getCommits
java.util.List<Commit> getCommits()
Returns the commits that have been applied togetPredecessorRevision()
so thatgetRevision()
results from it. The order of the returned list is from oldest to latest. Contains at least one commit.- Returns:
- The list of commits.
-
getLatestCommit
default Commit getLatestCommit()
Returns the latest commit ofgetCommits()
.- Returns:
- The latest commit of
getCommits()
.
-
getFileChanges
default java.util.List<FileChange> getFileChanges()
Returns all files that have changed betweengetPredecessorRevision()
andgetRevision()
. The default implementation, if necessary, merges the file changes of all commits listed ingetCommits()
.- Returns:
- The list of file changes.
-
getAddedFiles
default java.util.List<FileChange> getAddedFiles()
Returns all files that have been added.- Returns:
- All files that have been added.
-
getRemovedFiles
default java.util.List<FileChange> getRemovedFiles()
Returns all files that have been removed.- Returns:
- All files that have been removed.
-
getModifiedFiles
default java.util.List<FileChange> getModifiedFiles()
Returns all files that have been modified.- Returns:
- All files that have been modified.
-
getRelocatedFiles
default java.util.List<FileChange> getRelocatedFiles()
Returns all files that have been relocated.- Returns:
- All files that have been relocated.
-
getFileChangesBySuffix
default java.util.List<FileChange> getFileChangesBySuffix(java.lang.String suffix)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or the new relative path end withsuffix
. You may use this method to analyze file changes affecting a certain file type only. For instance, callgetFileChangesBySuffix(".java")
to get only the file changes affecting Java files.- Parameters:
suffix
- The suffix used to filter the file changes.- Returns:
- All file changes whose old or the new relative path end with
suffix
.
-
getFileChangesByPrefix
default java.util.List<FileChange> getFileChangesByPrefix(java.lang.String prefix)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or new relative path start withprefix
. You may use this method to analyze file changes affecting a certain directory (and its sub-directories) only. For instance, callgetFileChangesByPrefix("src/main/java")
to get only the file changes affecting files located in "src/main/java".- Parameters:
prefix
- The prefix used to filter the file changes.- Returns:
- All file changes whose old or new relative file path start with
prefix
.
-
getFileChangesByRegex
default java.util.List<FileChange> getFileChangesByRegex(java.lang.String regex)
Filters the list of file changes returned bygetFileChanges()
and returns only those whose old or new relative path matchregex
. Paths are matched usingString.matches(String)
.- Parameters:
regex
- The regular expression used to filter the file changes.- Returns:
- All file changes whose old or new relative path match
regex
.
-
getIssues
default java.util.List<Issue> getIssues()
Returns the issues referenced by the commits of this range. To enable this feature when processing a repository, set an appropriateITEngine
withVCSEngine.setITEngine(ITEngine)
. The returned list does not contain the same issue (according toIssue.getId()
) twice.- Returns:
- The issues referenced by the commits of this range.
-
isFirst
default boolean isFirst()
Returns whether this range is the first one. That is, there is no predecessor revision and, consequently, all changes returned bygetFileChanges()
are additions. The default implementation simply checks whethergetPredecessorRevision()
returns an emptyOptional
.- Returns:
true
if this range is the first one,false
otherwise.
-
ifFirst
default void ifFirst(java.util.function.Consumer<RevisionRange> action)
Runs the given action if this range is the first one.- Parameters:
action
- The action to run if this is the first range.
-
ifNotFirst
default void ifNotFirst(java.util.function.Consumer<RevisionRange> action)
Runs the given action if this range is not the first one.- Parameters:
action
- The action to run if this is not the first range.
-
merge
default RevisionRange merge(RevisionRange predecessor) throws java.lang.NullPointerException
Merges this range intopredecessor
and returns a new instance that represents the state transition frompredecessor.getPredecessorRevision()
tothis.getRevision()
. The commits ofpredecessor
andthis
are combined such that the commits ofthis
are applied onto the commits ofpredecessor
.- Parameters:
predecessor
- The predecessor range to merge this range into.- Returns:
- A new revision range representing the state transition from
predecessor.getPredecessorRevision()
tothis.getRevision()
. - Throws:
java.lang.NullPointerException
- Ifpredecessor
isnull
.
-
-