001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest; 018 019import org.apache.juneau.cp.*; 020 021/** 022 * Represents a simple child REST resource / path mapping. 023 * 024 * <h5 class='section'>Example:</h5> 025 * <p class='bjava'> 026 * <jc>// Parent resource.</jc> 027 * <jk>public class</jk> MyResource { 028 * <jk>public</jk> MyResource(RestContext.Builder <jv>builder</jv>) <jk>throws</jk> Exception { 029 * 030 * <jc>// Register a child resource.</jc> 031 * <jv>builder</jv>.children(<jk>new</jk> RestChild(<js>"/child"</js>, <jk>new</jk> MyChildResource()); 032 * 033 * <jc>// The above is equivalent to...</jc> 034 * <jv>builder</jv>.child(<js>"/child"</js>, <jk>new</jk> MyChildResource()); 035 * } 036 * } 037 * </p> 038 * 039 * <h5 class='section'>See Also:</h5><ul> 040 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestAnnotatedClassBasics">@Rest-Annotated Class Basics</a> 041 * </ul> 042 */ 043public class RestChild { 044 045 // final UrlPathPattern path; 046 final String path; 047 final Object resource; 048 049 /** 050 * Constructor. 051 * 052 * @param path The child resource path relative to the parent resource URI. 053 * @param resource 054 * The child resource. 055 * <br>Can either be a Class (which will be instantiated using the registered {@link BeanStore}) 056 * or an already-instantiated object. 057 */ 058 public RestChild(/*UrlPathPattern path, */ String path, Object resource) { 059 this.path = path; 060 this.resource = resource; 061 } 062}