This example Java source code file (Types.java) is included in the alvinalexander.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.lang.model.util;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationTypeMismatchException;
import java.lang.annotation.IncompleteAnnotationException;
import java.util.List;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
/**
* Utility methods for operating on types.
*
* <p>Compatibility Note: Methods may be added to this interface
* in future releases of the platform.
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @see javax.annotation.processing.ProcessingEnvironment#getTypeUtils
* @since 1.6
*/
public interface Types {
/**
* Returns the element corresponding to a type.
* The type may be a {@code DeclaredType} or {@code TypeVariable}.
* Returns {@code null} if the type is not one with a
* corresponding element.
*
* @param t the type to map to an element
* @return the element corresponding to the given type
*/
Element asElement(TypeMirror t);
/**
* Tests whether two {@code TypeMirror} objects represent the same type.
*
* <p>Caveat: if either of the arguments to this method represents a
* wildcard, this method will return false. As a consequence, a wildcard
* is not the same type as itself. This might be surprising at first,
* but makes sense once you consider that an example like this must be
* rejected by the compiler:
* <pre>
* {@code List<?> list = new ArrayList