This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git

commit 4ed9c577c14f3e6b3e268b1fd9c6b23d9b8da442
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jun 23 22:49:07 2023 -0400

    [juneau-marshall] Use lambdas
---
 .../main/java/org/apache/juneau/MediaRanges.java   | 24 +++++------
 .../main/java/org/apache/juneau/StringRanges.java  | 24 +++++------
 .../org/apache/juneau/collections/JsonList.java    | 48 ++++++++++------------
 .../org/apache/juneau/reflect/AnnotationList.java  |  7 +---
 4 files changed, 42 insertions(+), 61 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaRanges.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaRanges.java
index cdd2f2491..afe9802bd 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaRanges.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/MediaRanges.java
@@ -116,20 +116,16 @@ public class MediaRanges {
         * <c>MediaRanges</c> with the same types but with extensions are 
promoted over those same types with no
         * extensions.
         */
-       private static final Comparator<MediaRange> RANGE_COMPARATOR = new 
Comparator<>() {
-               @Override
-               public int compare(MediaRange o1, MediaRange o2) {
-                       // Compare q-values.
-                       int qCompare = Float.compare(o2.getQValue(), 
o1.getQValue());
-                       if (qCompare != 0)
-                               return qCompare;
-
-                       // Compare media-types.
-                       // Note that '*' comes alphabetically before letters, 
so just do a reverse-alphabetical comparison.
-                       int i = o2.toString().compareTo(o1.toString());
-                       return i;
-               }
-       };
+       private static final Comparator<MediaRange> RANGE_COMPARATOR = (o1, o2) 
-> {
+       // Compare q-values.
+       int qCompare = Float.compare(o2.getQValue(), o1.getQValue());
+       if (qCompare != 0)
+               return qCompare;
+
+       // Compare media-types.
+       // Note that '*' comes alphabetically before letters, so just do a 
reverse-alphabetical comparison.
+       return o2.toString().compareTo(o1.toString());
+    };
 
        /**
         * Given a list of media types, returns the best match for this 
<c>Accept</c> header.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRanges.java 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRanges.java
index d9e02b44a..e91de42e1 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRanges.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/StringRanges.java
@@ -139,20 +139,16 @@ public class StringRanges {
         * Should those values be equal, the <c>type</c> is then 
lexicographically compared (case-insensitive) in
         * ascending order, with the <js>"*"</js> type demoted last in that 
order.
         */
-       private static final Comparator<StringRange> RANGE_COMPARATOR = new 
Comparator<>() {
-               @Override
-               public int compare(StringRange o1, StringRange o2) {
-                       // Compare q-values.
-                       int qCompare = Float.compare(o2.getQValue(), 
o1.getQValue());
-                       if (qCompare != 0)
-                               return qCompare;
-
-                       // Compare media-types.
-                       // Note that '*' comes alphabetically before letters, 
so just do a reverse-alphabetical comparison.
-                       int i = o2.toString().compareTo(o1.toString());
-                       return i;
-               }
-       };
+       private static final Comparator<StringRange> RANGE_COMPARATOR = (o1, 
o2) -> {
+       // Compare q-values.
+       int qCompare = Float.compare(o2.getQValue(), o1.getQValue());
+       if (qCompare != 0)
+               return qCompare;
+
+       // Compare media-types.
+       // Note that '*' comes alphabetically before letters, so just do a 
reverse-alphabetical comparison.
+       return o2.toString().compareTo(o1.toString());
+    };
 
        /**
         * Given a list of media types, returns the best match for this string 
range header.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
index 9e748f411..077cf55fd 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
@@ -882,33 +882,27 @@ public class JsonList extends LinkedList<Object> {
         * @param childType The child object type.
         * @return A new <c>Iterable</c> object over this list.
         */
-       public <E> Iterable<E> elements(final Class<E> childType) {
-               final Iterator<?> i = iterator();
-               return new Iterable<>() {
-
-                       @Override /* Iterable */
-                       public Iterator<E> iterator() {
-                               return new Iterator<>() {
-
-                                       @Override /* Iterator */
-                                       public boolean hasNext() {
-                                               return i.hasNext();
-                                       }
-
-                                       @Override /* Iterator */
-                                       public E next() {
-                                               return 
bs().convertToType(i.next(), childType);
-                                       }
-
-                                       @Override /* Iterator */
-                                       public void remove() {
-                                               i.remove();
-                                       }
-
-                               };
-                       }
-               };
-       }
+    public <E> Iterable<E> elements(final Class<E> childType) {
+        final Iterator<?> iterator = iterator();
+        return () -> new Iterator<>() {
+
+            @Override /* Iterator */
+            public boolean hasNext() {
+                return iterator.hasNext();
+            }
+
+            @Override /* Iterator */
+            public E next() {
+                return bs().convertToType(iterator.next(), childType);
+            }
+
+            @Override /* Iterator */
+            public void remove() {
+                iterator.remove();
+            }
+
+        };
+    }
 
        /**
         * Returns the {@link ClassMeta} of the class of the object at the 
specified index.
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
index 376c18910..fafda0aae 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
@@ -29,12 +29,7 @@ import java.util.function.*;
 public final class AnnotationList extends ArrayList<AnnotationInfo<?>> {
        private static final long serialVersionUID = 1L;
 
-       private static final Comparator<AnnotationInfo<?>> RANK_COMPARATOR = 
new Comparator<>() {
-               @Override
-               public int compare(AnnotationInfo<?> o1, AnnotationInfo<?> o2) {
-                       return o1.rank - o2.rank;
-               }
-       };
+       private static final Comparator<AnnotationInfo<?>> RANK_COMPARATOR = 
(o1, o2) -> o1.rank - o2.rank;
 
        /**
         * Sort the annotations in this list based on rank.

Reply via email to