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.beans; 018 019import org.apache.juneau.bean.html5.*; 020 021/** 022 * Defines a simple hyperlink class. 023 * 024 * <h5 class='figure'>Examples:</h5> 025 * <p class='bjava'> 026 * <ja>@Rest</ja> 027 * <jk>public class</jk> MyRest <jk>extends</jk> BasicRestServlet { 028 * 029 * <jc>// Produces <a href="/foo">bar</a></jc> 030 * <ja>@RestGet</ja> 031 * <jk>public</jk> Hyperlink a01() { 032 * <jk>return new</jk> Hyperlink(<js>"foo"</js>, <js>"bar"</js>); 033 * } 034 * 035 * <jc>// Produces <ul><li><a href="/foo">bar</a></li></ul></jc> 036 * <ja>@RestGet</ja> 037 * <jk>public</jk> Hyperlink[] a02() { 038 * <jk>return new</jk> Hyperlink[]{a01()}; 039 * } 040 * 041 * <jc>// Produces <ul><li><a href="/foo">bar</a></li></ul></jc> 042 * <ja>@RestGet</ja> 043 * <jk>public</jk> Collection<Hyperlink> a03() { 044 * <jk>return</jk> Arrays.<jsm>asList</jsm>(a02()); 045 * } 046 * } 047 * </p> 048 * 049 * <h5 class='section'>See Also:</h5><ul> 050 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/UtilityBeans">Utility Beans</a> 051 * </ul> 052 */ 053public class Hyperlink extends A { 054 055 //----------------------------------------------------------------------------------------------------------------- 056 // Static 057 //----------------------------------------------------------------------------------------------------------------- 058 059 /** 060 * Static creator. 061 * 062 * @param href The {@link A#href(Object)} attribute. 063 * @param children The {@link A#children(Object[])} nodes. 064 * @return A new {@link Hyperlink} object. 065 */ 066 public static Hyperlink create(Object href, Object...children) { 067 return new Hyperlink(href, children); 068 } 069 070 //----------------------------------------------------------------------------------------------------------------- 071 // Implementation 072 //----------------------------------------------------------------------------------------------------------------- 073 074 /** 075 * Creates an empty {@link A} element. 076 */ 077 public Hyperlink() {} 078 079 /** 080 * Creates an {@link A} element with the specified {@link A#href(Object)} attribute and {@link A#children(Object[])} 081 * nodes. 082 * 083 * @param href The {@link A#href(Object)} attribute. 084 * @param children The {@link A#children(Object[])} nodes. 085 */ 086 public Hyperlink(Object href, Object...children) { 087 super(href, children); 088 } 089}