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;
014
015import org.apache.juneau.cp.*;
016
017/**
018 * Represents a simple child REST resource / path mapping.
019 *
020 * <h5 class='section'>Example:</h5>
021 * <p class='bjava'>
022 *    <jc>// Parent resource.</jc>
023 *    <jk>public class</jk> MyResource {
024 *       <jk>public</jk> MyResource(RestContext.Builder <jv>builder</jv>) <jk>throws</jk> Exception {
025 *
026 *          <jc>// Register a child resource.</jc>
027 *          <jv>builder</jv>.children(<jk>new</jk> RestChild(<js>"/child"</js>, <jk>new</jk> MyChildResource());
028 *
029 *          <jc>// The above is equivalent to...</jc>
030 *          <jv>builder</jv>.child(<js>"/child"</js>, <jk>new</jk> MyChildResource());
031 *       }
032 *    }
033 * </p>
034 *
035 * <h5 class='section'>See Also:</h5><ul>
036 *    <li class='link'><a class="doclink" href="../../../../index.html#jrs.AnnotatedClasses">@Rest-Annotated Classes</a>
037 * </ul>
038 */
039public class RestChild {
040
041   // final UrlPathPattern path;
042   final String path;
043   final Object resource;
044
045   /**
046    * Constructor.
047    *
048    * @param path The child resource path relative to the parent resource URI.
049    * @param resource
050    *    The child resource.
051    *    <br>Can either be a Class (which will be instantiated using the registered {@link BeanStore})
052    *    or an already-instantiated object.
053    */
054   public RestChild(/*UrlPathPattern path, */ String path, Object resource) {
055      this.path = path;
056      this.resource = resource;
057   }
058}