1 /*
   2  * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Sun designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Sun in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  22  * CA 95054 USA or visit www.sun.com if you need additional information or
  23  * have any questions.
  24  */
  25 
  26 package com.sun.mirror.util;
  27 
  28 
  29 import java.util.Collection;
  30 
  31 import com.sun.mirror.declaration.*;
  32 import com.sun.mirror.type.*;
  33 
  34 
  35 /**
  36  * Utility methods for operating on types.
  37  *
  38  * @deprecated All components of this API have been superseded by the
  39  * standardized annotation processing API.  The replacement for the
  40  * functionality of this interface is {@link
  41  * javax.lang.model.util.Types}.
  42  *
  43  * @author Joseph D. Darcy
  44  * @author Scott Seligman
  45  * @since 1.5
  46  */
  47 @Deprecated
  48 @SuppressWarnings("deprecation")
  49 public interface Types {
  50 
  51     /**
  52      * Tests whether one type is a subtype of the another.
  53      * Any type is considered to be a subtype of itself.
  54      *
  55      * @param t1  the first type
  56      * @param t2  the second type
  57      * @return <tt>true</tt> if and only if the first type is a subtype
  58      *          of the second
  59      */
  60     boolean isSubtype(TypeMirror t1, TypeMirror t2);
  61 
  62     /**
  63      * Tests whether one type is assignable to another.
  64      *
  65      * @param t1  the first type
  66      * @param t2  the second type
  67      * @return <tt>true</tt> if and only if the first type is assignable
  68      *          to the second
  69      */
  70     boolean isAssignable(TypeMirror t1, TypeMirror t2);
  71 
  72     /**
  73      * Returns the erasure of a type.
  74      *
  75      * @param t  the type to be erased
  76      * @return the erasure of the given type
  77      */
  78     TypeMirror getErasure(TypeMirror t);
  79 
  80     /**
  81      * Returns a primitive type.
  82      *
  83      * @param kind  the kind of primitive type to return
  84      * @return a primitive type
  85      */
  86     PrimitiveType getPrimitiveType(PrimitiveType.Kind kind);
  87 
  88     /**
  89      * Returns the pseudo-type representing the type of <tt>void</tt>.
  90      *
  91      * @return the pseudo-type representing the type of <tt>void</tt>
  92      */
  93     VoidType getVoidType();
  94 
  95     /**
  96      * Returns an array type with the specified component type.
  97      *
  98      * @param componentType  the component type
  99      * @return an array type with the specified component type.
 100      * @throws IllegalArgumentException if the component type is not valid for
 101      *          an array
 102      */
 103     ArrayType getArrayType(TypeMirror componentType);
 104 
 105     /**
 106      * Returns the type variable declared by a type parameter.
 107      *
 108      * @param tparam  the type parameter
 109      * @return the type variable declared by the type parameter
 110      */
 111     TypeVariable getTypeVariable(TypeParameterDeclaration tparam);
 112 
 113     /**
 114      * Returns a new wildcard.
 115      * Either the wildcards's upper bounds or lower bounds may be
 116      * specified, or neither, but not both.
 117      *
 118      * @param upperBounds  the upper bounds of this wildcard,
 119      *          or an empty collection if none
 120      * @param lowerBounds  the lower bounds of this wildcard,
 121      *          or an empty collection if none
 122      * @return a new wildcard
 123      * @throws IllegalArgumentException if bounds are not valid
 124      */
 125     WildcardType getWildcardType(Collection<ReferenceType> upperBounds,
 126                                  Collection<ReferenceType> lowerBounds);
 127 
 128     /**
 129      * Returns the type corresponding to a type declaration and
 130      * actual type arguments.
 131      * Given the declaration for <tt>String</tt>, for example, this
 132      * method may be used to get the <tt>String</tt> type.  It may
 133      * then be invoked a second time, with the declaration for <tt>Set</tt>,
 134      * to make the parameterized type {@code Set<String>}.
 135      *
 136      * <p> The number of type arguments must either equal the
 137      * number of the declaration's formal type parameters, or must be
 138      * zero.  If zero, and if the declaration is generic,
 139      * then the declaration's raw type is returned.
 140      *
 141      * <p> If a parameterized type is being returned, its declaration
 142      * must not be contained within a generic outer class.
 143      * The parameterized type {@code Outer<String>.Inner<Number>},
 144      * for example, may be constructed by first using this
 145      * method to get the type {@code Outer<String>}, and then invoking
 146      * {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}.
 147      *
 148      * @param decl      the type declaration
 149      * @param typeArgs  the actual type arguments
 150      * @return the type corresponding to the type declaration and
 151      *          actual type arguments
 152      * @throws IllegalArgumentException if too many or too few
 153      *          type arguments are given, or if an inappropriate type
 154      *          argument or declaration is provided
 155      */
 156     DeclaredType getDeclaredType(TypeDeclaration decl,
 157                                  TypeMirror... typeArgs);
 158 
 159     /**
 160      * Returns the type corresponding to a type declaration
 161      * and actual arguments, given a
 162      * {@linkplain DeclaredType#getContainingType() containing type}
 163      * of which it is a member.
 164      * The parameterized type {@code Outer<String>.Inner<Number>},
 165      * for example, may be constructed by first using
 166      * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)}
 167      * to get the type {@code Outer<String>}, and then invoking
 168      * this method.
 169      *
 170      * <p> If the containing type is a parameterized type,
 171      * the number of type arguments must equal the
 172      * number of the declaration's formal type parameters.
 173      * If it is not parameterized or if it is <tt>null</tt>, this method is
 174      * equivalent to <tt>getDeclaredType(decl, typeArgs)</tt>.
 175      *
 176      * @param containing  the containing type, or <tt>null</tt> if none
 177      * @param decl        the type declaration
 178      * @param typeArgs    the actual type arguments
 179      * @return the type corresponding to the type declaration and
 180      *          actual type arguments,
 181      *          contained within the given type
 182      * @throws IllegalArgumentException if too many or too few
 183      *          type arguments are given, or if an inappropriate type
 184      *          argument, declaration, or containing type is provided
 185      */
 186     DeclaredType getDeclaredType(DeclaredType containing,
 187                                  TypeDeclaration decl,
 188                                  TypeMirror... typeArgs);
 189 }