Skip to content

Commit 41e2e28

Browse files
committed
Use some lambda
1 parent 535e7f7 commit 41e2e28

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/main/java/com/mergebase/log4j/Log4JDetector.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,17 @@ private static boolean isZipSentinel(int[] chunk) {
217217
return chunk[0] == 0x50 && chunk[1] == 0x4B && chunk[2] == 3 && chunk[3] == 4;
218218
}
219219

220-
private static final Comparator<File> FILES_ORDER_BY_NAME = new Comparator<>() {
221-
@Override
222-
public int compare(File f1, File f2) {
223-
String s1 = f1 != null ? f1.getName() : "";
224-
String s2 = f2 != null ? f2.getName() : "";
225-
int c = s1.compareToIgnoreCase(s2);
226-
if (c == 0) {
227-
c = s1.compareTo(s2);
228-
if (c == 0 && f1 != null) {
229-
c = f1.compareTo(f2);
230-
}
220+
private static final Comparator<File> FILES_ORDER_BY_NAME = (f1, f2) -> {
221+
String s1 = f1 != null ? f1.getName() : "";
222+
String s2 = f2 != null ? f2.getName() : "";
223+
int c = s1.compareToIgnoreCase(s2);
224+
if (c == 0) {
225+
c = s1.compareTo(s2);
226+
if (c == 0 && f1 != null) {
227+
c = f1.compareTo(f2);
231228
}
232-
return c;
233229
}
230+
return c;
234231
};
235232

236233
/**

src/main/java/com/mergebase/log4j/VersionComparator.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,10 @@ private static String[] subSplit(String s) {
150150
}
151151

152152
public static Comparator<String> comparatorBySimilarity(final String anchor) {
153-
return new Comparator<>() {
154-
@Override
155-
public int compare(String o1, String o2) {
156-
int i1 = similarity(anchor, o1);
157-
int i2 = similarity(anchor, o2);
158-
return Integer.compare(i1, i2);
159-
}
153+
return (o1, o2) -> {
154+
int i1 = similarity(anchor, o1);
155+
int i2 = similarity(anchor, o2);
156+
return Integer.compare(i1, i2);
160157
};
161158
}
162159

0 commit comments

Comments
 (0)