001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.labels;
014
015import org.apache.juneau.html.annotation.*;
016
017/**
018 * Shortcut label for child resources.  Typically used in router resources.
019 * 
020 * <h5 class='section'>Example:</h5>
021 * <p class='bcode'>
022 *    <jk>new</jk> ResourceLink(<js>"httpTool"</js>, <js>"HTTP request test client"</js>);
023 * </p>
024 * 
025 * <h5 class='section'>See Also:</h5>
026 * <ul>
027 *    <li class='link'><a class="doclink" href="../../../../../overview-summary.html#juneau-rest-server.PredefinedLabelBeans">Overview &gt; juneau-rest-server &gt; Predefined Label Beans</a>
028 * </ul>
029 */
030public final class ResourceDescription extends NameDescription implements Comparable<ResourceDescription> {
031
032   /**
033    * Constructor.
034    * 
035    * @param name The name of the child resource.
036    * @param description The description of the child resource.
037    */
038   public ResourceDescription(String name, String description) {
039      super(name, description);
040   }
041
042   /** No-arg constructor.  Used for JUnit testing of OPTIONS pages. */
043   public ResourceDescription() {}
044
045   @Override /* NameDescription */
046   @Html(link="servlet:/{name}")
047   public Object getName() {
048      return super.getName();
049   }
050
051   @Override /* Comparable */
052   public int compareTo(ResourceDescription o) {
053      return getName().toString().compareTo(o.getName().toString());
054   }
055
056   @Override /* Object */
057   public boolean equals(Object o) {
058      return (o instanceof ResourceDescription) && ((ResourceDescription)o).getName().equals(getName());
059   }
060
061   @Override /* Object */
062   public int hashCode() {
063      return getName().hashCode();
064   }
065}