Interface FileChange
-
- All Superinterfaces:
VCSModelElement
public interface FileChange extends VCSModelElement
Represents a change of a file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FileChange.Type
The type of aFileChange
.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.List<LineChange>
computeDiff()
default int
computeLineDelta()
Returns the delta of the changed lines.java.util.Optional<VCSFile>
getNewFile()
Returns the file as it was like when its corresponding revision was checked out byVCSEngine.next()
.java.util.Optional<VCSFile>
getOldFile()
Returns the file as it was like when its corresponding revision was checked out byVCSEngine.next()
.default FileChange.Type
getType()
Returns theFileChange.Type
of this file change.-
Methods inherited from interface de.unibremen.informatik.st.libvcs4j.VCSModelElement
getVCSEngine
-
-
-
-
Method Detail
-
getOldFile
java.util.Optional<VCSFile> getOldFile()
Returns the file as it was like when its corresponding revision was checked out byVCSEngine.next()
.- Returns:
- The old state of the file or an empty
Optional
if thisFileChange
is an addition (FileChange.Type.ADD
).
-
getNewFile
java.util.Optional<VCSFile> getNewFile()
Returns the file as it was like when its corresponding revision was checked out byVCSEngine.next()
.- Returns:
- The new state of the file or an empty
Optional
if thisFileChange
is a removal (FileChange.Type.REMOVE
).
-
getType
default FileChange.Type getType()
Returns theFileChange.Type
of this file change. The default implementation computes the type based on the presence/absence ofgetOldFile()
andgetNewFile()
.- Returns:
- The
FileChange.Type
of this file change.
-
computeDiff
default java.util.List<LineChange> computeDiff() throws java.io.IOException
- Returns:
- A sequence of
LineChange
objects. - Throws:
BinaryFileException
- If the old or the new file is binary (seeVCSFile.isBinary()
).java.io.IOException
- If an error occurred while reading the content of the old or new file (seeVCSFile.readContent()
).- See Also:
VCSEngine.computeDiff(FileChange)
-
computeLineDelta
default int computeLineDelta() throws java.io.IOException
Returns the delta of the changed lines. A positive value indicates that more lines have been inserted than deleted, whereas a negative value indicates that more lines have been deleted than inserted. 0 indicates that an equal amount of lines have been inserted and deleted.- Returns:
- The delta of the changed lines.
- Throws:
BinaryFileException
- If the old or the new file is binary (seeVCSFile.isBinary()
).java.io.IOException
- If an error occurred while computing the diff (seecomputeDiff()
).
-
-