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