@Test public void testDiff_sc4() { String text1 = "soy-dil-din-abc"; String text2 = "soz - dil - din - abc"; assertThat(DiffUtil.diffLines(text1, text2, true), equalTo(new String[]{ "soy-dil-din- abc", " ^^^^^^^^^^^^^^^^ ", " z - dil - din - " })); assertThat(DiffUtil.diffLines(text1, text2, false), equalTo(new String[]{ "soy-dil-din- abc", " ^^^^^^^^^^^^^^^^ ", " z - dil - din - " })); }
public static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace) { final diff_match_patch dmp = new diff_match_patch(); final LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(line1, line2); if (CollectionUtils.isEmpty(diffs)) { return null; } else { if (ignoreWhiteSpace) { final LinkedList<diff_match_patch.Diff> filteredDiffs = Lists.newLinkedList(Iterables.filter(diffs, new Predicate<diff_match_patch.Diff>() { @Override public boolean apply(diff_match_patch.Diff input) { if (input.operation.equals(diff_match_patch.Operation.EQUAL)) return false; else if (StringUtils.isBlank(input.text)) return false; return true; } })); if (filteredDiffs.isEmpty()) return null; } dmp.diff_cleanupSemantic(diffs); final String[] diffLines = diffToFormattedLines(diffs, ignoreWhiteSpace); if (ignoreWhiteSpace) { if (StringUtils.isBlank(diffLines[1]) && StringUtils.isBlank(diffLines[2])) return null; } return diffLines; } }
DiffUtil { public static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace) { final diff_match_patch dmp = new diff_match_patch(); final LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(line1, line2); if (CollectionUtils.isEmpty(diffs)) { return null; } else { if (ignoreWhiteSpace) { final LinkedList<diff_match_patch.Diff> filteredDiffs = Lists.newLinkedList(Iterables.filter(diffs, new Predicate<diff_match_patch.Diff>() { @Override public boolean apply(diff_match_patch.Diff input) { if (input.operation.equals(diff_match_patch.Operation.EQUAL)) return false; else if (StringUtils.isBlank(input.text)) return false; return true; } })); if (filteredDiffs.isEmpty()) return null; } dmp.diff_cleanupSemantic(diffs); final String[] diffLines = diffToFormattedLines(diffs, ignoreWhiteSpace); if (ignoreWhiteSpace) { if (StringUtils.isBlank(diffLines[1]) && StringUtils.isBlank(diffLines[2])) return null; } return diffLines; } } }
DiffUtil { public static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace) { final diff_match_patch dmp = new diff_match_patch(); final LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(line1, line2); if (CollectionUtils.isEmpty(diffs)) { return null; } else { if (ignoreWhiteSpace) { final LinkedList<diff_match_patch.Diff> filteredDiffs = Lists.newLinkedList(Iterables.filter(diffs, new Predicate<diff_match_patch.Diff>() { @Override public boolean apply(diff_match_patch.Diff input) { if (input.operation.equals(diff_match_patch.Operation.EQUAL)) return false; else if (StringUtils.isBlank(input.text)) return false; return true; } })); if (filteredDiffs.isEmpty()) return null; } dmp.diff_cleanupSemantic(diffs); final String[] diffLines = diffToFormattedLines(diffs, ignoreWhiteSpace); if (ignoreWhiteSpace) { if (StringUtils.isBlank(diffLines[1]) && StringUtils.isBlank(diffLines[2])) return null; } return diffLines; } }  }
DiffUtil { public static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace) { final diff_match_patch dmp = new diff_match_patch(); final LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(line1, line2); if (CollectionUtils.isEmpty(diffs)) { return null; } else { if (ignoreWhiteSpace) { final LinkedList<diff_match_patch.Diff> filteredDiffs = Lists.newLinkedList(Iterables.filter(diffs, new Predicate<diff_match_patch.Diff>() { @Override public boolean apply(diff_match_patch.Diff input) { if (input.operation.equals(diff_match_patch.Operation.EQUAL)) return false; else if (StringUtils.isBlank(input.text)) return false; return true; } })); if (filteredDiffs.isEmpty()) return null; } dmp.diff_cleanupSemantic(diffs); final String[] diffLines = diffToFormattedLines(diffs, ignoreWhiteSpace); if (ignoreWhiteSpace) { if (StringUtils.isBlank(diffLines[1]) && StringUtils.isBlank(diffLines[2])) return null; } return diffLines; } }  static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace); }
DiffUtil { public static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace) { final diff_match_patch dmp = new diff_match_patch(); final LinkedList<diff_match_patch.Diff> diffs = dmp.diff_main(line1, line2); if (CollectionUtils.isEmpty(diffs)) { return null; } else { if (ignoreWhiteSpace) { final LinkedList<diff_match_patch.Diff> filteredDiffs = Lists.newLinkedList(Iterables.filter(diffs, new Predicate<diff_match_patch.Diff>() { @Override public boolean apply(diff_match_patch.Diff input) { if (input.operation.equals(diff_match_patch.Operation.EQUAL)) return false; else if (StringUtils.isBlank(input.text)) return false; return true; } })); if (filteredDiffs.isEmpty()) return null; } dmp.diff_cleanupSemantic(diffs); final String[] diffLines = diffToFormattedLines(diffs, ignoreWhiteSpace); if (ignoreWhiteSpace) { if (StringUtils.isBlank(diffLines[1]) && StringUtils.isBlank(diffLines[2])) return null; } return diffLines; } }  static String[] diffLines(final String line1, final String line2, final boolean ignoreWhiteSpace);  }