You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2021/04/25 21:50:47 UTC
[commons-imaging] 01/03: [IMAGING-295] Use 'compare()' method to
compare numbers
This is an automated email from the ASF dual-hosted git repository.
kinow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit 5fce159e9017c5f13f77bf14cc2ec43ae764962f
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Sun Apr 25 15:51:44 2021 +0200
[IMAGING-295] Use 'compare()' method to compare numbers
---
.../org/apache/commons/imaging/formats/tiff/TiffElement.java | 10 +---------
.../imaging/formats/tiff/write/TiffOutputDirectory.java | 10 +---------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java
index 4439173..35b5118 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java
@@ -21,15 +21,7 @@ import java.util.Comparator;
public abstract class TiffElement {
public final long offset;
public final int length;
- public static final Comparator<TiffElement> COMPARATOR = (e1, e2) -> {
- if (e1.offset < e2.offset) {
- return -1;
- }
- if (e1.offset > e2.offset) {
- return 1;
- }
- return 0;
- };
+ public static final Comparator<TiffElement> COMPARATOR = Comparator.comparingLong(e -> e.offset);
public TiffElement(final long offset, final int length) {
this.offset = offset;
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
index a9a1515..4913878 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
@@ -74,15 +74,7 @@ public final class TiffOutputDirectory extends TiffOutputItem {
private final List<TiffOutputField> fields = new ArrayList<>();
private final ByteOrder byteOrder;
private TiffOutputDirectory nextDirectory;
- public static final Comparator<TiffOutputDirectory> COMPARATOR = (o1, o2) -> {
- if (o1.type < o2.type) {
- return -1;
- }
- if (o1.type > o2.type) {
- return 1;
- }
- return 0;
- };
+ public static final Comparator<TiffOutputDirectory> COMPARATOR = Comparator.comparingInt(o -> o.type);
private JpegImageData jpegImageData;
private TiffImageData tiffImageData;