replace LogicalDeclarationComparator with Comparator.comparing

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2020-05-20 17:06:17 +02:00
parent 5c2f00c1f5
commit e0391a5ea8
2 changed files with 2 additions and 36 deletions

View File

@ -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<MappedResource>
{
public static final LogicalDeclarationComparator INSTANCE = new LogicalDeclarationComparator();
@Override
public int compare(MappedResource o1, MappedResource o2)
{
return o1.getPathSpec().compareTo(o2.getPathSpec());
}
}

View File

@ -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<E> implements Iterable<MappedResource<E>>, Dumpable
{
private static final Logger LOG = Log.getLogger(PathMappings.class);
private final Set<MappedResource<E>> _mappings = new TreeSet<>(LogicalDeclarationComparator.INSTANCE);
private final Set<MappedResource<E>> _mappings = new TreeSet<>(Comparator.comparing(MappedResource::getPathSpec));
private Trie<MappedResource<E>> _exactMap = new ArrayTernaryTrie<>(false);
private Trie<MappedResource<E>> _prefixMap = new ArrayTernaryTrie<>(false);