Skip to content

Commit 05b5d80

Browse files
committed
1 parent d2355a8 commit 05b5d80

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @author Tobias Warneke (t.warneke@gmx.net)
2525
*/
26-
public class UnifiedDiff {
26+
public final class UnifiedDiff {
2727

2828
private String header;
2929
private String tail;
@@ -52,4 +52,14 @@ void setTailTxt(String tailTxt) {
5252
public String getTail() {
5353
return tail;
5454
}
55+
56+
public static UnifiedDiff from(String header, String tail, UnifiedDiffFile... files) {
57+
UnifiedDiff diff = new UnifiedDiff();
58+
diff.setHeader(header);
59+
diff.setTailTxt(tail);
60+
for (UnifiedDiffFile file : files) {
61+
diff.addFile(file);
62+
}
63+
return diff;
64+
}
5565
}

src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @author Tobias Warneke (t.warneke@gmx.net)
2323
*/
24-
public class UnifiedDiffFile {
24+
public final class UnifiedDiffFile {
2525

2626
private String diffCommand;
2727
private String fromFile;
@@ -64,4 +64,12 @@ public String getIndex() {
6464
public Patch<String> getPatch() {
6565
return patch;
6666
}
67+
68+
public static UnifiedDiffFile from(String fromFile, String toFile, Patch<String> patch) {
69+
UnifiedDiffFile file = new UnifiedDiffFile();
70+
file.setFromFile(fromFile);
71+
file.setToFile(toFile);
72+
file.patch = patch;
73+
return file;
74+
}
6775
}

0 commit comments

Comments
 (0)