langtools/src/java.compiler/share/classes/javax/lang/model/type/TypeMirror.java
author darcy
Wed, 22 Feb 2017 12:01:15 -0800
changeset 44014 56d15b6333fc
parent 25874 83c19f00452c
permissions -rw-r--r--
8175335: Improve handling of module types in javax.lang.model.util.Types Reviewed-by: jjg, abuckley
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
44014
56d15b6333fc 8175335: Improve handling of module types in javax.lang.model.util.Types
darcy
parents: 25874
diff changeset
     2
 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.lang.model.type;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
16557
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 5520
diff changeset
    28
import java.lang.annotation.Annotation;
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 5520
diff changeset
    29
import java.util.List;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import javax.lang.model.util.Types;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Represents a type in the Java programming language.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * Types include primitive types, declared types (class and interface types),
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * array types, type variables, and the null type.
44014
56d15b6333fc 8175335: Improve handling of module types in javax.lang.model.util.Types
darcy
parents: 25874
diff changeset
    37
 * Also represented are wildcard type arguments, the signature and
56d15b6333fc 8175335: Improve handling of module types in javax.lang.model.util.Types
darcy
parents: 25874
diff changeset
    38
 * return types of executables, and pseudo-types corresponding to
56d15b6333fc 8175335: Improve handling of module types in javax.lang.model.util.Types
darcy
parents: 25874
diff changeset
    39
 * packages, modules, and the keyword {@code void}.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * <p> Types should be compared using the utility methods in {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * Types}.  There is no guarantee that any particular type will always
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * be represented by the same object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * <p> To implement operations based on the class of an {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * or use the result of the {@link #getKind} method.  Using {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * instanceof} is <em>not</em> necessarily a reliable idiom for
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * determining the effective class of an object in this modeling
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * hierarchy since an implementation may choose to have a single
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * object implement multiple {@code TypeMirror} subinterfaces.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @see Element
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @see Types
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 */
16557
67a3ae363f03 8007803: Implement javax.lang.model API for Type Annotations
jjg
parents: 5520
diff changeset
    60
public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Returns the {@code kind} of this type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * @return the kind of this type
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    TypeKind getKind();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * Obeys the general contract of {@link Object#equals Object.equals}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * This method does not, however, indicate whether two types represent
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * the same type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * Semantic comparisons of type equality should instead use
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * {@link Types#isSameType(TypeMirror, TypeMirror)}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * The results of {@code t1.equals(t2)} and
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * {@code Types.isSameType(t1, t2)} may differ.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @param obj  the object to be compared with this type
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @return {@code true} if the specified object is equal to this one
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    boolean equals(Object obj);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Obeys the general contract of {@link Object#hashCode Object.hashCode}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @see #equals
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    int hashCode();
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Returns an informative string representation of this type.  If
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * possible, the string should be of a form suitable for
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * representing this type in source code.  Any names embedded in
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * the result are qualified if possible.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * @return a string representation of this type
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    String toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * Applies a visitor to this type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * @param <R> the return type of the visitor's methods
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @param <P> the type of the additional parameter to the visitor's methods
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @param v   the visitor operating on this type
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * @param p   additional parameter to the visitor
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * @return a visitor-specified result
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    <R, P> R accept(TypeVisitor<R, P> v, P p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
}