From e0391a5ea833bc104a700af9d37a748e33ec50aa Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 20 May 2020 17:06:17 +0200 Subject: [PATCH] replace LogicalDeclarationComparator with Comparator.comparing Signed-off-by: Ludovic Orban --- .../pathmap/LogicalDeclarationComparator.java | 35 ------------------- .../jetty/http/pathmap/PathMappings.java | 3 +- 2 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/LogicalDeclarationComparator.java diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/LogicalDeclarationComparator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/LogicalDeclarationComparator.java deleted file mode 100644 index 3ad17257c74..00000000000 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/LogicalDeclarationComparator.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.http.pathmap; - -import java.util.Comparator; - -/** - * Sort {@link MappedResource}s by their {@link MappedResource#getPathSpec()} logical declarations. - */ -public class LogicalDeclarationComparator implements Comparator -{ - public static final LogicalDeclarationComparator INSTANCE = new LogicalDeclarationComparator(); - - @Override - public int compare(MappedResource o1, MappedResource o2) - { - return o1.getPathSpec().compareTo(o2.getPathSpec()); - } -} diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java index 9fc42fcc2ed..bf59e908b03 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.http.pathmap; import java.io.IOException; import java.util.ArrayList; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Optional; @@ -46,7 +47,7 @@ import org.eclipse.jetty.util.log.Logger; public class PathMappings implements Iterable>, Dumpable { private static final Logger LOG = Log.getLogger(PathMappings.class); - private final Set> _mappings = new TreeSet<>(LogicalDeclarationComparator.INSTANCE); + private final Set> _mappings = new TreeSet<>(Comparator.comparing(MappedResource::getPathSpec)); private Trie> _exactMap = new ArrayTernaryTrie<>(false); private Trie> _prefixMap = new ArrayTernaryTrie<>(false);