Skip to content

Commit

Permalink
Improve code style
Browse files Browse the repository at this point in the history
- Simplify comparisons
  • Loading branch information
spannm committed Feb 16, 2024
1 parent 7375715 commit f2f56de
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public String toString() {

try {
sb.append("hasContentsEntry", hasContentsEntry())
.append("entries", getEntries(new ArrayList<Entry>(), getFileSystem().getRoot(), ENTRY_SEPARATOR));
.append("entries", getEntries(new ArrayList<>(), getFileSystem().getRoot(), ENTRY_SEPARATOR));
} catch (IOException e) {
sb.append("entries", "<" + e + ">");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public enum EntryType {
if (pos < len) {
return ByteUtil.asUnsignedByte(left[pos]) < ByteUtil.asUnsignedByte(right[pos]) ? -1 : 1;
}
return left.length < right.length ? -1 : left.length > right.length ? 1 : 0;
return Integer.compare(left.length, right.length);
};

/** name, generated on demand */
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/github/spannm/jackcess/impl/TableImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ public enum IndexFeature {
* comparator which sorts variable length columns based on their index into the variable length offset table
*/
private static final Comparator<ColumnImpl> VAR_LEN_COLUMN_COMPARATOR =
(c1, c2) -> c1.getVarLenTableIndex() < c2.getVarLenTableIndex() ? -1
: c1.getVarLenTableIndex() > c2.getVarLenTableIndex() ? 1 : 0;
(c1, c2) -> Integer.compare(c1.getVarLenTableIndex(), c2.getVarLenTableIndex());

/** comparator which sorts columns based on their display index */
private static final Comparator<ColumnImpl> DISPLAY_ORDER_COMPARATOR =
(c1, c2) -> c1.getDisplayIndex() < c2.getDisplayIndex() ? -1 : c1.getDisplayIndex() > c2.getDisplayIndex() ? 1 : 0;
(c1, c2) -> Integer.compare(c1.getDisplayIndex(), c2.getDisplayIndex());

/** owning database */
private final DatabaseImpl _database;
Expand Down

0 comments on commit f2f56de

Please sign in to comment.