2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.http.pathmap;
21 import org.eclipse.jetty.util.annotation.ManagedAttribute;
22 import org.eclipse.jetty.util.annotation.ManagedObject;
24 @ManagedObject("Mapped Resource")
25 public class MappedResource<E> implements Comparable<MappedResource<E>>
27 private final PathSpec pathSpec;
28 private final E resource;
30 public MappedResource(PathSpec pathSpec, E resource)
32 this.pathSpec = pathSpec;
33 this.resource = resource;
37 * Comparison is based solely on the pathSpec
40 public int compareTo(MappedResource<E> other)
42 return this.pathSpec.compareTo(other.pathSpec);
46 public boolean equals(Object obj)
56 if (getClass() != obj.getClass())
60 MappedResource<?> other = (MappedResource<?>)obj;
63 if (other.pathSpec != null)
68 else if (!pathSpec.equals(other.pathSpec))
75 @ManagedAttribute(value = "path spec", readonly = true)
76 public PathSpec getPathSpec()
81 @ManagedAttribute(value = "resource", readonly = true)
82 public E getResource()
92 result = (prime * result) + ((pathSpec == null) ? 0 : pathSpec.hashCode());
97 public String toString()
99 return String.format("MappedResource[pathSpec=%s,resource=%s]",pathSpec,resource);