001/***
002 * ASM: a very small and fast Java bytecode manipulation framework
003 * Copyright (c) 2000-2011 INRIA, France Telecom
004 * All rights reserved.
005 *
006 * Redistribution and use in source and binary forms, with or without
007 * modification, are permitted provided that the following conditions
008 * are met:
009 * 1. Redistributions of source code must retain the above copyright
010 *    notice, this list of conditions and the following disclaimer.
011 * 2. Redistributions in binary form must reproduce the above copyright
012 *    notice, this list of conditions and the following disclaimer in the
013 *    documentation and/or other materials provided with the distribution.
014 * 3. Neither the name of the copyright holders nor the names of its
015 *    contributors may be used to endorse or promote products derived from
016 *    this software without specific prior written permission.
017 *
018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
028 * THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package io.ebean.enhance.asm.tree;
031
032import io.ebean.enhance.asm.Opcodes;
033import io.ebean.enhance.asm.TypePath;
034import io.ebean.enhance.asm.TypeReference;
035
036/**
037 * A node that represents a type annotationn.
038 * 
039 * @author Eric Bruneton
040 */
041public class TypeAnnotationNode extends AnnotationNode {
042
043    /**
044     * A reference to the annotated type. See {@link TypeReference}.
045     */
046    public int typeRef;
047
048    /**
049     * The path to the annotated type argument, wildcard bound, array element
050     * type, or static outer type within the referenced type. May be
051     * <tt>null</tt> if the annotation targets 'typeRef' as a whole.
052     */
053    public TypePath typePath;
054
055    /**
056     * Constructs a new {@link AnnotationNode}. <i>Subclasses must not use this
057     * constructor</i>. Instead, they must use the
058     * {@link #TypeAnnotationNode(int, int, TypePath, String)} version.
059     * 
060     * @param typeRef
061     *            a reference to the annotated type. See {@link TypeReference}.
062     * @param typePath
063     *            the path to the annotated type argument, wildcard bound, array
064     *            element type, or static inner type within 'typeRef'. May be
065     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
066     * @param desc
067     *            the class descriptor of the annotation class.
068     * @throws IllegalStateException
069     *             If a subclass calls this constructor.
070     */
071    public TypeAnnotationNode(final int typeRef, final TypePath typePath,
072            final String desc) {
073        this(Opcodes.ASM6, typeRef, typePath, desc);
074        if (getClass() != TypeAnnotationNode.class) {
075            throw new IllegalStateException();
076        }
077    }
078
079    /**
080     * Constructs a new {@link AnnotationNode}.
081     * 
082     * @param api
083     *            the ASM API version implemented by this visitor. Must be one
084     *            of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
085     * @param typeRef
086     *            a reference to the annotated type. See {@link TypeReference}.
087     * @param typePath
088     *            the path to the annotated type argument, wildcard bound, array
089     *            element type, or static inner type within 'typeRef'. May be
090     *            <tt>null</tt> if the annotation targets 'typeRef' as a whole.
091     * @param desc
092     *            the class descriptor of the annotation class.
093     */
094    public TypeAnnotationNode(final int api, final int typeRef,
095                              final TypePath typePath, final String desc) {
096        super(api, desc);
097        this.typeRef = typeRef;
098        this.typePath = typePath;
099    }
100}