json/src/main/java/net/java/html/json/Component.java
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 15 Dec 2015 23:19:35 +0100
branchComponent257162
changeset 1035 3534e15dc446
permissions -rw-r--r--
Introducing @Component annotation, adding basic annotation and providing its (reflection based) implementation in ko4j module.
jtulach@1035
     1
/**
jtulach@1035
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jtulach@1035
     3
 *
jtulach@1035
     4
 * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
jtulach@1035
     5
 *
jtulach@1035
     6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
jtulach@1035
     7
 * Other names may be trademarks of their respective owners.
jtulach@1035
     8
 *
jtulach@1035
     9
 * The contents of this file are subject to the terms of either the GNU
jtulach@1035
    10
 * General Public License Version 2 only ("GPL") or the Common
jtulach@1035
    11
 * Development and Distribution License("CDDL") (collectively, the
jtulach@1035
    12
 * "License"). You may not use this file except in compliance with the
jtulach@1035
    13
 * License. You can obtain a copy of the License at
jtulach@1035
    14
 * http://www.netbeans.org/cddl-gplv2.html
jtulach@1035
    15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jtulach@1035
    16
 * specific language governing permissions and limitations under the
jtulach@1035
    17
 * License.  When distributing the software, include this License Header
jtulach@1035
    18
 * Notice in each file and include the License file at
jtulach@1035
    19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
jtulach@1035
    20
 * particular file as subject to the "Classpath" exception as provided
jtulach@1035
    21
 * by Oracle in the GPL Version 2 section of the License file that
jtulach@1035
    22
 * accompanied this code. If applicable, add the following below the
jtulach@1035
    23
 * License Header, with the fields enclosed by brackets [] replaced by
jtulach@1035
    24
 * your own identifying information:
jtulach@1035
    25
 * "Portions Copyrighted [year] [name of copyright owner]"
jtulach@1035
    26
 *
jtulach@1035
    27
 * Contributor(s):
jtulach@1035
    28
 *
jtulach@1035
    29
 * The Original Software is NetBeans. The Initial Developer of the Original
jtulach@1035
    30
 * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
jtulach@1035
    31
 *
jtulach@1035
    32
 * If you wish your version of this file to be governed by only the CDDL
jtulach@1035
    33
 * or only the GPL Version 2, indicate your decision by adding
jtulach@1035
    34
 * "[Contributor] elects to include this software in this distribution
jtulach@1035
    35
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
jtulach@1035
    36
 * single choice of license, a recipient has the option to distribute
jtulach@1035
    37
 * your version of this file under either the CDDL, the GPL Version 2 or
jtulach@1035
    38
 * to extend the choice of license to its licensees as provided above.
jtulach@1035
    39
 * However, if you add GPL Version 2 code and therefore, elected the GPL
jtulach@1035
    40
 * Version 2 license, then the option applies only if the new code is
jtulach@1035
    41
 * made subject to such option by the copyright holder.
jtulach@1035
    42
 */
jtulach@1035
    43
package net.java.html.json;
jtulach@1035
    44
jtulach@1035
    45
import java.lang.annotation.ElementType;
jtulach@1035
    46
import java.lang.annotation.Retention;
jtulach@1035
    47
import java.lang.annotation.RetentionPolicy;
jtulach@1035
    48
import java.lang.annotation.Target;
jtulach@1035
    49
jtulach@1035
    50
/** Defines a reusable piece of code and UI. Put the annotation on a
jtulach@1035
    51
 * method that accepts a class generated by the {@link Model} annotation
jtulach@1035
    52
 * and returns another class generated with the help of the
jtulach@1035
    53
 * {@link Model} annotation. The first annotation describes the
jtulach@1035
    54
 * input parameters. The latter one the internal structure of the
jtulach@1035
    55
 * {@link #template() declarative UI snippet}.
jtulach@1035
    56
 */
jtulach@1035
    57
@Target(ElementType.METHOD)
jtulach@1035
    58
@Retention(RetentionPolicy.SOURCE)
jtulach@1035
    59
public @interface Component {
jtulach@1035
    60
    /**
jtulach@1035
    61
     * Gives the component a name.
jtulach@1035
    62
     * @return name that one uses from the UI to reference this component
jtulach@1035
    63
     */
jtulach@1035
    64
    public String name();
jtulach@1035
    65
    /**
jtulach@1035
    66
     * Location of associated file with UI. Usually (but not always) a fragment
jtulach@1035
    67
     * of HTML that
jtulach@1035
    68
     * @return
jtulach@1035
    69
     */
jtulach@1035
    70
    public String template();
jtulach@1035
    71
    /**
jtulach@1035
    72
     * Technologies that should be preferred when processing the
jtulach@1035
    73
     * {@link #template} of this component.
jtulach@1035
    74
     * @return ids of technologies to prefer inside of the component
jtulach@1035
    75
     */
jtulach@1035
    76
    public String[] techIds() default {};
jtulach@1035
    77
}