bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [33/50] bval git commit: fix ContainerElementKey comparison
Date Tue, 16 Oct 2018 17:35:34 GMT
fix ContainerElementKey comparison


Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/fe4faf07
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/fe4faf07
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/fe4faf07

Branch: refs/heads/master
Commit: fe4faf0763cf9dfac1460b232d91185881aa09cb
Parents: 99b7488
Author: Matt Benson <mbenson@apache.org>
Authored: Mon Apr 2 11:48:49 2018 -0500
Committer: Matt Benson <mbenson@apache.org>
Committed: Tue Oct 16 12:28:20 2018 -0500

----------------------------------------------------------------------
 .../apache/bval/jsr/metadata/ContainerElementKey.java   | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/fe4faf07/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/ContainerElementKey.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/ContainerElementKey.java
b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/ContainerElementKey.java
index 2d7102b..ed45601 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/ContainerElementKey.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/ContainerElementKey.java
@@ -16,6 +16,10 @@
  */
 package org.apache.bval.jsr.metadata;
 
+import static java.util.Comparator.comparing;
+import static java.util.Comparator.naturalOrder;
+import static java.util.Comparator.nullsFirst;
+
 import java.lang.reflect.AnnotatedParameterizedType;
 import java.lang.reflect.AnnotatedType;
 import java.lang.reflect.ParameterizedType;
@@ -46,6 +50,9 @@ import org.apache.bval.util.Validate;
 import org.apache.bval.util.reflection.TypeUtils;
 
 public class ContainerElementKey implements Comparable<ContainerElementKey> {
+    public static final Comparator<ContainerElementKey> COMPARATOR =
+        nullsFirst(comparing(ContainerElementKey::containerClassName)
+            .thenComparing(ContainerElementKey::getTypeArgumentIndex, nullsFirst(naturalOrder())));
 
     private static Logger log = Logger.getLogger(ContainerElementKey.class.getName());
 
@@ -161,10 +168,7 @@ public class ContainerElementKey implements Comparable<ContainerElementKey>
{
 
     @Override
     public int compareTo(ContainerElementKey o) {
-        return Comparator
-            .nullsFirst(Comparator.comparing(ContainerElementKey::containerClassName)
-                .thenComparing(Comparator.nullsFirst(Comparator.comparing(ContainerElementKey::getTypeArgumentIndex))))
-            .compare(this, o);
+        return COMPARATOR.compare(this, o);
     }
 
     public Set<ContainerElementKey> getAssignableKeys() {


Mime
View raw message