Skip to content

Commit

Permalink
Added some lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
tweimer committed Oct 13, 2024
1 parent 535e7f7 commit dec9712
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
21 changes: 9 additions & 12 deletions src/main/java/com/mergebase/log4j/Log4JDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,17 @@ private static boolean isZipSentinel(int[] chunk) {
return chunk[0] == 0x50 && chunk[1] == 0x4B && chunk[2] == 3 && chunk[3] == 4;
}

private static final Comparator<File> FILES_ORDER_BY_NAME = new Comparator<>() {
@Override
public int compare(File f1, File f2) {
String s1 = f1 != null ? f1.getName() : "";
String s2 = f2 != null ? f2.getName() : "";
int c = s1.compareToIgnoreCase(s2);
if (c == 0) {
c = s1.compareTo(s2);
if (c == 0 && f1 != null) {
c = f1.compareTo(f2);
}
private static final Comparator<File> FILES_ORDER_BY_NAME = (f1, f2) -> {
String s1 = f1 != null ? f1.getName() : "";
String s2 = f2 != null ? f2.getName() : "";
int c = s1.compareToIgnoreCase(s2);
if (c == 0) {
c = s1.compareTo(s2);
if (c == 0 && f1 != null) {
c = f1.compareTo(f2);
}
return c;
}
return c;
};

/**
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/mergebase/log4j/VersionComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,7 @@ private static String[] subSplit(String s) {
}

public static Comparator<String> comparatorBySimilarity(final String anchor) {
return new Comparator<>() {
@Override
public int compare(String o1, String o2) {
int i1 = similarity(anchor, o1);
int i2 = similarity(anchor, o2);
return Integer.compare(i1, i2);
}
};
return Comparator.comparingInt(s -> similarity(anchor, s));
}

public static int similarity(String s1, String s2) {
Expand Down

0 comments on commit dec9712

Please sign in to comment.