feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
235
jdkSrc/jdk8/javax/lang/model/AnnotatedConstruct.java
Normal file
235
jdkSrc/jdk8/javax/lang/model/AnnotatedConstruct.java
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (c) 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;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
|
||||
/**
|
||||
* Represents a construct that can be annotated.
|
||||
*
|
||||
* A construct is either an {@linkplain
|
||||
* javax.lang.model.element.Element element} or a {@linkplain
|
||||
* javax.lang.model.type.TypeMirror type}. Annotations on an element
|
||||
* are on a <em>declaration</em>, whereas annotations on a type are on
|
||||
* a specific <em>use</em> of a type name.
|
||||
*
|
||||
* The terms <em>directly present</em>, <em>present</em>,
|
||||
* <em>indirectly present</em>, and <em>associated </em> are used
|
||||
* throughout this interface to describe precisely which annotations
|
||||
* are returned by the methods defined herein.
|
||||
*
|
||||
* <p>In the definitions below, an annotation <i>A</i> has an
|
||||
* annotation type <i>AT</i>. If <i>AT</i> is a repeatable annotation
|
||||
* type, the type of the containing annotation is <i>ATC</i>.
|
||||
*
|
||||
* <p>Annotation <i>A</i> is <em>directly present</em> on a construct
|
||||
* <i>C</i> if either:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><i>A</i> is explicitly or implicitly declared as applying to
|
||||
* the source code representation of <i>C</i>.
|
||||
*
|
||||
* <p>Typically, if exactly one annotation of type <i>AT</i> appears in
|
||||
* the source code of representation of <i>C</i>, then <i>A</i> is
|
||||
* explicitly declared as applying to <i>C</i>.
|
||||
*
|
||||
* If there are multiple annotations of type <i>AT</i> present on
|
||||
* <i>C</i>, then if <i>AT</i> is repeatable annotation type, an
|
||||
* annotation of type <i>ATC</i> is implicitly declared on <i>C</i>.
|
||||
*
|
||||
* <li> A representation of <i>A</i> appears in the executable output
|
||||
* for <i>C</i>, such as the {@code RuntimeVisibleAnnotations} or
|
||||
* {@code RuntimeVisibleParameterAnnotations} attributes of a class
|
||||
* file.
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* <p>An annotation <i>A</i> is <em>present</em> on a
|
||||
* construct <i>C</i> if either:
|
||||
* <ul>
|
||||
*
|
||||
* <li><i>A</i> is directly present on <i>C</i>.
|
||||
*
|
||||
* <li>No annotation of type <i>AT</i> is directly present on
|
||||
* <i>C</i>, and <i>C</i> is a class and <i>AT</i> is inheritable
|
||||
* and <i>A</i> is present on the superclass of <i>C</i>.
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* An annotation <i>A</i> is <em>indirectly present</em> on a construct
|
||||
* <i>C</i> if both:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><i>AT</i> is a repeatable annotation type with a containing
|
||||
* annotation type <i>ATC</i>.
|
||||
*
|
||||
* <li>An annotation of type <i>ATC</i> is directly present on
|
||||
* <i>C</i> and <i>A</i> is an annotation included in the result of
|
||||
* calling the {@code value} method of the directly present annotation
|
||||
* of type <i>ATC</i>.
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* An annotation <i>A</i> is <em>associated</em> with a construct
|
||||
* <i>C</i> if either:
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li> <i>A</i> is directly or indirectly present on <i>C</i>.
|
||||
*
|
||||
* <li> No annotation of type <i>AT</i> is directly or indirectly
|
||||
* present on <i>C</i>, and <i>C</i> is a class, and <i>AT</i> is
|
||||
* inheritable, and <i>A</i> is associated with the superclass of
|
||||
* <i>C</i>.
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* @since 1.8
|
||||
* @jls 9.6 Annotation Types
|
||||
* @jls 9.6.3.3 @Inherited
|
||||
*/
|
||||
public interface AnnotatedConstruct {
|
||||
/**
|
||||
* Returns the annotations that are <em>directly present</em> on
|
||||
* this construct.
|
||||
*
|
||||
* @return the annotations <em>directly present</em> on this
|
||||
* construct; an empty list if there are none
|
||||
*/
|
||||
List<? extends AnnotationMirror> getAnnotationMirrors();
|
||||
|
||||
/**
|
||||
* Returns this construct's annotation of the specified type if
|
||||
* such an annotation is <em>present</em>, else {@code null}.
|
||||
*
|
||||
* <p> The annotation returned by this method could contain an element
|
||||
* whose value is of type {@code Class}.
|
||||
* This value cannot be returned directly: information necessary to
|
||||
* locate and load a class (such as the class loader to use) is
|
||||
* not available, and the class might not be loadable at all.
|
||||
* Attempting to read a {@code Class} object by invoking the relevant
|
||||
* method on the returned annotation
|
||||
* will result in a {@link MirroredTypeException},
|
||||
* from which the corresponding {@link TypeMirror} may be extracted.
|
||||
* Similarly, attempting to read a {@code Class[]}-valued element
|
||||
* will result in a {@link MirroredTypesException}.
|
||||
*
|
||||
* <blockquote>
|
||||
* <i>Note:</i> This method is unlike others in this and related
|
||||
* interfaces. It operates on runtime reflective information —
|
||||
* representations of annotation types currently loaded into the
|
||||
* VM — rather than on the representations defined by and used
|
||||
* throughout these interfaces. Consequently, calling methods on
|
||||
* the returned annotation object can throw many of the exceptions
|
||||
* that can be thrown when calling methods on an annotation object
|
||||
* returned by core reflection. This method is intended for
|
||||
* callers that are written to operate on a known, fixed set of
|
||||
* annotation types.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param <A> the annotation type
|
||||
* @param annotationType the {@code Class} object corresponding to
|
||||
* the annotation type
|
||||
* @return this construct's annotation for the specified
|
||||
* annotation type if present, else {@code null}
|
||||
*
|
||||
* @see #getAnnotationMirrors()
|
||||
* @see java.lang.reflect.AnnotatedElement#getAnnotation
|
||||
* @see EnumConstantNotPresentException
|
||||
* @see AnnotationTypeMismatchException
|
||||
* @see IncompleteAnnotationException
|
||||
* @see MirroredTypeException
|
||||
* @see MirroredTypesException
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
<A extends Annotation> A getAnnotation(Class<A> annotationType);
|
||||
|
||||
/**
|
||||
* Returns annotations that are <em>associated</em> with this construct.
|
||||
*
|
||||
* If there are no annotations associated with this construct, the
|
||||
* return value is an array of length 0.
|
||||
*
|
||||
* The order of annotations which are directly or indirectly
|
||||
* present on a construct <i>C</i> is computed as if indirectly present
|
||||
* annotations on <i>C</i> are directly present on <i>C</i> in place of their
|
||||
* container annotation, in the order in which they appear in the
|
||||
* value element of the container annotation.
|
||||
*
|
||||
* The difference between this method and {@link #getAnnotation(Class)}
|
||||
* is that this method detects if its argument is a <em>repeatable
|
||||
* annotation type</em>, and if so, attempts to find one or more
|
||||
* annotations of that type by "looking through" a container annotation.
|
||||
*
|
||||
* <p> The annotations returned by this method could contain an element
|
||||
* whose value is of type {@code Class}.
|
||||
* This value cannot be returned directly: information necessary to
|
||||
* locate and load a class (such as the class loader to use) is
|
||||
* not available, and the class might not be loadable at all.
|
||||
* Attempting to read a {@code Class} object by invoking the relevant
|
||||
* method on the returned annotation
|
||||
* will result in a {@link MirroredTypeException},
|
||||
* from which the corresponding {@link TypeMirror} may be extracted.
|
||||
* Similarly, attempting to read a {@code Class[]}-valued element
|
||||
* will result in a {@link MirroredTypesException}.
|
||||
*
|
||||
* <blockquote>
|
||||
* <i>Note:</i> This method is unlike others in this and related
|
||||
* interfaces. It operates on runtime reflective information —
|
||||
* representations of annotation types currently loaded into the
|
||||
* VM — rather than on the representations defined by and used
|
||||
* throughout these interfaces. Consequently, calling methods on
|
||||
* the returned annotation object can throw many of the exceptions
|
||||
* that can be thrown when calling methods on an annotation object
|
||||
* returned by core reflection. This method is intended for
|
||||
* callers that are written to operate on a known, fixed set of
|
||||
* annotation types.
|
||||
* </blockquote>
|
||||
*
|
||||
* @param <A> the annotation type
|
||||
* @param annotationType the {@code Class} object corresponding to
|
||||
* the annotation type
|
||||
* @return this construct's annotations for the specified annotation
|
||||
* type if present on this construct, else an empty array
|
||||
*
|
||||
* @see #getAnnotationMirrors()
|
||||
* @see #getAnnotation(Class)
|
||||
* @see java.lang.reflect.AnnotatedElement#getAnnotationsByType(Class)
|
||||
* @see EnumConstantNotPresentException
|
||||
* @see AnnotationTypeMismatchException
|
||||
* @see IncompleteAnnotationException
|
||||
* @see MirroredTypeException
|
||||
* @see MirroredTypesException
|
||||
* @jls 9.6 Annotation Types
|
||||
* @jls 9.6.1 Annotation Type Elements
|
||||
*/
|
||||
<A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
|
||||
}
|
||||
275
jdkSrc/jdk8/javax/lang/model/SourceVersion.java
Normal file
275
jdkSrc/jdk8/javax/lang/model/SourceVersion.java
Normal file
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Source versions of the Java™ programming language.
|
||||
*
|
||||
* See the appropriate edition of
|
||||
* <cite>The Java™ Language Specification</cite>
|
||||
* for information about a particular source version.
|
||||
*
|
||||
* <p>Note that additional source version constants will be added to
|
||||
* model future releases of the language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public enum SourceVersion {
|
||||
/*
|
||||
* Summary of language evolution
|
||||
* 1.1: nested classes
|
||||
* 1.2: strictfp
|
||||
* 1.3: no changes
|
||||
* 1.4: assert
|
||||
* 1.5: annotations, generics, autoboxing, var-args...
|
||||
* 1.6: no changes
|
||||
* 1.7: diamond syntax, try-with-resources, etc.
|
||||
* 1.8: lambda expressions and default methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* The original version.
|
||||
*
|
||||
* The language described in
|
||||
* <cite>The Java™ Language Specification, First Edition</cite>.
|
||||
*/
|
||||
RELEASE_0,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java Platform 1.1.
|
||||
*
|
||||
* The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
|
||||
* <cite>The Java™ Language Specification, First Edition</cite>.
|
||||
*/
|
||||
RELEASE_1,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java 2 Platform, Standard Edition,
|
||||
* v 1.2.
|
||||
*
|
||||
* The language described in
|
||||
* <cite>The Java™ Language Specification,
|
||||
* Second Edition</cite>, which includes the {@code
|
||||
* strictfp} modifier.
|
||||
*/
|
||||
RELEASE_2,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java 2 Platform, Standard Edition,
|
||||
* v 1.3.
|
||||
*
|
||||
* No major changes from {@code RELEASE_2}.
|
||||
*/
|
||||
RELEASE_3,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java 2 Platform, Standard Edition,
|
||||
* v 1.4.
|
||||
*
|
||||
* Added a simple assertion facility.
|
||||
*/
|
||||
RELEASE_4,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java 2 Platform, Standard
|
||||
* Edition 5.0.
|
||||
*
|
||||
* The language described in
|
||||
* <cite>The Java™ Language Specification,
|
||||
* Third Edition</cite>. First release to support
|
||||
* generics, annotations, autoboxing, var-args, enhanced {@code
|
||||
* for} loop, and hexadecimal floating-point literals.
|
||||
*/
|
||||
RELEASE_5,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java Platform, Standard Edition
|
||||
* 6.
|
||||
*
|
||||
* No major changes from {@code RELEASE_5}.
|
||||
*/
|
||||
RELEASE_6,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java Platform, Standard Edition
|
||||
* 7.
|
||||
*
|
||||
* Additions in this release include, diamond syntax for
|
||||
* constructors, {@code try}-with-resources, strings in switch,
|
||||
* binary literals, and multi-catch.
|
||||
* @since 1.7
|
||||
*/
|
||||
RELEASE_7,
|
||||
|
||||
/**
|
||||
* The version recognized by the Java Platform, Standard Edition
|
||||
* 8.
|
||||
*
|
||||
* Additions in this release include lambda expressions and default methods.
|
||||
* @since 1.8
|
||||
*/
|
||||
RELEASE_8;
|
||||
|
||||
// Note that when adding constants for newer releases, the
|
||||
// behavior of latest() and latestSupported() must be updated too.
|
||||
|
||||
/**
|
||||
* Returns the latest source version that can be modeled.
|
||||
*
|
||||
* @return the latest source version that can be modeled
|
||||
*/
|
||||
public static SourceVersion latest() {
|
||||
return RELEASE_8;
|
||||
}
|
||||
|
||||
private static final SourceVersion latestSupported = getLatestSupported();
|
||||
|
||||
private static SourceVersion getLatestSupported() {
|
||||
try {
|
||||
String specVersion = System.getProperty("java.specification.version");
|
||||
|
||||
if ("1.8".equals(specVersion))
|
||||
return RELEASE_8;
|
||||
else if("1.7".equals(specVersion))
|
||||
return RELEASE_7;
|
||||
else if("1.6".equals(specVersion))
|
||||
return RELEASE_6;
|
||||
} catch (SecurityException se) {}
|
||||
|
||||
return RELEASE_5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest source version fully supported by the
|
||||
* current execution environment. {@code RELEASE_5} or later must
|
||||
* be returned.
|
||||
*
|
||||
* @return the latest source version that is fully supported
|
||||
*/
|
||||
public static SourceVersion latestSupported() {
|
||||
return latestSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not {@code name} is a syntactically valid
|
||||
* identifier (simple name) or keyword in the latest source
|
||||
* version. The method returns {@code true} if the name consists
|
||||
* of an initial character for which {@link
|
||||
* Character#isJavaIdentifierStart(int)} returns {@code true},
|
||||
* followed only by characters for which {@link
|
||||
* Character#isJavaIdentifierPart(int)} returns {@code true}.
|
||||
* This pattern matches regular identifiers, keywords, and the
|
||||
* literals {@code "true"}, {@code "false"}, and {@code "null"}.
|
||||
* The method returns {@code false} for all other strings.
|
||||
*
|
||||
* @param name the string to check
|
||||
* @return {@code true} if this string is a
|
||||
* syntactically valid identifier or keyword, {@code false}
|
||||
* otherwise.
|
||||
*/
|
||||
public static boolean isIdentifier(CharSequence name) {
|
||||
String id = name.toString();
|
||||
|
||||
if (id.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
int cp = id.codePointAt(0);
|
||||
if (!Character.isJavaIdentifierStart(cp)) {
|
||||
return false;
|
||||
}
|
||||
for (int i = Character.charCount(cp);
|
||||
i < id.length();
|
||||
i += Character.charCount(cp)) {
|
||||
cp = id.codePointAt(i);
|
||||
if (!Character.isJavaIdentifierPart(cp)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not {@code name} is a syntactically valid
|
||||
* qualified name in the latest source version. Unlike {@link
|
||||
* #isIdentifier isIdentifier}, this method returns {@code false}
|
||||
* for keywords and literals.
|
||||
*
|
||||
* @param name the string to check
|
||||
* @return {@code true} if this string is a
|
||||
* syntactically valid name, {@code false} otherwise.
|
||||
* @jls 6.2 Names and Identifiers
|
||||
*/
|
||||
public static boolean isName(CharSequence name) {
|
||||
String id = name.toString();
|
||||
|
||||
for(String s : id.split("\\.", -1)) {
|
||||
if (!isIdentifier(s) || isKeyword(s))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private final static Set<String> keywords;
|
||||
static {
|
||||
Set<String> s = new HashSet<String>();
|
||||
String [] kws = {
|
||||
"abstract", "continue", "for", "new", "switch",
|
||||
"assert", "default", "if", "package", "synchronized",
|
||||
"boolean", "do", "goto", "private", "this",
|
||||
"break", "double", "implements", "protected", "throw",
|
||||
"byte", "else", "import", "public", "throws",
|
||||
"case", "enum", "instanceof", "return", "transient",
|
||||
"catch", "extends", "int", "short", "try",
|
||||
"char", "final", "interface", "static", "void",
|
||||
"class", "finally", "long", "strictfp", "volatile",
|
||||
"const", "float", "native", "super", "while",
|
||||
// literals
|
||||
"null", "true", "false"
|
||||
};
|
||||
for(String kw : kws)
|
||||
s.add(kw);
|
||||
keywords = Collections.unmodifiableSet(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not {@code s} is a keyword or literal in the
|
||||
* latest source version.
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return {@code true} if {@code s} is a keyword or literal, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isKeyword(CharSequence s) {
|
||||
String keywordOrLiteral = s.toString();
|
||||
return keywords.contains(keywordOrLiteral);
|
||||
}
|
||||
}
|
||||
57
jdkSrc/jdk8/javax/lang/model/UnknownEntityException.java
Normal file
57
jdkSrc/jdk8/javax/lang/model/UnknownEntityException.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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;
|
||||
|
||||
/**
|
||||
* Superclass of exceptions which indicate that an unknown kind of
|
||||
* entity was encountered. This situation can occur if the language
|
||||
* evolves and new kinds of constructs are introduced. Subclasses of
|
||||
* this exception may be thrown by visitors to indicate that the
|
||||
* visitor was created for a prior version of the language.
|
||||
*
|
||||
* <p>A common superclass for those exceptions allows a single catch
|
||||
* block to have code handling them uniformly.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @see javax.lang.model.element.UnknownElementException
|
||||
* @see javax.lang.model.element.UnknownAnnotationValueException
|
||||
* @see javax.lang.model.type.UnknownTypeException
|
||||
* @since 1.7
|
||||
*/
|
||||
public class UnknownEntityException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 269L;
|
||||
|
||||
/**
|
||||
* Creates a new {@code UnknownEntityException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
protected UnknownEntityException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
74
jdkSrc/jdk8/javax/lang/model/element/AnnotationMirror.java
Normal file
74
jdkSrc/jdk8/javax/lang/model/element/AnnotationMirror.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.element;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
|
||||
/**
|
||||
* Represents an annotation. An annotation associates a value with
|
||||
* each element of an annotation type.
|
||||
*
|
||||
* <p> Annotations should be compared using the {@code equals}
|
||||
* method. There is no guarantee that any particular annotation will
|
||||
* always be represented by the same object.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface AnnotationMirror {
|
||||
|
||||
/**
|
||||
* Returns the type of this annotation.
|
||||
*
|
||||
* @return the type of this annotation
|
||||
*/
|
||||
DeclaredType getAnnotationType();
|
||||
|
||||
/**
|
||||
* Returns the values of this annotation's elements.
|
||||
* This is returned in the form of a map that associates elements
|
||||
* with their corresponding values.
|
||||
* Only those elements with values explicitly present in the
|
||||
* annotation are included, not those that are implicitly assuming
|
||||
* their default values.
|
||||
* The order of the map matches the order in which the
|
||||
* values appear in the annotation's source.
|
||||
*
|
||||
* <p>Note that an annotation mirror of a marker annotation type
|
||||
* will by definition have an empty map.
|
||||
*
|
||||
* <p>To fill in default values, use {@link
|
||||
* javax.lang.model.util.Elements#getElementValuesWithDefaults
|
||||
* getElementValuesWithDefaults}.
|
||||
*
|
||||
* @return the values of this annotation's elements,
|
||||
* or an empty map if there are none
|
||||
*/
|
||||
Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues();
|
||||
}
|
||||
73
jdkSrc/jdk8/javax/lang/model/element/AnnotationValue.java
Normal file
73
jdkSrc/jdk8/javax/lang/model/element/AnnotationValue.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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.element;
|
||||
|
||||
/**
|
||||
* Represents a value of an annotation type element.
|
||||
* A value is of one of the following types:
|
||||
* <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
|
||||
* <li> {@code String}
|
||||
* <li> {@code TypeMirror}
|
||||
* <li> {@code VariableElement} (representing an enum constant)
|
||||
* <li> {@code AnnotationMirror}
|
||||
* <li> {@code List<? extends AnnotationValue>}
|
||||
* (representing the elements, in declared order, if the value is an array)
|
||||
* </ul>
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface AnnotationValue {
|
||||
|
||||
/**
|
||||
* Returns the value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
Object getValue();
|
||||
|
||||
/**
|
||||
* Returns a string representation of this value.
|
||||
* This is returned in a form suitable for representing this value
|
||||
* in the source code of an annotation.
|
||||
*
|
||||
* @return a string representation of this value
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Applies a visitor to this value.
|
||||
*
|
||||
* @param <R> the return type of the visitor's methods
|
||||
* @param <P> the type of the additional parameter to the visitor's methods
|
||||
* @param v the visitor operating on this value
|
||||
* @param p additional parameter to the visitor
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
<R, P> R accept(AnnotationValueVisitor<R, P> v, P p);
|
||||
}
|
||||
214
jdkSrc/jdk8/javax/lang/model/element/AnnotationValueVisitor.java
Normal file
214
jdkSrc/jdk8/javax/lang/model/element/AnnotationValueVisitor.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
|
||||
/**
|
||||
* A visitor of the values of annotation type elements, using a
|
||||
* variant of the visitor design pattern. Unlike a standard visitor
|
||||
* which dispatches based on the concrete type of a member of a type
|
||||
* hierarchy, this visitor dispatches based on the type of data
|
||||
* stored; there are no distinct subclasses for storing, for example,
|
||||
* {@code boolean} values versus {@code int} values. Classes
|
||||
* implementing this interface are used to operate on a value when the
|
||||
* type of that value is unknown at compile time. When a visitor is
|
||||
* passed to a value's {@link AnnotationValue#accept accept} method,
|
||||
* the <tt>visit<i>XYZ</i></tt> method applicable to that value is
|
||||
* invoked.
|
||||
*
|
||||
* <p> Classes implementing this interface may or may not throw a
|
||||
* {@code NullPointerException} if the additional parameter {@code p}
|
||||
* is {@code null}; see documentation of the implementing class for
|
||||
* details.
|
||||
*
|
||||
* <p> <b>WARNING:</b> It is possible that methods will be added to
|
||||
* this interface to accommodate new, currently unknown, language
|
||||
* structures added to future versions of the Java™ programming
|
||||
* language. Therefore, visitor classes directly implementing this
|
||||
* interface may be source incompatible with future versions of the
|
||||
* platform. To avoid this source incompatibility, visitor
|
||||
* implementations are encouraged to instead extend the appropriate
|
||||
* abstract visitor class that implements this interface. However, an
|
||||
* API should generally use this visitor interface as the type for
|
||||
* parameters, return type, etc. rather than one of the abstract
|
||||
* classes.
|
||||
*
|
||||
* <p>Note that methods to accommodate new language constructs could
|
||||
* be added in a source <em>compatible</em> way if they were added as
|
||||
* <em>default methods</em>. However, default methods are only
|
||||
* available on Java SE 8 and higher releases and the {@code
|
||||
* javax.lang.model.*} packages bundled in Java SE 8 are required to
|
||||
* also be runnable on Java SE 7. Therefore, default methods
|
||||
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
|
||||
* to cover Java SE 8 language features. However, default methods may
|
||||
* be used in subsequent revisions of the {@code javax.lang.model.*}
|
||||
* packages that are only required to run on Java SE 8 and higher
|
||||
* platform versions.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface AnnotationValueVisitor<R, P> {
|
||||
/**
|
||||
* Visits an annotation value.
|
||||
* @param av the value to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(AnnotationValue av, P p);
|
||||
|
||||
/**
|
||||
* A convenience method equivalent to {@code v.visit(av, null)}.
|
||||
* @param av the value to visit
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(AnnotationValue av);
|
||||
|
||||
/**
|
||||
* Visits a {@code boolean} value in an annotation.
|
||||
* @param b the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitBoolean(boolean b, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code byte} value in an annotation.
|
||||
* @param b the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitByte(byte b, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code char} value in an annotation.
|
||||
* @param c the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitChar(char c, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code double} value in an annotation.
|
||||
* @param d the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitDouble(double d, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code float} value in an annotation.
|
||||
* @param f the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitFloat(float f, P p);
|
||||
|
||||
/**
|
||||
* Visits an {@code int} value in an annotation.
|
||||
* @param i the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitInt(int i, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code long} value in an annotation.
|
||||
* @param i the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitLong(long i, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@code short} value in an annotation.
|
||||
* @param s the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitShort(short s, P p);
|
||||
|
||||
/**
|
||||
* Visits a string value in an annotation.
|
||||
* @param s the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitString(String s, P p);
|
||||
|
||||
/**
|
||||
* Visits a type value in an annotation.
|
||||
* @param t the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitType(TypeMirror t, P p);
|
||||
|
||||
/**
|
||||
* Visits an {@code enum} value in an annotation.
|
||||
* @param c the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitEnumConstant(VariableElement c, P p);
|
||||
|
||||
/**
|
||||
* Visits an annotation value in an annotation.
|
||||
* @param a the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitAnnotation(AnnotationMirror a, P p);
|
||||
|
||||
/**
|
||||
* Visits an array value in an annotation.
|
||||
* @param vals the value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
*/
|
||||
R visitArray(List<? extends AnnotationValue> vals, P p);
|
||||
|
||||
/**
|
||||
* Visits an unknown kind of annotation value.
|
||||
* This can occur if the language evolves and new kinds
|
||||
* of value can be stored in an annotation.
|
||||
* @param av the unknown value being visited
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of the visit
|
||||
* @throws UnknownAnnotationValueException
|
||||
* a visitor implementation may optionally throw this exception
|
||||
*/
|
||||
R visitUnknown(AnnotationValue av, P p);
|
||||
}
|
||||
246
jdkSrc/jdk8/javax/lang/model/element/Element.java
Normal file
246
jdkSrc/jdk8/javax/lang/model/element/Element.java
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.AnnotationTypeMismatchException;
|
||||
import java.lang.annotation.IncompleteAnnotationException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a program element such as a package, class, or method.
|
||||
* Each element represents a static, language-level construct
|
||||
* (and not, for example, a runtime construct of the virtual machine).
|
||||
*
|
||||
* <p> Elements should be compared using the {@link #equals(Object)}
|
||||
* method. There is no guarantee that any particular element will
|
||||
* always be represented by the same object.
|
||||
*
|
||||
* <p> To implement operations based on the class of an {@code
|
||||
* Element} object, either use a {@linkplain ElementVisitor visitor} or
|
||||
* use the result of the {@link #getKind} method. Using {@code
|
||||
* instanceof} is <em>not</em> necessarily a reliable idiom for
|
||||
* determining the effective class of an object in this modeling
|
||||
* hierarchy since an implementation may choose to have a single object
|
||||
* implement multiple {@code Element} subinterfaces.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see Elements
|
||||
* @see TypeMirror
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Element extends javax.lang.model.AnnotatedConstruct {
|
||||
/**
|
||||
* Returns the type defined by this element.
|
||||
*
|
||||
* <p> A generic element defines a family of types, not just one.
|
||||
* If this is a generic element, a <i>prototypical</i> type is
|
||||
* returned. This is the element's invocation on the
|
||||
* type variables corresponding to its own formal type parameters.
|
||||
* For example,
|
||||
* for the generic class element {@code C<N extends Number>},
|
||||
* the parameterized type {@code C<N>} is returned.
|
||||
* The {@link Types} utility interface has more general methods
|
||||
* for obtaining the full range of types defined by an element.
|
||||
*
|
||||
* @see Types
|
||||
*
|
||||
* @return the type defined by this element
|
||||
*/
|
||||
TypeMirror asType();
|
||||
|
||||
/**
|
||||
* Returns the {@code kind} of this element.
|
||||
*
|
||||
* @return the kind of this element
|
||||
*/
|
||||
ElementKind getKind();
|
||||
|
||||
/**
|
||||
* Returns the modifiers of this element, excluding annotations.
|
||||
* Implicit modifiers, such as the {@code public} and {@code static}
|
||||
* modifiers of interface members, are included.
|
||||
*
|
||||
* @return the modifiers of this element, or an empty set if there are none
|
||||
*/
|
||||
Set<Modifier> getModifiers();
|
||||
|
||||
/**
|
||||
* Returns the simple (unqualified) name of this element. The
|
||||
* name of a generic type does not include any reference to its
|
||||
* formal type parameters.
|
||||
*
|
||||
* For example, the simple name of the type element {@code
|
||||
* java.util.Set<E>} is {@code "Set"}.
|
||||
*
|
||||
* If this element represents an unnamed {@linkplain
|
||||
* PackageElement#getSimpleName package}, an empty name is
|
||||
* returned.
|
||||
*
|
||||
* If it represents a {@linkplain ExecutableElement#getSimpleName
|
||||
* constructor}, the name "{@code <init>}" is returned. If it
|
||||
* represents a {@linkplain ExecutableElement#getSimpleName static
|
||||
* initializer}, the name "{@code <clinit>}" is returned.
|
||||
*
|
||||
* If it represents an {@linkplain TypeElement#getSimpleName
|
||||
* anonymous class} or {@linkplain ExecutableElement#getSimpleName
|
||||
* instance initializer}, an empty name is returned.
|
||||
*
|
||||
* @return the simple name of this element
|
||||
* @see PackageElement#getSimpleName
|
||||
* @see ExecutableElement#getSimpleName
|
||||
* @see TypeElement#getSimpleName
|
||||
* @see VariableElement#getSimpleName
|
||||
*/
|
||||
Name getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the innermost element
|
||||
* within which this element is, loosely speaking, enclosed.
|
||||
* <ul>
|
||||
* <li> If this element is one whose declaration is lexically enclosed
|
||||
* immediately within the declaration of another element, that other
|
||||
* element is returned.
|
||||
*
|
||||
* <li> If this is a {@linkplain TypeElement#getEnclosingElement
|
||||
* top-level type}, its package is returned.
|
||||
*
|
||||
* <li> If this is a {@linkplain
|
||||
* PackageElement#getEnclosingElement package}, {@code null} is
|
||||
* returned.
|
||||
*
|
||||
* <li> If this is a {@linkplain
|
||||
* TypeParameterElement#getEnclosingElement type parameter},
|
||||
* {@linkplain TypeParameterElement#getGenericElement the
|
||||
* generic element} of the type parameter is returned.
|
||||
*
|
||||
* <li> If this is a {@linkplain
|
||||
* VariableElement#getEnclosingElement method or constructor
|
||||
* parameter}, {@linkplain ExecutableElement the executable
|
||||
* element} which declares the parameter is returned.
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* @return the enclosing element, or {@code null} if there is none
|
||||
* @see Elements#getPackageOf
|
||||
*/
|
||||
Element getEnclosingElement();
|
||||
|
||||
/**
|
||||
* Returns the elements that are, loosely speaking, directly
|
||||
* enclosed by this element.
|
||||
*
|
||||
* A {@linkplain TypeElement#getEnclosedElements class or
|
||||
* interface} is considered to enclose the fields, methods,
|
||||
* constructors, and member types that it directly declares.
|
||||
*
|
||||
* A {@linkplain PackageElement#getEnclosedElements package}
|
||||
* encloses the top-level classes and interfaces within it, but is
|
||||
* not considered to enclose subpackages.
|
||||
*
|
||||
* Other kinds of elements are not currently considered to enclose
|
||||
* any elements; however, that may change as this API or the
|
||||
* programming language evolves.
|
||||
*
|
||||
* <p>Note that elements of certain kinds can be isolated using
|
||||
* methods in {@link ElementFilter}.
|
||||
*
|
||||
* @return the enclosed elements, or an empty list if none
|
||||
* @see PackageElement#getEnclosedElements
|
||||
* @see TypeElement#getEnclosedElements
|
||||
* @see Elements#getAllMembers
|
||||
* @jls 8.8.9 Default Constructor
|
||||
* @jls 8.9 Enums
|
||||
*/
|
||||
List<? extends Element> getEnclosedElements();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument represents the same
|
||||
* element as {@code this}, or {@code false} otherwise.
|
||||
*
|
||||
* <p>Note that the identity of an element involves implicit state
|
||||
* not directly accessible from the element's methods, including
|
||||
* state about the presence of unrelated types. Element objects
|
||||
* created by different implementations of these interfaces should
|
||||
* <i>not</i> be expected to be equal even if "the same"
|
||||
* element is being modeled; this is analogous to the inequality
|
||||
* of {@code Class} objects for the same class file loaded through
|
||||
* different class loaders.
|
||||
*
|
||||
* @param obj the object to be compared with this element
|
||||
* @return {@code true} if the specified object represents the same
|
||||
* element as this
|
||||
*/
|
||||
@Override
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
|
||||
*
|
||||
* @see #equals
|
||||
*/
|
||||
@Override
|
||||
int hashCode();
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p> To get inherited annotations as well, use {@link
|
||||
* Elements#getAllAnnotationMirrors(Element)
|
||||
* getAllAnnotationMirrors}.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
List<? extends AnnotationMirror> getAnnotationMirrors();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
<A extends Annotation> A getAnnotation(Class<A> annotationType);
|
||||
|
||||
/**
|
||||
* Applies a visitor to this element.
|
||||
*
|
||||
* @param <R> the return type of the visitor's methods
|
||||
* @param <P> the type of the additional parameter to the visitor's methods
|
||||
* @param v the visitor operating on this element
|
||||
* @param p additional parameter to the visitor
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
<R, P> R accept(ElementVisitor<R, P> v, P p);
|
||||
}
|
||||
129
jdkSrc/jdk8/javax/lang/model/element/ElementKind.java
Normal file
129
jdkSrc/jdk8/javax/lang/model/element/ElementKind.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, 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.element;
|
||||
|
||||
/**
|
||||
* The {@code kind} of an element.
|
||||
*
|
||||
* <p>Note that it is possible additional element kinds will be added
|
||||
* to accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see Element
|
||||
* @since 1.6
|
||||
*/
|
||||
public enum ElementKind {
|
||||
|
||||
/** A package. */
|
||||
PACKAGE,
|
||||
|
||||
// Declared types
|
||||
/** An enum type. */
|
||||
ENUM,
|
||||
/** A class not described by a more specific kind (like {@code ENUM}). */
|
||||
CLASS,
|
||||
/** An annotation type. */
|
||||
ANNOTATION_TYPE,
|
||||
/**
|
||||
* An interface not described by a more specific kind (like
|
||||
* {@code ANNOTATION_TYPE}).
|
||||
*/
|
||||
INTERFACE,
|
||||
|
||||
// Variables
|
||||
/** An enum constant. */
|
||||
ENUM_CONSTANT,
|
||||
/**
|
||||
* A field not described by a more specific kind (like
|
||||
* {@code ENUM_CONSTANT}).
|
||||
*/
|
||||
FIELD,
|
||||
/** A parameter of a method or constructor. */
|
||||
PARAMETER,
|
||||
/** A local variable. */
|
||||
LOCAL_VARIABLE,
|
||||
/** A parameter of an exception handler. */
|
||||
EXCEPTION_PARAMETER,
|
||||
|
||||
// Executables
|
||||
/** A method. */
|
||||
METHOD,
|
||||
/** A constructor. */
|
||||
CONSTRUCTOR,
|
||||
/** A static initializer. */
|
||||
STATIC_INIT,
|
||||
/** An instance initializer. */
|
||||
INSTANCE_INIT,
|
||||
|
||||
/** A type parameter. */
|
||||
TYPE_PARAMETER,
|
||||
|
||||
/**
|
||||
* An implementation-reserved element. This is not the element
|
||||
* you are looking for.
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* A resource variable.
|
||||
* @since 1.7
|
||||
*/
|
||||
RESOURCE_VARIABLE;
|
||||
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this is a kind of class:
|
||||
* either {@code CLASS} or {@code ENUM}.
|
||||
*
|
||||
* @return {@code true} if this is a kind of class
|
||||
*/
|
||||
public boolean isClass() {
|
||||
return this == CLASS || this == ENUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this is a kind of interface:
|
||||
* either {@code INTERFACE} or {@code ANNOTATION_TYPE}.
|
||||
*
|
||||
* @return {@code true} if this is a kind of interface
|
||||
*/
|
||||
public boolean isInterface() {
|
||||
return this == INTERFACE || this == ANNOTATION_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this is a kind of field:
|
||||
* either {@code FIELD} or {@code ENUM_CONSTANT}.
|
||||
*
|
||||
* @return {@code true} if this is a kind of field
|
||||
*/
|
||||
public boolean isField() {
|
||||
return this == FIELD || this == ENUM_CONSTANT;
|
||||
}
|
||||
}
|
||||
148
jdkSrc/jdk8/javax/lang/model/element/ElementVisitor.java
Normal file
148
jdkSrc/jdk8/javax/lang/model/element/ElementVisitor.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
import javax.lang.model.util.*;
|
||||
|
||||
/**
|
||||
* A visitor of program elements, in the style of the visitor design
|
||||
* pattern. Classes implementing this interface are used to operate
|
||||
* on an element when the kind of element is unknown at compile time.
|
||||
* When a visitor is passed to an element's {@link Element#accept
|
||||
* accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
|
||||
* to that element is invoked.
|
||||
*
|
||||
* <p> Classes implementing this interface may or may not throw a
|
||||
* {@code NullPointerException} if the additional parameter {@code p}
|
||||
* is {@code null}; see documentation of the implementing class for
|
||||
* details.
|
||||
*
|
||||
* <p> <b>WARNING:</b> It is possible that methods will be added to
|
||||
* this interface to accommodate new, currently unknown, language
|
||||
* structures added to future versions of the Java™ programming
|
||||
* language. Therefore, visitor classes directly implementing this
|
||||
* interface may be source incompatible with future versions of the
|
||||
* platform. To avoid this source incompatibility, visitor
|
||||
* implementations are encouraged to instead extend the appropriate
|
||||
* abstract visitor class that implements this interface. However, an
|
||||
* API should generally use this visitor interface as the type for
|
||||
* parameters, return type, etc. rather than one of the abstract
|
||||
* classes.
|
||||
*
|
||||
* <p>Note that methods to accommodate new language constructs could
|
||||
* be added in a source <em>compatible</em> way if they were added as
|
||||
* <em>default methods</em>. However, default methods are only
|
||||
* available on Java SE 8 and higher releases and the {@code
|
||||
* javax.lang.model.*} packages bundled in Java SE 8 are required to
|
||||
* also be runnable on Java SE 7. Therefore, default methods
|
||||
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
|
||||
* to cover Java SE 8 language features. However, default methods may
|
||||
* be used in subsequent revisions of the {@code javax.lang.model.*}
|
||||
* packages that are only required to run on Java SE 8 and higher
|
||||
* platform versions.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see AbstractElementVisitor6
|
||||
* @see AbstractElementVisitor7
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ElementVisitor<R, P> {
|
||||
/**
|
||||
* Visits an element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(Element e, P p);
|
||||
|
||||
/**
|
||||
* A convenience method equivalent to {@code v.visit(e, null)}.
|
||||
* @param e the element to visit
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(Element e);
|
||||
|
||||
/**
|
||||
* Visits a package element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitPackage(PackageElement e, P p);
|
||||
|
||||
/**
|
||||
* Visits a type element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitType(TypeElement e, P p);
|
||||
|
||||
/**
|
||||
* Visits a variable element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitVariable(VariableElement e, P p);
|
||||
|
||||
/**
|
||||
* Visits an executable element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitExecutable(ExecutableElement e, P p);
|
||||
|
||||
/**
|
||||
* Visits a type parameter element.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitTypeParameter(TypeParameterElement e, P p);
|
||||
|
||||
/**
|
||||
* Visits an unknown kind of element.
|
||||
* This can occur if the language evolves and new kinds
|
||||
* of elements are added to the {@code Element} hierarchy.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
* @throws UnknownElementException
|
||||
* a visitor implementation may optionally throw this exception
|
||||
*/
|
||||
R visitUnknown(Element e, P p);
|
||||
}
|
||||
141
jdkSrc/jdk8/javax/lang/model/element/ExecutableElement.java
Normal file
141
jdkSrc/jdk8/javax/lang/model/element/ExecutableElement.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
import java.util.List;
|
||||
import javax.lang.model.type.*;
|
||||
|
||||
/**
|
||||
* Represents a method, constructor, or initializer (static or
|
||||
* instance) of a class or interface, including annotation type
|
||||
* elements.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see ExecutableType
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ExecutableElement extends Element, Parameterizable {
|
||||
/**
|
||||
* Returns the formal type parameters of this executable
|
||||
* in declaration order.
|
||||
*
|
||||
* @return the formal type parameters, or an empty list
|
||||
* if there are none
|
||||
*/
|
||||
List<? extends TypeParameterElement> getTypeParameters();
|
||||
|
||||
/**
|
||||
* Returns the return type of this executable.
|
||||
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
|
||||
* if this executable is not a method, or is a method that does not
|
||||
* return a value.
|
||||
*
|
||||
* @return the return type of this executable
|
||||
*/
|
||||
TypeMirror getReturnType();
|
||||
|
||||
/**
|
||||
* Returns the formal parameters of this executable.
|
||||
* They are returned in declaration order.
|
||||
*
|
||||
* @return the formal parameters,
|
||||
* or an empty list if there are none
|
||||
*/
|
||||
List<? extends VariableElement> getParameters();
|
||||
|
||||
/**
|
||||
* Returns the receiver type of this executable,
|
||||
* or {@link javax.lang.model.type.NoType NoType} with
|
||||
* kind {@link javax.lang.model.type.TypeKind#NONE NONE}
|
||||
* if the executable has no receiver type.
|
||||
*
|
||||
* An executable which is an instance method, or a constructor of an
|
||||
* inner class, has a receiver type derived from the {@linkplain
|
||||
* #getEnclosingElement declaring type}.
|
||||
*
|
||||
* An executable which is a static method, or a constructor of a
|
||||
* non-inner class, or an initializer (static or instance), has no
|
||||
* receiver type.
|
||||
*
|
||||
* @return the receiver type of this executable
|
||||
* @since 1.8
|
||||
*/
|
||||
TypeMirror getReceiverType();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this method or constructor accepts a variable
|
||||
* number of arguments and returns {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if this method or constructor accepts a variable
|
||||
* number of arguments and {@code false} otherwise
|
||||
*/
|
||||
boolean isVarArgs();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this method is a default method and
|
||||
* returns {@code false} otherwise.
|
||||
*
|
||||
* @return {@code true} if this method is a default method and
|
||||
* {@code false} otherwise
|
||||
* @since 1.8
|
||||
*/
|
||||
boolean isDefault();
|
||||
|
||||
/**
|
||||
* Returns the exceptions and other throwables listed in this
|
||||
* method or constructor's {@code throws} clause in declaration
|
||||
* order.
|
||||
*
|
||||
* @return the exceptions and other throwables listed in the
|
||||
* {@code throws} clause, or an empty list if there are none
|
||||
*/
|
||||
List<? extends TypeMirror> getThrownTypes();
|
||||
|
||||
/**
|
||||
* Returns the default value if this executable is an annotation
|
||||
* type element. Returns {@code null} if this method is not an
|
||||
* annotation type element, or if it is an annotation type element
|
||||
* with no default value.
|
||||
*
|
||||
* @return the default value, or {@code null} if none
|
||||
*/
|
||||
AnnotationValue getDefaultValue();
|
||||
|
||||
/**
|
||||
* Returns the simple name of a constructor, method, or
|
||||
* initializer. For a constructor, the name {@code "<init>"} is
|
||||
* returned, for a static initializer, the name {@code "<clinit>"}
|
||||
* is returned, and for an anonymous class or instance
|
||||
* initializer, an empty name is returned.
|
||||
*
|
||||
* @return the simple name of a constructor, method, or
|
||||
* initializer
|
||||
*/
|
||||
@Override
|
||||
Name getSimpleName();
|
||||
}
|
||||
75
jdkSrc/jdk8/javax/lang/model/element/Modifier.java
Normal file
75
jdkSrc/jdk8/javax/lang/model/element/Modifier.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a modifier on a program element such
|
||||
* as a class, method, or field.
|
||||
*
|
||||
* <p>Not all modifiers are applicable to all kinds of elements.
|
||||
* When two or more modifiers appear in the source code of an element
|
||||
* then it is customary, though not required, that they appear in the same
|
||||
* order as the constants listed in the detail section below.
|
||||
*
|
||||
* <p>Note that it is possible additional modifiers will be added in
|
||||
* future versions of the platform.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
public enum Modifier {
|
||||
|
||||
// See JLS sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
|
||||
// java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
|
||||
|
||||
/** The modifier {@code public} */ PUBLIC,
|
||||
/** The modifier {@code protected} */ PROTECTED,
|
||||
/** The modifier {@code private} */ PRIVATE,
|
||||
/** The modifier {@code abstract} */ ABSTRACT,
|
||||
/**
|
||||
* The modifier {@code default}
|
||||
* @since 1.8
|
||||
*/
|
||||
DEFAULT,
|
||||
/** The modifier {@code static} */ STATIC,
|
||||
/** The modifier {@code final} */ FINAL,
|
||||
/** The modifier {@code transient} */ TRANSIENT,
|
||||
/** The modifier {@code volatile} */ VOLATILE,
|
||||
/** The modifier {@code synchronized} */ SYNCHRONIZED,
|
||||
/** The modifier {@code native} */ NATIVE,
|
||||
/** The modifier {@code strictfp} */ STRICTFP;
|
||||
|
||||
/**
|
||||
* Returns this modifier's name in lowercase.
|
||||
*/
|
||||
public String toString() {
|
||||
return name().toLowerCase(java.util.Locale.US);
|
||||
}
|
||||
}
|
||||
89
jdkSrc/jdk8/javax/lang/model/element/Name.java
Normal file
89
jdkSrc/jdk8/javax/lang/model/element/Name.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 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.element;
|
||||
|
||||
/**
|
||||
* An immutable sequence of characters. When created by the same
|
||||
* implementation, objects implementing this interface must obey the
|
||||
* general {@linkplain Object#equals equals contract} when compared
|
||||
* with each other. Therefore, {@code Name} objects from the same
|
||||
* implementation are usable in collections while {@code Name}s from
|
||||
* different implementations may not work properly in collections.
|
||||
*
|
||||
* <p>An empty {@code Name} has a length of zero.
|
||||
*
|
||||
* <p>In the context of {@linkplain
|
||||
* javax.annotation.processing.ProcessingEnvironment annotation
|
||||
* processing}, the guarantees for "the same" implementation must
|
||||
* include contexts where the {@linkplain javax.annotation.processing
|
||||
* API mediated} side effects of {@linkplain
|
||||
* javax.annotation.processing.Processor processors} could be visible
|
||||
* to each other, including successive annotation processing
|
||||
* {@linkplain javax.annotation.processing.RoundEnvironment rounds}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see javax.lang.model.util.Elements#getName
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Name extends CharSequence {
|
||||
/**
|
||||
* Returns {@code true} if the argument represents the same
|
||||
* name as {@code this}, and {@code false} otherwise.
|
||||
*
|
||||
* <p>Note that the identity of a {@code Name} is a function both
|
||||
* of its content in terms of a sequence of characters as well as
|
||||
* the implementation which created it.
|
||||
*
|
||||
* @param obj the object to be compared with this element
|
||||
* @return {@code true} if the specified object represents the same
|
||||
* name as this
|
||||
* @see Element#equals
|
||||
*/
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
|
||||
*
|
||||
* @see #equals
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
* Compares this name to the specified {@code CharSequence}. The result
|
||||
* is {@code true} if and only if this name represents the same sequence
|
||||
* of {@code char} values as the specified sequence.
|
||||
*
|
||||
* @return {@code true} if this name represents the same sequence
|
||||
* of {@code char} values as the specified sequence, {@code false}
|
||||
* otherwise
|
||||
*
|
||||
* @param cs The sequence to compare this name against
|
||||
* @see String#contentEquals(CharSequence)
|
||||
*/
|
||||
boolean contentEquals(CharSequence cs);
|
||||
}
|
||||
115
jdkSrc/jdk8/javax/lang/model/element/NestingKind.java
Normal file
115
jdkSrc/jdk8/javax/lang/model/element/NestingKind.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
/**
|
||||
* The <i>nesting kind</i> of a type element.
|
||||
* Type elements come in four varieties:
|
||||
* top-level, member, local, and anonymous.
|
||||
* <i>Nesting kind</i> is a non-standard term used here to denote this
|
||||
* classification.
|
||||
*
|
||||
* <p>Note that it is possible additional nesting kinds will be added
|
||||
* in future versions of the platform.
|
||||
*
|
||||
* <p><b>Example:</b> The classes below are annotated with their nesting kind.
|
||||
* <blockquote><pre>
|
||||
*
|
||||
* import java.lang.annotation.*;
|
||||
* import static java.lang.annotation.RetentionPolicy.*;
|
||||
* import javax.lang.model.element.*;
|
||||
* import static javax.lang.model.element.NestingKind.*;
|
||||
*
|
||||
* @Nesting(TOP_LEVEL)
|
||||
* public class NestingExamples {
|
||||
* @Nesting(MEMBER)
|
||||
* static class MemberClass1{}
|
||||
*
|
||||
* @Nesting(MEMBER)
|
||||
* class MemberClass2{}
|
||||
*
|
||||
* public static void main(String... argv) {
|
||||
* @Nesting(LOCAL)
|
||||
* class LocalClass{};
|
||||
*
|
||||
* Class<?>[] classes = {
|
||||
* NestingExamples.class,
|
||||
* MemberClass1.class,
|
||||
* MemberClass2.class,
|
||||
* LocalClass.class
|
||||
* };
|
||||
*
|
||||
* for(Class<?> clazz : classes) {
|
||||
* System.out.format("%s is %s%n",
|
||||
* clazz.getName(),
|
||||
* clazz.getAnnotation(Nesting.class).value());
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @Retention(RUNTIME)
|
||||
* @interface Nesting {
|
||||
* NestingKind value();
|
||||
* }
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public enum NestingKind {
|
||||
/**
|
||||
* A top-level type, not contained within another type.
|
||||
*/
|
||||
TOP_LEVEL,
|
||||
|
||||
/**
|
||||
* A type that is a named member of another type.
|
||||
*/
|
||||
MEMBER,
|
||||
|
||||
/**
|
||||
* A named type declared within a construct other than a type.
|
||||
*/
|
||||
LOCAL,
|
||||
|
||||
/**
|
||||
* A type without a name.
|
||||
*/
|
||||
ANONYMOUS;
|
||||
|
||||
/**
|
||||
* Does this constant correspond to a nested type element?
|
||||
* A <i>nested</i> type element is any that is not top-level.
|
||||
* An <i>inner</i> type element is any nested type element that
|
||||
* is not {@linkplain Modifier#STATIC static}.
|
||||
* @return whether or not the constant is nested
|
||||
*/
|
||||
public boolean isNested() {
|
||||
return this != TOP_LEVEL;
|
||||
}
|
||||
}
|
||||
92
jdkSrc/jdk8/javax/lang/model/element/PackageElement.java
Normal file
92
jdkSrc/jdk8/javax/lang/model/element/PackageElement.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a package program element. Provides access to information
|
||||
* about the package and its members.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see javax.lang.model.util.Elements#getPackageOf
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface PackageElement extends Element, QualifiedNameable {
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of this package.
|
||||
* This is also known as the package's <i>canonical</i> name.
|
||||
*
|
||||
* @return the fully qualified name of this package, or an
|
||||
* empty name if this is an unnamed package
|
||||
* @jls 6.7 Fully Qualified Names and Canonical Names
|
||||
*/
|
||||
Name getQualifiedName();
|
||||
|
||||
/**
|
||||
* Returns the simple name of this package. For an unnamed
|
||||
* package, an empty name is returned.
|
||||
*
|
||||
* @return the simple name of this package or an empty name if
|
||||
* this is an unnamed package
|
||||
*/
|
||||
@Override
|
||||
Name getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain NestingKind#TOP_LEVEL top-level}
|
||||
* classes and interfaces within this package. Note that
|
||||
* subpackages are <em>not</em> considered to be enclosed by a
|
||||
* package.
|
||||
*
|
||||
* @return the top-level classes and interfaces within this
|
||||
* package
|
||||
*/
|
||||
@Override
|
||||
List<? extends Element> getEnclosedElements();
|
||||
|
||||
/**
|
||||
* Returns {@code true} is this is an unnamed package and {@code
|
||||
* false} otherwise.
|
||||
*
|
||||
* @return {@code true} is this is an unnamed package and {@code
|
||||
* false} otherwise
|
||||
* @jls 7.4.2 Unnamed Packages
|
||||
*/
|
||||
boolean isUnnamed();
|
||||
|
||||
/**
|
||||
* Returns {@code null} since a package is not enclosed by another
|
||||
* element.
|
||||
*
|
||||
* @return {@code null}
|
||||
*/
|
||||
@Override
|
||||
Element getEnclosingElement();
|
||||
}
|
||||
45
jdkSrc/jdk8/javax/lang/model/element/Parameterizable.java
Normal file
45
jdkSrc/jdk8/javax/lang/model/element/Parameterizable.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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.element;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A mixin interface for an element that has type parameters.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @since 1.7
|
||||
*/
|
||||
public interface Parameterizable extends Element {
|
||||
/**
|
||||
* Returns the formal type parameters of the type element in
|
||||
* declaration order.
|
||||
*
|
||||
* @return the formal type parameters, or an empty list
|
||||
* if there are none
|
||||
*/
|
||||
List<? extends TypeParameterElement> getTypeParameters();
|
||||
}
|
||||
41
jdkSrc/jdk8/javax/lang/model/element/QualifiedNameable.java
Normal file
41
jdkSrc/jdk8/javax/lang/model/element/QualifiedNameable.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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.element;
|
||||
|
||||
/**
|
||||
* A mixin interface for an element that has a qualified name.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @since 1.7
|
||||
*/
|
||||
public interface QualifiedNameable extends Element {
|
||||
/**
|
||||
* Returns the fully qualified name of an element.
|
||||
*
|
||||
* @return the fully qualified name of an element
|
||||
*/
|
||||
Name getQualifiedName();
|
||||
}
|
||||
164
jdkSrc/jdk8/javax/lang/model/element/TypeElement.java
Normal file
164
jdkSrc/jdk8/javax/lang/model/element/TypeElement.java
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
import java.util.List;
|
||||
import javax.lang.model.type.*;
|
||||
import javax.lang.model.util.*;
|
||||
|
||||
/**
|
||||
* Represents a class or interface program element. Provides access
|
||||
* to information about the type and its members. Note that an enum
|
||||
* type is a kind of class and an annotation type is a kind of
|
||||
* interface.
|
||||
*
|
||||
* <p> <a name="ELEM_VS_TYPE"></a>
|
||||
* While a {@code TypeElement} represents a class or interface
|
||||
* <i>element</i>, a {@link DeclaredType} represents a class
|
||||
* or interface <i>type</i>, the latter being a use
|
||||
* (or <i>invocation</i>) of the former.
|
||||
* The distinction is most apparent with generic types,
|
||||
* for which a single element can define a whole
|
||||
* family of types. For example, the element
|
||||
* {@code java.util.Set} corresponds to the parameterized types
|
||||
* {@code java.util.Set<String>} and {@code java.util.Set<Number>}
|
||||
* (and many others), and to the raw type {@code java.util.Set}.
|
||||
*
|
||||
* <p> Each method of this interface that returns a list of elements
|
||||
* will return them in the order that is natural for the underlying
|
||||
* source of program information. For example, if the underlying
|
||||
* source of information is Java source code, then the elements will be
|
||||
* returned in source code order.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see DeclaredType
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
|
||||
/**
|
||||
* Returns the fields, methods, constructors, and member types
|
||||
* that are directly declared in this class or interface.
|
||||
*
|
||||
* This includes any (implicit) default constructor and
|
||||
* the implicit {@code values} and {@code valueOf} methods of an
|
||||
* enum type.
|
||||
*
|
||||
* <p> Note that as a particular instance of the {@linkplain
|
||||
* javax.lang.model.element general accuracy requirements} and the
|
||||
* ordering behavior required of this interface, the list of
|
||||
* enclosed elements will be returned in the natural order for the
|
||||
* originating source of information about the type. For example,
|
||||
* if the information about the type is originating from a source
|
||||
* file, the elements will be returned in source code order.
|
||||
* (However, in that case the the ordering of synthesized
|
||||
* elements, such as a default constructor, is not specified.)
|
||||
*
|
||||
* @return the enclosed elements in proper order, or an empty list if none
|
||||
*/
|
||||
@Override
|
||||
List<? extends Element> getEnclosedElements();
|
||||
|
||||
/**
|
||||
* Returns the <i>nesting kind</i> of this type element.
|
||||
*
|
||||
* @return the nesting kind of this type element
|
||||
*/
|
||||
NestingKind getNestingKind();
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of this type element.
|
||||
* More precisely, it returns the <i>canonical</i> name.
|
||||
* For local and anonymous classes, which do not have canonical names,
|
||||
* an empty name is returned.
|
||||
*
|
||||
* <p>The name of a generic type does not include any reference
|
||||
* to its formal type parameters.
|
||||
* For example, the fully qualified name of the interface
|
||||
* {@code java.util.Set<E>} is "{@code java.util.Set}".
|
||||
* Nested types use "{@code .}" as a separator, as in
|
||||
* "{@code java.util.Map.Entry}".
|
||||
*
|
||||
* @return the fully qualified name of this class or interface, or
|
||||
* an empty name if none
|
||||
*
|
||||
* @see Elements#getBinaryName
|
||||
* @jls 6.7 Fully Qualified Names and Canonical Names
|
||||
*/
|
||||
Name getQualifiedName();
|
||||
|
||||
/**
|
||||
* Returns the simple name of this type element.
|
||||
*
|
||||
* For an anonymous class, an empty name is returned.
|
||||
*
|
||||
* @return the simple name of this class or interface,
|
||||
* an empty name for an anonymous class
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
Name getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the direct superclass of this type element.
|
||||
* If this type element represents an interface or the class
|
||||
* {@code java.lang.Object}, then a {@link NoType}
|
||||
* with kind {@link TypeKind#NONE NONE} is returned.
|
||||
*
|
||||
* @return the direct superclass, or a {@code NoType} if there is none
|
||||
*/
|
||||
TypeMirror getSuperclass();
|
||||
|
||||
/**
|
||||
* Returns the interface types directly implemented by this class
|
||||
* or extended by this interface.
|
||||
*
|
||||
* @return the interface types directly implemented by this class
|
||||
* or extended by this interface, or an empty list if there are none
|
||||
*/
|
||||
List<? extends TypeMirror> getInterfaces();
|
||||
|
||||
/**
|
||||
* Returns the formal type parameters of this type element
|
||||
* in declaration order.
|
||||
*
|
||||
* @return the formal type parameters, or an empty list
|
||||
* if there are none
|
||||
*/
|
||||
List<? extends TypeParameterElement> getTypeParameters();
|
||||
|
||||
/**
|
||||
* Returns the package of a top-level type and returns the
|
||||
* immediately lexically enclosing element for a {@linkplain
|
||||
* NestingKind#isNested nested} type.
|
||||
*
|
||||
* @return the package of a top-level type, the immediately
|
||||
* lexically enclosing element for a nested type
|
||||
*/
|
||||
@Override
|
||||
Element getEnclosingElement();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, 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.element;
|
||||
|
||||
import java.util.List;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
|
||||
/**
|
||||
* Represents a formal type parameter of a generic class, interface, method,
|
||||
* or constructor element.
|
||||
* A type parameter declares a {@link TypeVariable}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see TypeVariable
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface TypeParameterElement extends Element {
|
||||
|
||||
/**
|
||||
* Returns the generic class, interface, method, or constructor that is
|
||||
* parameterized by this type parameter.
|
||||
*
|
||||
* @return the generic class, interface, method, or constructor that is
|
||||
* parameterized by this type parameter
|
||||
*/
|
||||
Element getGenericElement();
|
||||
|
||||
/**
|
||||
* Returns the bounds of this type parameter.
|
||||
* These are the types given by the {@code extends} clause
|
||||
* used to declare this type parameter.
|
||||
* If no explicit {@code extends} clause was used,
|
||||
* then {@code java.lang.Object} is considered to be the sole bound.
|
||||
*
|
||||
* @return the bounds of this type parameter, or an empty list if
|
||||
* there are none
|
||||
*/
|
||||
List<? extends TypeMirror> getBounds();
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
|
||||
*
|
||||
* @return the generic element of this type parameter
|
||||
*/
|
||||
@Override
|
||||
Element getEnclosingElement();
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2009, 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.element;
|
||||
|
||||
import javax.lang.model.UnknownEntityException;
|
||||
|
||||
/**
|
||||
* Indicates that an unknown kind of annotation value was encountered.
|
||||
* This can occur if the language evolves and new kinds of annotation
|
||||
* values can be stored in an annotation. May be thrown by an
|
||||
* {@linkplain AnnotationValueVisitor annotation value visitor} to
|
||||
* indicate that the visitor was created for a prior version of the
|
||||
* language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see AnnotationValueVisitor#visitUnknown
|
||||
* @since 1.6
|
||||
*/
|
||||
public class UnknownAnnotationValueException extends UnknownEntityException {
|
||||
|
||||
private static final long serialVersionUID = 269L;
|
||||
|
||||
private transient AnnotationValue av;
|
||||
private transient Object parameter;
|
||||
|
||||
/**
|
||||
* Creates a new {@code UnknownAnnotationValueException}. The
|
||||
* {@code p} parameter may be used to pass in an additional
|
||||
* argument with information about the context in which the
|
||||
* unknown annotation value was encountered; for example, the
|
||||
* visit methods of {@link AnnotationValueVisitor} may pass in
|
||||
* their additional parameter.
|
||||
*
|
||||
* @param av the unknown annotation value, may be {@code null}
|
||||
* @param p an additional parameter, may be {@code null}
|
||||
*/
|
||||
public UnknownAnnotationValueException(AnnotationValue av, Object p) {
|
||||
super("Unknown annotation value: " + av);
|
||||
this.av = av;
|
||||
this.parameter = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unknown annotation value.
|
||||
* The value may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the unknown element, or {@code null} if unavailable
|
||||
*/
|
||||
public AnnotationValue getUnknownAnnotationValue() {
|
||||
return av;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additional argument.
|
||||
*
|
||||
* @return the additional argument
|
||||
*/
|
||||
public Object getArgument() {
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2009, 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.element;
|
||||
|
||||
import javax.lang.model.UnknownEntityException;
|
||||
|
||||
/**
|
||||
* Indicates that an unknown kind of element was encountered. This
|
||||
* can occur if the language evolves and new kinds of elements are
|
||||
* added to the {@code Element} hierarchy. May be thrown by an
|
||||
* {@linkplain ElementVisitor element visitor} to indicate that the
|
||||
* visitor was created for a prior version of the language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see ElementVisitor#visitUnknown
|
||||
* @since 1.6
|
||||
*/
|
||||
public class UnknownElementException extends UnknownEntityException {
|
||||
|
||||
private static final long serialVersionUID = 269L;
|
||||
|
||||
private transient Element element;
|
||||
private transient Object parameter;
|
||||
|
||||
/**
|
||||
* Creates a new {@code UnknownElementException}. The {@code p}
|
||||
* parameter may be used to pass in an additional argument with
|
||||
* information about the context in which the unknown element was
|
||||
* encountered; for example, the visit methods of {@link
|
||||
* ElementVisitor} may pass in their additional parameter.
|
||||
*
|
||||
* @param e the unknown element, may be {@code null}
|
||||
* @param p an additional parameter, may be {@code null}
|
||||
*/
|
||||
public UnknownElementException(Element e, Object p) {
|
||||
super("Unknown element: " + e);
|
||||
element = e;
|
||||
this.parameter = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unknown element.
|
||||
* The value may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the unknown element, or {@code null} if unavailable
|
||||
*/
|
||||
public Element getUnknownElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additional argument.
|
||||
*
|
||||
* @return the additional argument
|
||||
*/
|
||||
public Object getArgument() {
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
90
jdkSrc/jdk8/javax/lang/model/element/VariableElement.java
Normal file
90
jdkSrc/jdk8/javax/lang/model/element/VariableElement.java
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.element;
|
||||
|
||||
import javax.lang.model.util.Elements;
|
||||
|
||||
/**
|
||||
* Represents a field, {@code enum} constant, method or constructor
|
||||
* parameter, local variable, resource variable, or exception
|
||||
* parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface VariableElement extends Element {
|
||||
|
||||
/**
|
||||
* Returns the value of this variable if this is a {@code final}
|
||||
* field initialized to a compile-time constant. Returns {@code
|
||||
* null} otherwise. The value will be of a primitive type or a
|
||||
* {@code String}. If the value is of a primitive type, it is
|
||||
* wrapped in the appropriate wrapper class (such as {@link
|
||||
* Integer}).
|
||||
*
|
||||
* <p>Note that not all {@code final} fields will have
|
||||
* constant values. In particular, {@code enum} constants are
|
||||
* <em>not</em> considered to be compile-time constants. To have a
|
||||
* constant value, a field's type must be either a primitive type
|
||||
* or {@code String}.
|
||||
*
|
||||
* @return the value of this variable if this is a {@code final}
|
||||
* field initialized to a compile-time constant, or {@code null}
|
||||
* otherwise
|
||||
*
|
||||
* @see Elements#getConstantExpression(Object)
|
||||
* @jls 15.28 Constant Expression
|
||||
* @jls 4.12.4 final Variables
|
||||
*/
|
||||
Object getConstantValue();
|
||||
|
||||
/**
|
||||
* Returns the simple name of this variable element.
|
||||
*
|
||||
* <p>For method and constructor parameters, the name of each
|
||||
* parameter must be distinct from the names of all other
|
||||
* parameters of the same executable. If the original source
|
||||
* names are not available, an implementation may synthesize names
|
||||
* subject to the distinctness requirement above.
|
||||
*
|
||||
* @return the simple name of this variable element
|
||||
*/
|
||||
@Override
|
||||
Name getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the enclosing element of this variable.
|
||||
*
|
||||
* The enclosing element of a method or constructor parameter is
|
||||
* the executable declaring the parameter.
|
||||
*
|
||||
* @return the enclosing element of this variable
|
||||
*/
|
||||
@Override
|
||||
Element getEnclosingElement();
|
||||
}
|
||||
101
jdkSrc/jdk8/javax/lang/model/element/package-info.java
Normal file
101
jdkSrc/jdk8/javax/lang/model/element/package-info.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces used to model elements of the Java programming language.
|
||||
*
|
||||
* The term "element" in this package is used to refer to program
|
||||
* elements, the declared entities that make up a program. Elements
|
||||
* include classes, interfaces, methods, constructors, and fields.
|
||||
* The interfaces in this package do not model the structure of a
|
||||
* program inside a method body; for example there is no
|
||||
* representation of a {@code for} loop or {@code try}-{@code finally}
|
||||
* block. However, the interfaces can model some structures only
|
||||
* appearing inside method bodies, such as local variables and
|
||||
* anonymous classes.
|
||||
*
|
||||
* <p>When used in the context of annotation processing, an accurate
|
||||
* model of the element being represented must be returned. As this
|
||||
* is a language model, the source code provides the fiducial
|
||||
* (reference) representation of the construct in question rather than
|
||||
* a representation in an executable output like a class file.
|
||||
* Executable output may serve as the basis for creating a modeling
|
||||
* element. However, the process of translating source code to
|
||||
* executable output may not permit recovering some aspects of the
|
||||
* source code representation. For example, annotations with
|
||||
* {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
|
||||
* {@linkplain java.lang.annotation.Retention retention} cannot be
|
||||
* recovered from class files and class files might not be able to
|
||||
* provide source position information.
|
||||
*
|
||||
* Names of parameters may not be recoverable from class files.
|
||||
*
|
||||
* The {@linkplain javax.lang.model.element.Modifier modifiers} on an
|
||||
* element may differ in some cases including:
|
||||
*
|
||||
* <ul>
|
||||
* <li> {@code strictfp} on a class or interface
|
||||
* <li> {@code final} on a parameter
|
||||
* <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces
|
||||
* </ul>
|
||||
*
|
||||
* Additionally, synthetic constructs in a class file, such as
|
||||
* accessor methods used in implementing nested classes and bridge
|
||||
* methods used in implementing covariant returns, are translation
|
||||
* artifacts outside of this model.
|
||||
*
|
||||
* <p>During annotation processing, operating on incomplete or
|
||||
* erroneous programs is necessary; however, there are fewer
|
||||
* guarantees about the nature of the resulting model. If the source
|
||||
* code is not syntactically well-formed or has some other
|
||||
* irrecoverable error that could not be removed by the generation of
|
||||
* new types, a model may or may not be provided as a quality of
|
||||
* implementation issue.
|
||||
* If a program is syntactically valid but erroneous in some other
|
||||
* fashion, any returned model must have no less information than if
|
||||
* all the method bodies in the program were replaced by {@code "throw
|
||||
* new RuntimeException();"}. If a program refers to a missing type XYZ,
|
||||
* the returned model must contain no less information than if the
|
||||
* declaration of type XYZ were assumed to be {@code "class XYZ {}"},
|
||||
* {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
|
||||
* "@interface XYZ {}"}. If a program refers to a missing type {@code
|
||||
* XYZ<K1, ... ,Kn>}, the returned model must contain no less
|
||||
* information than if the declaration of XYZ were assumed to be
|
||||
* {@code "class XYZ<T1, ... ,Tn> {}"} or {@code "interface XYZ<T1,
|
||||
* ... ,Tn> {}"}
|
||||
*
|
||||
* <p> Unless otherwise specified in a particular implementation, the
|
||||
* collections returned by methods in this package should be expected
|
||||
* to be unmodifiable by the caller and unsafe for concurrent access.
|
||||
*
|
||||
* <p> Unless otherwise specified, methods in this package will throw
|
||||
* a {@code NullPointerException} if given a {@code null} argument.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
package javax.lang.model.element;
|
||||
60
jdkSrc/jdk8/javax/lang/model/package-info.java
Normal file
60
jdkSrc/jdk8/javax/lang/model/package-info.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes and hierarchies of packages used to model the Java
|
||||
* programming language.
|
||||
*
|
||||
* The members of this package and its subpackages are for use in
|
||||
* language modeling and language processing tasks and APIs including,
|
||||
* but not limited to, the {@linkplain javax.annotation.processing
|
||||
* annotation processing} framework.
|
||||
*
|
||||
* <p> This language model follows a <i>mirror</i>-based design; see
|
||||
*
|
||||
* <blockquote>
|
||||
* Gilad Bracha and David Ungar. <i>Mirrors: Design Principles for
|
||||
* Meta-level Facilities of Object-Oriented Programming Languages</i>.
|
||||
* In Proc. of the ACM Conf. on Object-Oriented Programming, Systems,
|
||||
* Languages and Applications, October 2004.
|
||||
* </blockquote>
|
||||
*
|
||||
* In particular, the model makes a distinction between static
|
||||
* language constructs, like the {@linkplain javax.lang.model.element
|
||||
* element} representing {@code java.util.Set}, and the family of
|
||||
* {@linkplain javax.lang.model.type types} that may be associated
|
||||
* with an element, like the raw type {@code java.util.Set}, {@code
|
||||
* java.util.Set<String>}, and {@code java.util.Set<T>}.
|
||||
*
|
||||
* <p> Unless otherwise specified, methods in this package will throw
|
||||
* a {@code NullPointerException} if given a {@code null} argument.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
package javax.lang.model;
|
||||
47
jdkSrc/jdk8/javax/lang/model/type/ArrayType.java
Normal file
47
jdkSrc/jdk8/javax/lang/model/type/ArrayType.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents an array type.
|
||||
* A multidimensional array type is represented as an array type
|
||||
* whose component type is also an array type.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ArrayType extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the component type of this array type.
|
||||
*
|
||||
* @return the component type of this array type
|
||||
*/
|
||||
TypeMirror getComponentType();
|
||||
}
|
||||
89
jdkSrc/jdk8/javax/lang/model/type/DeclaredType.java
Normal file
89
jdkSrc/jdk8/javax/lang/model/type/DeclaredType.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.Types;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a declared type, either a class type or an interface type.
|
||||
* This includes parameterized types such as {@code java.util.Set<String>}
|
||||
* as well as raw types.
|
||||
*
|
||||
* <p> While a {@code TypeElement} represents a class or interface
|
||||
* <i>element</i>, a {@code DeclaredType} represents a class
|
||||
* or interface <i>type</i>, the latter being a use
|
||||
* (or <i>invocation</i>) of the former.
|
||||
* See {@link TypeElement} for more on this distinction.
|
||||
*
|
||||
* <p> The supertypes (both class and interface types) of a declared
|
||||
* type may be found using the {@link
|
||||
* Types#directSupertypes(TypeMirror)} method. This returns the
|
||||
* supertypes with any type arguments substituted in.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see TypeElement
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface DeclaredType extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the element corresponding to this type.
|
||||
*
|
||||
* @return the element corresponding to this type
|
||||
*/
|
||||
Element asElement();
|
||||
|
||||
/**
|
||||
* Returns the type of the innermost enclosing instance or a
|
||||
* {@code NoType} of kind {@code NONE} if there is no enclosing
|
||||
* instance. Only types corresponding to inner classes have an
|
||||
* enclosing instance.
|
||||
*
|
||||
* @return a type mirror for the enclosing type
|
||||
* @jls 8.1.3 Inner Classes and Enclosing Instances
|
||||
* @jls 15.9.2 Determining Enclosing Instances
|
||||
*/
|
||||
TypeMirror getEnclosingType();
|
||||
|
||||
/**
|
||||
* Returns the actual type arguments of this type.
|
||||
* For a type nested within a parameterized type
|
||||
* (such as {@code Outer<String>.Inner<Number>}), only the type
|
||||
* arguments of the innermost type are included.
|
||||
*
|
||||
* @return the actual type arguments of this type, or an empty list
|
||||
* if none
|
||||
*/
|
||||
List<? extends TypeMirror> getTypeArguments();
|
||||
}
|
||||
42
jdkSrc/jdk8/javax/lang/model/type/ErrorType.java
Normal file
42
jdkSrc/jdk8/javax/lang/model/type/ErrorType.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, 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.type;
|
||||
|
||||
/**
|
||||
* Represents a class or interface type that cannot be properly modeled.
|
||||
* This may be the result of a processing error,
|
||||
* such as a missing class file or erroneous source code.
|
||||
* Most queries for
|
||||
* information derived from such a type (such as its members or its
|
||||
* supertype) will not, in general, return meaningful results.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ErrorType extends DeclaredType {
|
||||
}
|
||||
107
jdkSrc/jdk8/javax/lang/model/type/ExecutableType.java
Normal file
107
jdkSrc/jdk8/javax/lang/model/type/ExecutableType.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
|
||||
/**
|
||||
* Represents the type of an executable. An <i>executable</i>
|
||||
* is a method, constructor, or initializer.
|
||||
*
|
||||
* <p> The executable is
|
||||
* represented as when viewed as a method (or constructor or
|
||||
* initializer) of some reference type.
|
||||
* If that reference type is parameterized, then its actual
|
||||
* type arguments are substituted into any types returned by the methods of
|
||||
* this interface.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see ExecutableElement
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ExecutableType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Returns the type variables declared by the formal type parameters
|
||||
* of this executable.
|
||||
*
|
||||
* @return the type variables declared by the formal type parameters,
|
||||
* or an empty list if there are none
|
||||
*/
|
||||
List<? extends TypeVariable> getTypeVariables();
|
||||
|
||||
/**
|
||||
* Returns the return type of this executable.
|
||||
* Returns a {@link NoType} with kind {@link TypeKind#VOID VOID}
|
||||
* if this executable is not a method, or is a method that does not
|
||||
* return a value.
|
||||
*
|
||||
* @return the return type of this executable
|
||||
*/
|
||||
TypeMirror getReturnType();
|
||||
|
||||
/**
|
||||
* Returns the types of this executable's formal parameters.
|
||||
*
|
||||
* @return the types of this executable's formal parameters,
|
||||
* or an empty list if there are none
|
||||
*/
|
||||
List<? extends TypeMirror> getParameterTypes();
|
||||
|
||||
/**
|
||||
* Returns the receiver type of this executable,
|
||||
* or {@link javax.lang.model.type.NoType NoType} with
|
||||
* kind {@link javax.lang.model.type.TypeKind#NONE NONE}
|
||||
* if the executable has no receiver type.
|
||||
*
|
||||
* An executable which is an instance method, or a constructor of an
|
||||
* inner class, has a receiver type derived from the {@linkplain
|
||||
* ExecutableElement#getEnclosingElement declaring type}.
|
||||
*
|
||||
* An executable which is a static method, or a constructor of a
|
||||
* non-inner class, or an initializer (static or instance), has no
|
||||
* receiver type.
|
||||
*
|
||||
* @return the receiver type of this executable
|
||||
* @since 1.8
|
||||
*/
|
||||
TypeMirror getReceiverType();
|
||||
|
||||
/**
|
||||
* Returns the exceptions and other throwables listed in this
|
||||
* executable's {@code throws} clause.
|
||||
*
|
||||
* @return the exceptions and other throwables listed in this
|
||||
* executable's {@code throws} clause,
|
||||
* or an empty list if there are none.
|
||||
*/
|
||||
List<? extends TypeMirror> getThrownTypes();
|
||||
}
|
||||
55
jdkSrc/jdk8/javax/lang/model/type/IntersectionType.java
Normal file
55
jdkSrc/jdk8/javax/lang/model/type/IntersectionType.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents an intersection type.
|
||||
*
|
||||
* <p>An intersection type can be either implicitly or explicitly
|
||||
* declared in a program. For example, the bound of the type parameter
|
||||
* {@code <T extends Number & Runnable>} is an (implicit) intersection
|
||||
* type. As of {@link javax.lang.model.SourceVersion#RELEASE_8
|
||||
* RELEASE_8}, this is represented by an {@code IntersectionType} with
|
||||
* {@code Number} and {@code Runnable} as its bounds.
|
||||
*
|
||||
* @implNote Also as of {@link
|
||||
* javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}, in the
|
||||
* reference implementation an {@code IntersectionType} is used to
|
||||
* model the explicit target type of a cast expression.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public interface IntersectionType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Return the bounds comprising this intersection type.
|
||||
*
|
||||
* @return the bounds of this intersection types.
|
||||
*/
|
||||
List<? extends TypeMirror> getBounds();
|
||||
}
|
||||
80
jdkSrc/jdk8/javax/lang/model/type/MirroredTypeException.java
Normal file
80
jdkSrc/jdk8/javax/lang/model/type/MirroredTypeException.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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.type;
|
||||
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when an application attempts to access the {@link Class} object
|
||||
* corresponding to a {@link TypeMirror}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see MirroredTypesException
|
||||
* @see Element#getAnnotation(Class)
|
||||
* @since 1.6
|
||||
*/
|
||||
public class MirroredTypeException extends MirroredTypesException {
|
||||
|
||||
private static final long serialVersionUID = 269;
|
||||
|
||||
private transient TypeMirror type; // cannot be serialized
|
||||
|
||||
/**
|
||||
* Constructs a new MirroredTypeException for the specified type.
|
||||
*
|
||||
* @param type the type being accessed
|
||||
*/
|
||||
public MirroredTypeException(TypeMirror type) {
|
||||
super("Attempt to access Class object for TypeMirror " + type.toString(), type);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type mirror corresponding to the type being accessed.
|
||||
* The type mirror may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the type mirror, or {@code null} if unavailable
|
||||
*/
|
||||
public TypeMirror getTypeMirror() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly set all transient fields.
|
||||
*/
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
type = null;
|
||||
types = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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.type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
|
||||
/**
|
||||
* Thrown when an application attempts to access a sequence of {@link
|
||||
* Class} objects each corresponding to a {@link TypeMirror}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see MirroredTypeException
|
||||
* @see Element#getAnnotation(Class)
|
||||
* @since 1.6
|
||||
*/
|
||||
public class MirroredTypesException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 269;
|
||||
|
||||
transient List<? extends TypeMirror> types; // cannot be serialized
|
||||
|
||||
/*
|
||||
* Trusted constructor to be called by MirroredTypeException.
|
||||
*/
|
||||
MirroredTypesException(String message, TypeMirror type) {
|
||||
super(message);
|
||||
List<TypeMirror> tmp = (new ArrayList<TypeMirror>());
|
||||
tmp.add(type);
|
||||
types = Collections.unmodifiableList(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new MirroredTypesException for the specified types.
|
||||
*
|
||||
* @param types the types being accessed
|
||||
*/
|
||||
public MirroredTypesException(List<? extends TypeMirror> types) {
|
||||
super("Attempt to access Class objects for TypeMirrors " +
|
||||
(types = // defensive copy
|
||||
new ArrayList<TypeMirror>(types)).toString() );
|
||||
this.types = Collections.unmodifiableList(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type mirrors corresponding to the types being accessed.
|
||||
* The type mirrors may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the type mirrors in construction order, or {@code null} if unavailable
|
||||
*/
|
||||
public List<? extends TypeMirror> getTypeMirrors() {
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly set all transient fields.
|
||||
*/
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
types = null;
|
||||
}
|
||||
}
|
||||
50
jdkSrc/jdk8/javax/lang/model/type/NoType.java
Normal file
50
jdkSrc/jdk8/javax/lang/model/type/NoType.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
|
||||
|
||||
/**
|
||||
* A pseudo-type used where no actual type is appropriate.
|
||||
* The kinds of {@code NoType} are:
|
||||
* <ul>
|
||||
* <li>{@link TypeKind#VOID VOID} - corresponds to the keyword {@code void}.
|
||||
* <li>{@link TypeKind#PACKAGE PACKAGE} - the pseudo-type of a package element.
|
||||
* <li>{@link TypeKind#NONE NONE} - used in other cases
|
||||
* where no actual type is appropriate; for example, the superclass
|
||||
* of {@code java.lang.Object}.
|
||||
* </ul>
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see ExecutableElement#getReturnType()
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
public interface NoType extends TypeMirror {
|
||||
}
|
||||
40
jdkSrc/jdk8/javax/lang/model/type/NullType.java
Normal file
40
jdkSrc/jdk8/javax/lang/model/type/NullType.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents the null type.
|
||||
* This is the type of the expression {@code null},
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
public interface NullType extends ReferenceType {
|
||||
}
|
||||
40
jdkSrc/jdk8/javax/lang/model/type/PrimitiveType.java
Normal file
40
jdkSrc/jdk8/javax/lang/model/type/PrimitiveType.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a primitive type. These include
|
||||
* {@code boolean}, {@code byte}, {@code short}, {@code int},
|
||||
* {@code long}, {@code char}, {@code float}, and {@code double}.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface PrimitiveType extends TypeMirror {
|
||||
}
|
||||
40
jdkSrc/jdk8/javax/lang/model/type/ReferenceType.java
Normal file
40
jdkSrc/jdk8/javax/lang/model/type/ReferenceType.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a reference type.
|
||||
* These include class and interface types, array types, type variables,
|
||||
* and the null type.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface ReferenceType extends TypeMirror {
|
||||
}
|
||||
177
jdkSrc/jdk8/javax/lang/model/type/TypeKind.java
Normal file
177
jdkSrc/jdk8/javax/lang/model/type/TypeKind.java
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* The kind of a type mirror.
|
||||
*
|
||||
* <p>Note that it is possible additional type kinds will be added to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see TypeMirror
|
||||
* @since 1.6
|
||||
*/
|
||||
public enum TypeKind {
|
||||
/**
|
||||
* The primitive type {@code boolean}.
|
||||
*/
|
||||
BOOLEAN,
|
||||
|
||||
/**
|
||||
* The primitive type {@code byte}.
|
||||
*/
|
||||
BYTE,
|
||||
|
||||
/**
|
||||
* The primitive type {@code short}.
|
||||
*/
|
||||
SHORT,
|
||||
|
||||
/**
|
||||
* The primitive type {@code int}.
|
||||
*/
|
||||
INT,
|
||||
|
||||
/**
|
||||
* The primitive type {@code long}.
|
||||
*/
|
||||
LONG,
|
||||
|
||||
/**
|
||||
* The primitive type {@code char}.
|
||||
*/
|
||||
CHAR,
|
||||
|
||||
/**
|
||||
* The primitive type {@code float}.
|
||||
*/
|
||||
FLOAT,
|
||||
|
||||
/**
|
||||
* The primitive type {@code double}.
|
||||
*/
|
||||
DOUBLE,
|
||||
|
||||
/**
|
||||
* The pseudo-type corresponding to the keyword {@code void}.
|
||||
* @see NoType
|
||||
*/
|
||||
VOID,
|
||||
|
||||
/**
|
||||
* A pseudo-type used where no actual type is appropriate.
|
||||
* @see NoType
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* The null type.
|
||||
*/
|
||||
NULL,
|
||||
|
||||
/**
|
||||
* An array type.
|
||||
*/
|
||||
ARRAY,
|
||||
|
||||
/**
|
||||
* A class or interface type.
|
||||
*/
|
||||
DECLARED,
|
||||
|
||||
/**
|
||||
* A class or interface type that could not be resolved.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* A type variable.
|
||||
*/
|
||||
TYPEVAR,
|
||||
|
||||
/**
|
||||
* A wildcard type argument.
|
||||
*/
|
||||
WILDCARD,
|
||||
|
||||
/**
|
||||
* A pseudo-type corresponding to a package element.
|
||||
* @see NoType
|
||||
*/
|
||||
PACKAGE,
|
||||
|
||||
/**
|
||||
* A method, constructor, or initializer.
|
||||
*/
|
||||
EXECUTABLE,
|
||||
|
||||
/**
|
||||
* An implementation-reserved type.
|
||||
* This is not the type you are looking for.
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* A union type.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
UNION,
|
||||
|
||||
/**
|
||||
* An intersection type.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
INTERSECTION;
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this kind corresponds to a primitive
|
||||
* type and {@code false} otherwise.
|
||||
* @return {@code true} if this kind corresponds to a primitive type
|
||||
*/
|
||||
public boolean isPrimitive() {
|
||||
switch(this) {
|
||||
case BOOLEAN:
|
||||
case BYTE:
|
||||
case SHORT:
|
||||
case INT:
|
||||
case LONG:
|
||||
case CHAR:
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/javax/lang/model/type/TypeMirror.java
Normal file
110
jdkSrc/jdk8/javax/lang/model/type/TypeMirror.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.util.Types;
|
||||
|
||||
/**
|
||||
* Represents a type in the Java programming language.
|
||||
* Types include primitive types, declared types (class and interface types),
|
||||
* array types, type variables, and the null type.
|
||||
* Also represented are wildcard type arguments,
|
||||
* the signature and return types of executables,
|
||||
* and pseudo-types corresponding to packages and to the keyword {@code void}.
|
||||
*
|
||||
* <p> Types should be compared using the utility methods in {@link
|
||||
* Types}. There is no guarantee that any particular type will always
|
||||
* be represented by the same object.
|
||||
*
|
||||
* <p> To implement operations based on the class of an {@code
|
||||
* TypeMirror} object, either use a {@linkplain TypeVisitor visitor}
|
||||
* or use the result of the {@link #getKind} method. Using {@code
|
||||
* instanceof} is <em>not</em> necessarily a reliable idiom for
|
||||
* determining the effective class of an object in this modeling
|
||||
* hierarchy since an implementation may choose to have a single
|
||||
* object implement multiple {@code TypeMirror} subinterfaces.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see Element
|
||||
* @see Types
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
|
||||
|
||||
/**
|
||||
* Returns the {@code kind} of this type.
|
||||
*
|
||||
* @return the kind of this type
|
||||
*/
|
||||
TypeKind getKind();
|
||||
|
||||
/**
|
||||
* Obeys the general contract of {@link Object#equals Object.equals}.
|
||||
* This method does not, however, indicate whether two types represent
|
||||
* the same type.
|
||||
* Semantic comparisons of type equality should instead use
|
||||
* {@link Types#isSameType(TypeMirror, TypeMirror)}.
|
||||
* The results of {@code t1.equals(t2)} and
|
||||
* {@code Types.isSameType(t1, t2)} may differ.
|
||||
*
|
||||
* @param obj the object to be compared with this type
|
||||
* @return {@code true} if the specified object is equal to this one
|
||||
*/
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Obeys the general contract of {@link Object#hashCode Object.hashCode}.
|
||||
*
|
||||
* @see #equals
|
||||
*/
|
||||
int hashCode();
|
||||
|
||||
/**
|
||||
* Returns an informative string representation of this type. If
|
||||
* possible, the string should be of a form suitable for
|
||||
* representing this type in source code. Any names embedded in
|
||||
* the result are qualified if possible.
|
||||
*
|
||||
* @return a string representation of this type
|
||||
*/
|
||||
String toString();
|
||||
|
||||
/**
|
||||
* Applies a visitor to this type.
|
||||
*
|
||||
* @param <R> the return type of the visitor's methods
|
||||
* @param <P> the type of the additional parameter to the visitor's methods
|
||||
* @param v the visitor operating on this type
|
||||
* @param p additional parameter to the visitor
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
<R, P> R accept(TypeVisitor<R, P> v, P p);
|
||||
}
|
||||
83
jdkSrc/jdk8/javax/lang/model/type/TypeVariable.java
Normal file
83
jdkSrc/jdk8/javax/lang/model/type/TypeVariable.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeParameterElement;
|
||||
import javax.lang.model.util.Types;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a type variable.
|
||||
* A type variable may be explicitly declared by a
|
||||
* {@linkplain TypeParameterElement type parameter} of a
|
||||
* type, method, or constructor.
|
||||
* A type variable may also be declared implicitly, as by
|
||||
* the capture conversion of a wildcard type argument
|
||||
* (see chapter 5 of
|
||||
* <cite>The Java™ Language Specification</cite>).
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see TypeParameterElement
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface TypeVariable extends ReferenceType {
|
||||
|
||||
/**
|
||||
* Returns the element corresponding to this type variable.
|
||||
*
|
||||
* @return the element corresponding to this type variable
|
||||
*/
|
||||
Element asElement();
|
||||
|
||||
/**
|
||||
* Returns the upper bound of this type variable.
|
||||
*
|
||||
* <p> If this type variable was declared with no explicit
|
||||
* upper bounds, the result is {@code java.lang.Object}.
|
||||
* If it was declared with multiple upper bounds,
|
||||
* the result is an {@linkplain IntersectionType intersection type};
|
||||
* individual bounds can be found by examining the result's
|
||||
* {@linkplain IntersectionType#getBounds() bounds}.
|
||||
*
|
||||
* @return the upper bound of this type variable
|
||||
*/
|
||||
TypeMirror getUpperBound();
|
||||
|
||||
/**
|
||||
* Returns the lower bound of this type variable. While a type
|
||||
* parameter cannot include an explicit lower bound declaration,
|
||||
* capture conversion can produce a type variable with a
|
||||
* non-trivial lower bound. Type variables otherwise have a
|
||||
* lower bound of {@link NullType}.
|
||||
*
|
||||
* @return the lower bound of this type variable
|
||||
*/
|
||||
TypeMirror getLowerBound();
|
||||
}
|
||||
197
jdkSrc/jdk8/javax/lang/model/type/TypeVisitor.java
Normal file
197
jdkSrc/jdk8/javax/lang/model/type/TypeVisitor.java
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* 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.type;
|
||||
|
||||
import javax.lang.model.element.*;
|
||||
|
||||
/**
|
||||
* A visitor of types, in the style of the
|
||||
* visitor design pattern. Classes implementing this
|
||||
* interface are used to operate on a type when the kind of
|
||||
* type is unknown at compile time. When a visitor is passed to a
|
||||
* type's {@link TypeMirror#accept accept} method, the <tt>visit<i>XYZ</i></tt>
|
||||
* method most applicable to that type is invoked.
|
||||
*
|
||||
* <p> Classes implementing this interface may or may not throw a
|
||||
* {@code NullPointerException} if the additional parameter {@code p}
|
||||
* is {@code null}; see documentation of the implementing class for
|
||||
* details.
|
||||
*
|
||||
* <p> <b>WARNING:</b> It is possible that methods will be added to
|
||||
* this interface to accommodate new, currently unknown, language
|
||||
* structures added to future versions of the Java™ programming
|
||||
* language. Therefore, visitor classes directly implementing this
|
||||
* interface may be source incompatible with future versions of the
|
||||
* platform. To avoid this source incompatibility, visitor
|
||||
* implementations are encouraged to instead extend the appropriate
|
||||
* abstract visitor class that implements this interface. However, an
|
||||
* API should generally use this visitor interface as the type for
|
||||
* parameters, return type, etc. rather than one of the abstract
|
||||
* classes.
|
||||
*
|
||||
* <p>Note that methods to accommodate new language constructs could
|
||||
* be added in a source <em>compatible</em> way if they were added as
|
||||
* <em>default methods</em>. However, default methods are only
|
||||
* available on Java SE 8 and higher releases and the {@code
|
||||
* javax.lang.model.*} packages bundled in Java SE 8 are required to
|
||||
* also be runnable on Java SE 7. Therefore, default methods
|
||||
* <em>cannot</em> be used when extending {@code javax.lang.model.*}
|
||||
* to cover Java SE 8 language features. However, default methods may
|
||||
* be used in subsequent revisions of the {@code javax.lang.model.*}
|
||||
* packages that are only required to run on Java SE 8 and higher
|
||||
* platform versions.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface TypeVisitor<R, P> {
|
||||
/**
|
||||
* Visits a type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(TypeMirror t, P p);
|
||||
|
||||
/**
|
||||
* A convenience method equivalent to {@code v.visit(t, null)}.
|
||||
* @param t the element to visit
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visit(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Visits a primitive type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitPrimitive(PrimitiveType t, P p);
|
||||
|
||||
/**
|
||||
* Visits the null type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitNull(NullType t, P p);
|
||||
|
||||
/**
|
||||
* Visits an array type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitArray(ArrayType t, P p);
|
||||
|
||||
/**
|
||||
* Visits a declared type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitDeclared(DeclaredType t, P p);
|
||||
|
||||
/**
|
||||
* Visits an error type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitError(ErrorType t, P p);
|
||||
|
||||
/**
|
||||
* Visits a type variable.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitTypeVariable(TypeVariable t, P p);
|
||||
|
||||
/**
|
||||
* Visits a wildcard type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitWildcard(WildcardType t, P p);
|
||||
|
||||
/**
|
||||
* Visits an executable type.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitExecutable(ExecutableType t, P p);
|
||||
|
||||
/**
|
||||
* Visits a {@link NoType} instance.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
R visitNoType(NoType t, P p);
|
||||
|
||||
/**
|
||||
* Visits an unknown kind of type.
|
||||
* This can occur if the language evolves and new kinds
|
||||
* of types are added to the {@code TypeMirror} hierarchy.
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
* @throws UnknownTypeException
|
||||
* a visitor implementation may optionally throw this exception
|
||||
*/
|
||||
R visitUnknown(TypeMirror t, P p);
|
||||
|
||||
/**
|
||||
* Visits a union type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
* @since 1.7
|
||||
*/
|
||||
R visitUnion(UnionType t, P p);
|
||||
|
||||
/**
|
||||
* Visits an intersection type.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
* @since 1.8
|
||||
*/
|
||||
R visitIntersection(IntersectionType t, P p);
|
||||
}
|
||||
47
jdkSrc/jdk8/javax/lang/model/type/UnionType.java
Normal file
47
jdkSrc/jdk8/javax/lang/model/type/UnionType.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2011, 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.type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a union type.
|
||||
*
|
||||
* As of the {@link javax.lang.model.SourceVersion#RELEASE_7
|
||||
* RELEASE_7} source version, union types can appear as the type
|
||||
* of a multi-catch exception parameter.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public interface UnionType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Return the alternatives comprising this union type.
|
||||
*
|
||||
* @return the alternatives comprising this union type.
|
||||
*/
|
||||
List<? extends TypeMirror> getAlternatives();
|
||||
}
|
||||
85
jdkSrc/jdk8/javax/lang/model/type/UnknownTypeException.java
Normal file
85
jdkSrc/jdk8/javax/lang/model/type/UnknownTypeException.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2009, 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.type;
|
||||
|
||||
import javax.lang.model.UnknownEntityException;
|
||||
|
||||
/**
|
||||
* Indicates that an unknown kind of type was encountered. This can
|
||||
* occur if the language evolves and new kinds of types are added to
|
||||
* the {@code TypeMirror} hierarchy. May be thrown by a {@linkplain
|
||||
* TypeVisitor type visitor} to indicate that the visitor was created
|
||||
* for a prior version of the language.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @see TypeVisitor#visitUnknown
|
||||
* @since 1.6
|
||||
*/
|
||||
public class UnknownTypeException extends UnknownEntityException {
|
||||
|
||||
private static final long serialVersionUID = 269L;
|
||||
|
||||
private transient TypeMirror type;
|
||||
private transient Object parameter;
|
||||
|
||||
/**
|
||||
* Creates a new {@code UnknownTypeException}.The {@code p}
|
||||
* parameter may be used to pass in an additional argument with
|
||||
* information about the context in which the unknown type was
|
||||
* encountered; for example, the visit methods of {@link
|
||||
* TypeVisitor} may pass in their additional parameter.
|
||||
*
|
||||
* @param t the unknown type, may be {@code null}
|
||||
* @param p an additional parameter, may be {@code null}
|
||||
*/
|
||||
public UnknownTypeException(TypeMirror t, Object p) {
|
||||
super("Unknown type: " + t);
|
||||
type = t;
|
||||
this.parameter = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unknown type.
|
||||
* The value may be unavailable if this exception has been
|
||||
* serialized and then read back in.
|
||||
*
|
||||
* @return the unknown type, or {@code null} if unavailable
|
||||
*/
|
||||
public TypeMirror getUnknownType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the additional argument.
|
||||
*
|
||||
* @return the additional argument
|
||||
*/
|
||||
public Object getArgument() {
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
65
jdkSrc/jdk8/javax/lang/model/type/WildcardType.java
Normal file
65
jdkSrc/jdk8/javax/lang/model/type/WildcardType.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.type;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a wildcard type argument.
|
||||
* Examples include: <pre><tt>
|
||||
* ?
|
||||
* ? extends Number
|
||||
* ? super T
|
||||
* </tt></pre>
|
||||
*
|
||||
* <p> A wildcard may have its upper bound explicitly set by an
|
||||
* {@code extends} clause, its lower bound explicitly set by a
|
||||
* {@code super} clause, or neither (but not both).
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface WildcardType extends TypeMirror {
|
||||
|
||||
/**
|
||||
* Returns the upper bound of this wildcard.
|
||||
* If no upper bound is explicitly declared,
|
||||
* {@code null} is returned.
|
||||
*
|
||||
* @return the upper bound of this wildcard
|
||||
*/
|
||||
TypeMirror getExtendsBound();
|
||||
|
||||
/**
|
||||
* Returns the lower bound of this wildcard.
|
||||
* If no lower bound is explicitly declared,
|
||||
* {@code null} is returned.
|
||||
*
|
||||
* @return the lower bound of this wildcard
|
||||
*/
|
||||
TypeMirror getSuperBound();
|
||||
}
|
||||
41
jdkSrc/jdk8/javax/lang/model/type/package-info.java
Normal file
41
jdkSrc/jdk8/javax/lang/model/type/package-info.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces used to model Java programming language types.
|
||||
*
|
||||
* <p> Unless otherwise specified in a particular implementation, the
|
||||
* collections returned by methods in this package should be expected
|
||||
* to be unmodifiable by the caller and unsafe for concurrent access.
|
||||
*
|
||||
* <p> Unless otherwise specified, methods in this package will throw
|
||||
* a {@code NullPointerException} if given a {@code null} argument.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
package javax.lang.model.type;
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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 javax.lang.model.element.*;
|
||||
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
|
||||
/**
|
||||
* A skeletal visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see AbstractAnnotationValueVisitor7
|
||||
* @see AbstractAnnotationValueVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public abstract class AbstractAnnotationValueVisitor6<R, P>
|
||||
implements AnnotationValueVisitor<R, P> {
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractAnnotationValueVisitor6() {}
|
||||
|
||||
/**
|
||||
* Visits an annotation value as if by passing itself to that
|
||||
* value's {@link AnnotationValue#accept accept}. The invocation
|
||||
* {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}.
|
||||
* @param av {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
*/
|
||||
public final R visit(AnnotationValue av, P p) {
|
||||
return av.accept(this, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation value as if by passing itself to that
|
||||
* value's {@link AnnotationValue#accept accept} method passing
|
||||
* {@code null} for the additional parameter. The invocation
|
||||
* {@code v.visit(av)} is equivalent to {@code av.accept(v,
|
||||
* null)}.
|
||||
* @param av {@inheritDoc}
|
||||
*/
|
||||
public final R visit(AnnotationValue av) {
|
||||
return av.accept(this, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation of this method in {@code
|
||||
* AbstractAnnotationValueVisitor6} will always throw {@code
|
||||
* UnknownAnnotationValueException}. This behavior is not
|
||||
* required of a subclass.
|
||||
*
|
||||
* @param av {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
*/
|
||||
public R visitUnknown(AnnotationValue av, P p) {
|
||||
throw new UnknownAnnotationValueException(av, p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
|
||||
/**
|
||||
* A skeletal visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @see AbstractAnnotationValueVisitor6
|
||||
* @see AbstractAnnotationValueVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public abstract class AbstractAnnotationValueVisitor7<R, P> extends AbstractAnnotationValueVisitor6<R, P> {
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractAnnotationValueVisitor7() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
|
||||
/**
|
||||
* A skeletal visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @see AbstractAnnotationValueVisitor6
|
||||
* @see AbstractAnnotationValueVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public abstract class AbstractAnnotationValueVisitor8<R, P> extends AbstractAnnotationValueVisitor7<R, P> {
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractAnnotationValueVisitor8() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
131
jdkSrc/jdk8/javax/lang/model/util/AbstractElementVisitor6.java
Normal file
131
jdkSrc/jdk8/javax/lang/model/util/AbstractElementVisitor6.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A skeletal visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see AbstractElementVisitor7
|
||||
* @see AbstractElementVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public abstract class AbstractElementVisitor6<R, P> implements ElementVisitor<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractElementVisitor6(){}
|
||||
|
||||
/**
|
||||
* Visits any program element as if by passing itself to that
|
||||
* element's {@link Element#accept accept} method. The invocation
|
||||
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
|
||||
* p)}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
public final R visit(Element e, P p) {
|
||||
return e.accept(this, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits any program element as if by passing itself to that
|
||||
* element's {@link Element#accept accept} method and passing
|
||||
* {@code null} for the additional parameter. The invocation
|
||||
* {@code v.visit(elem)} is equivalent to {@code elem.accept(v,
|
||||
* null)}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
public final R visit(Element e) {
|
||||
return e.accept(this, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p> The default implementation of this method in
|
||||
* {@code AbstractElementVisitor6} will always throw
|
||||
* {@code UnknownElementException}.
|
||||
* This behavior is not required of a subclass.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
* @throws UnknownElementException
|
||||
* a visitor implementation may optionally throw this exception
|
||||
*/
|
||||
public R visitUnknown(Element e, P p) {
|
||||
throw new UnknownElementException(e, p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A skeletal visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see AbstractElementVisitor6
|
||||
* @see AbstractElementVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public abstract class AbstractElementVisitor7<R, P> extends AbstractElementVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractElementVisitor7(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A skeletal visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see AbstractElementVisitor6
|
||||
* @see AbstractElementVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public abstract class AbstractElementVisitor8<R, P> extends AbstractElementVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractElementVisitor8(){
|
||||
super();
|
||||
}
|
||||
}
|
||||
152
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor6.java
Normal file
152
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor6.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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 javax.lang.model.type.*;
|
||||
|
||||
/**
|
||||
* A skeletal visitor of types with default behavior appropriate for
|
||||
* the {@link javax.lang.model.SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see AbstractTypeVisitor7
|
||||
* @see AbstractTypeVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractTypeVisitor6() {}
|
||||
|
||||
/**
|
||||
* Visits any type mirror as if by passing itself to that type
|
||||
* mirror's {@link TypeMirror#accept accept} method. The
|
||||
* invocation {@code v.visit(t, p)} is equivalent to {@code
|
||||
* t.accept(v, p)}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
public final R visit(TypeMirror t, P p) {
|
||||
return t.accept(this, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits any type mirror as if by passing itself to that type
|
||||
* mirror's {@link TypeMirror#accept accept} method and passing
|
||||
* {@code null} for the additional parameter. The invocation
|
||||
* {@code v.visit(t)} is equivalent to {@code t.accept(v, null)}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @return a visitor-specified result
|
||||
*/
|
||||
public final R visit(TypeMirror t) {
|
||||
return t.accept(this, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code UnionType} element by calling {@code
|
||||
* visitUnknown}.
|
||||
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code visitUnknown}
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public R visitUnion(UnionType t, P p) {
|
||||
return visitUnknown(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code IntersectionType} element by calling {@code
|
||||
* visitUnknown}.
|
||||
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code visitUnknown}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public R visitIntersection(IntersectionType t, P p) {
|
||||
return visitUnknown(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p> The default implementation of this method in {@code
|
||||
* AbstractTypeVisitor6} will always throw {@code
|
||||
* UnknownTypeException}. This behavior is not required of a
|
||||
* subclass.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @return a visitor-specified result
|
||||
* @throws UnknownTypeException
|
||||
* a visitor implementation may optionally throw this exception
|
||||
*/
|
||||
public R visitUnknown(TypeMirror t, P p) {
|
||||
throw new UnknownTypeException(t, p);
|
||||
}
|
||||
}
|
||||
87
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor7.java
Normal file
87
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor7.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.lang.model.type.*;
|
||||
|
||||
/**
|
||||
* A skeletal visitor of types with default behavior appropriate for
|
||||
* the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see AbstractTypeVisitor6
|
||||
* @see AbstractTypeVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractTypeVisitor7() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code UnionType} in a manner defined by a subclass.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the visit as defined by a subclass
|
||||
*/
|
||||
public abstract R visitUnion(UnionType t, P p);
|
||||
}
|
||||
87
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor8.java
Normal file
87
jdkSrc/jdk8/javax/lang/model/util/AbstractTypeVisitor8.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.lang.model.type.*;
|
||||
|
||||
/**
|
||||
* A skeletal visitor of types with default behavior appropriate for
|
||||
* the {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see AbstractTypeVisitor6
|
||||
* @see AbstractTypeVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
public abstract class AbstractTypeVisitor8<R, P> extends AbstractTypeVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call.
|
||||
*/
|
||||
protected AbstractTypeVisitor8() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code IntersectionType} in a manner defined by a subclass.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the visit as defined by a subclass
|
||||
*/
|
||||
public abstract R visitIntersection(IntersectionType t, P p);
|
||||
}
|
||||
210
jdkSrc/jdk8/javax/lang/model/util/ElementFilter.java
Normal file
210
jdkSrc/jdk8/javax/lang/model/util/ElementFilter.java
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, 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.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import javax.lang.model.element.*;
|
||||
|
||||
|
||||
/**
|
||||
* Filters for selecting just the elements of interest from a
|
||||
* collection of elements. The returned sets and lists are new
|
||||
* collections and do use the argument as a backing store. The
|
||||
* methods in this class do not make any attempts to guard against
|
||||
* concurrent modifications of the arguments. The returned sets and
|
||||
* lists are mutable but unsafe for concurrent access. A returned set
|
||||
* has the same iteration order as the argument set to a method.
|
||||
*
|
||||
* <p>If iterables and sets containing {@code null} are passed as
|
||||
* arguments to methods in this class, a {@code NullPointerException}
|
||||
* will be thrown.
|
||||
*
|
||||
* <p>Note that a <i>static import</i> statement can make the text of
|
||||
* calls to the methods in this class more concise; for example:
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* import static javax.lang.model.util.ElementFilter.*;
|
||||
* ...
|
||||
* {@code List<VariableElement>} fs = fieldsIn(someClass.getEnclosedElements());
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @author Martin Buchholz
|
||||
* @since 1.6
|
||||
*/
|
||||
public class ElementFilter {
|
||||
private ElementFilter() {} // Do not instantiate.
|
||||
|
||||
private static final Set<ElementKind> CONSTRUCTOR_KIND =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
|
||||
|
||||
private static final Set<ElementKind> FIELD_KINDS =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
|
||||
ElementKind.ENUM_CONSTANT));
|
||||
private static final Set<ElementKind> METHOD_KIND =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
|
||||
|
||||
private static final Set<ElementKind> PACKAGE_KIND =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
|
||||
|
||||
private static final Set<ElementKind> TYPE_KINDS =
|
||||
Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
|
||||
ElementKind.ENUM,
|
||||
ElementKind.INTERFACE,
|
||||
ElementKind.ANNOTATION_TYPE));
|
||||
/**
|
||||
* Returns a list of fields in {@code elements}.
|
||||
* @return a list of fields in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static List<VariableElement>
|
||||
fieldsIn(Iterable<? extends Element> elements) {
|
||||
return listFilter(elements, FIELD_KINDS, VariableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of fields in {@code elements}.
|
||||
* @return a set of fields in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static Set<VariableElement>
|
||||
fieldsIn(Set<? extends Element> elements) {
|
||||
return setFilter(elements, FIELD_KINDS, VariableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of constructors in {@code elements}.
|
||||
* @return a list of constructors in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static List<ExecutableElement>
|
||||
constructorsIn(Iterable<? extends Element> elements) {
|
||||
return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of constructors in {@code elements}.
|
||||
* @return a set of constructors in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static Set<ExecutableElement>
|
||||
constructorsIn(Set<? extends Element> elements) {
|
||||
return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of methods in {@code elements}.
|
||||
* @return a list of methods in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static List<ExecutableElement>
|
||||
methodsIn(Iterable<? extends Element> elements) {
|
||||
return listFilter(elements, METHOD_KIND, ExecutableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of methods in {@code elements}.
|
||||
* @return a set of methods in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static Set<ExecutableElement>
|
||||
methodsIn(Set<? extends Element> elements) {
|
||||
return setFilter(elements, METHOD_KIND, ExecutableElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of types in {@code elements}.
|
||||
* @return a list of types in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static List<TypeElement>
|
||||
typesIn(Iterable<? extends Element> elements) {
|
||||
return listFilter(elements, TYPE_KINDS, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of types in {@code elements}.
|
||||
* @return a set of types in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static Set<TypeElement>
|
||||
typesIn(Set<? extends Element> elements) {
|
||||
return setFilter(elements, TYPE_KINDS, TypeElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of packages in {@code elements}.
|
||||
* @return a list of packages in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static List<PackageElement>
|
||||
packagesIn(Iterable<? extends Element> elements) {
|
||||
return listFilter(elements, PACKAGE_KIND, PackageElement.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of packages in {@code elements}.
|
||||
* @return a set of packages in {@code elements}
|
||||
* @param elements the elements to filter
|
||||
*/
|
||||
public static Set<PackageElement>
|
||||
packagesIn(Set<? extends Element> elements) {
|
||||
return setFilter(elements, PACKAGE_KIND, PackageElement.class);
|
||||
}
|
||||
|
||||
// Assumes targetKinds and E are sensible.
|
||||
private static <E extends Element> List<E> listFilter(Iterable<? extends Element> elements,
|
||||
Set<ElementKind> targetKinds,
|
||||
Class<E> clazz) {
|
||||
List<E> list = new ArrayList<E>();
|
||||
for (Element e : elements) {
|
||||
if (targetKinds.contains(e.getKind()))
|
||||
list.add(clazz.cast(e));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// Assumes targetKinds and E are sensible.
|
||||
private static <E extends Element> Set<E> setFilter(Set<? extends Element> elements,
|
||||
Set<ElementKind> targetKinds,
|
||||
Class<E> clazz) {
|
||||
// Return set preserving iteration order of input set.
|
||||
Set<E> set = new LinkedHashSet<E>();
|
||||
for (Element e : elements) {
|
||||
if (targetKinds.contains(e.getKind()))
|
||||
set.add(clazz.cast(e));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
413
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor6.java
Normal file
413
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor6.java
Normal file
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
* 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 javax.lang.model.element.*;
|
||||
import static javax.lang.model.element.ElementKind.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
|
||||
/**
|
||||
* A visitor of program elements based on their {@linkplain
|
||||
* ElementKind kind} with default behavior appropriate for the {@link
|
||||
* SourceVersion#RELEASE_6 RELEASE_6} source version. For {@linkplain
|
||||
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it or the
|
||||
* {@code ElementKind} {@code enum} used in this case may have
|
||||
* constants added to it in the future to accommodate new, currently
|
||||
* unknown, language structures added to future versions of the
|
||||
* Java™ programming language. Therefore, methods whose names
|
||||
* begin with {@code "visit"} may be added to this class in the
|
||||
* future; to avoid incompatibilities, classes which extend this class
|
||||
* should not declare any instance methods with names beginning with
|
||||
* {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element kind
|
||||
* visitor class will also be introduced to correspond to the new
|
||||
* language level; this visitor will have different default behavior
|
||||
* for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see ElementKindVisitor7
|
||||
* @see ElementKindVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class ElementKindVisitor6<R, P>
|
||||
extends SimpleElementVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementKindVisitor6() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected ElementKindVisitor6(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* The element argument has kind {@code PACKAGE}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public R visitPackage(PackageElement e, P p) {
|
||||
assert e.getKind() == PACKAGE: "Bad kind on PackageElement";
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type element, dispatching to the visit method for the
|
||||
* specific {@linkplain ElementKind kind} of type, {@code
|
||||
* ANNOTATION_TYPE}, {@code CLASS}, {@code ENUM}, or {@code
|
||||
* INTERFACE}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the kind-specific visit method
|
||||
*/
|
||||
@Override
|
||||
public R visitType(TypeElement e, P p) {
|
||||
ElementKind k = e.getKind();
|
||||
switch(k) {
|
||||
case ANNOTATION_TYPE:
|
||||
return visitTypeAsAnnotationType(e, p);
|
||||
|
||||
case CLASS:
|
||||
return visitTypeAsClass(e, p);
|
||||
|
||||
case ENUM:
|
||||
return visitTypeAsEnum(e, p);
|
||||
|
||||
case INTERFACE:
|
||||
return visitTypeAsInterface(e, p);
|
||||
|
||||
default:
|
||||
throw new AssertionError("Bad kind " + k + " for TypeElement" + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code ANNOTATION_TYPE} type element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeAsAnnotationType(TypeElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code CLASS} type element by calling {@code
|
||||
* defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeAsClass(TypeElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code ENUM} type element by calling {@code
|
||||
* defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeAsEnum(TypeElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code INTERFACE} type element by calling {@code
|
||||
* defaultAction}.
|
||||
*.
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeAsInterface(TypeElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a variable element, dispatching to the visit method for
|
||||
* the specific {@linkplain ElementKind kind} of variable, {@code
|
||||
* ENUM_CONSTANT}, {@code EXCEPTION_PARAMETER}, {@code FIELD},
|
||||
* {@code LOCAL_VARIABLE}, {@code PARAMETER}, or {@code RESOURCE_VARIABLE}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the kind-specific visit method
|
||||
*/
|
||||
@Override
|
||||
public R visitVariable(VariableElement e, P p) {
|
||||
ElementKind k = e.getKind();
|
||||
switch(k) {
|
||||
case ENUM_CONSTANT:
|
||||
return visitVariableAsEnumConstant(e, p);
|
||||
|
||||
case EXCEPTION_PARAMETER:
|
||||
return visitVariableAsExceptionParameter(e, p);
|
||||
|
||||
case FIELD:
|
||||
return visitVariableAsField(e, p);
|
||||
|
||||
case LOCAL_VARIABLE:
|
||||
return visitVariableAsLocalVariable(e, p);
|
||||
|
||||
case PARAMETER:
|
||||
return visitVariableAsParameter(e, p);
|
||||
|
||||
case RESOURCE_VARIABLE:
|
||||
return visitVariableAsResourceVariable(e, p);
|
||||
|
||||
default:
|
||||
throw new AssertionError("Bad kind " + k + " for VariableElement" + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code ENUM_CONSTANT} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitVariableAsEnumConstant(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code EXCEPTION_PARAMETER} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitVariableAsExceptionParameter(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code FIELD} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitVariableAsField(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code LOCAL_VARIABLE} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitVariableAsLocalVariable(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code PARAMETER} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitVariableAsParameter(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
|
||||
* {@code visitUnknown}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code visitUnknown}
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public R visitVariableAsResourceVariable(VariableElement e, P p) {
|
||||
return visitUnknown(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an executable element, dispatching to the visit method
|
||||
* for the specific {@linkplain ElementKind kind} of executable,
|
||||
* {@code CONSTRUCTOR}, {@code INSTANCE_INIT}, {@code METHOD}, or
|
||||
* {@code STATIC_INIT}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the kind-specific visit method
|
||||
*/
|
||||
@Override
|
||||
public R visitExecutable(ExecutableElement e, P p) {
|
||||
ElementKind k = e.getKind();
|
||||
switch(k) {
|
||||
case CONSTRUCTOR:
|
||||
return visitExecutableAsConstructor(e, p);
|
||||
|
||||
case INSTANCE_INIT:
|
||||
return visitExecutableAsInstanceInit(e, p);
|
||||
|
||||
case METHOD:
|
||||
return visitExecutableAsMethod(e, p);
|
||||
|
||||
case STATIC_INIT:
|
||||
return visitExecutableAsStaticInit(e, p);
|
||||
|
||||
default:
|
||||
throw new AssertionError("Bad kind " + k + " for ExecutableElement" + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code CONSTRUCTOR} executable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutableAsConstructor(ExecutableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code INSTANCE_INIT} executable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutableAsInstanceInit(ExecutableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code METHOD} executable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutableAsMethod(ExecutableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code STATIC_INIT} executable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e the element to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutableAsStaticInit(ExecutableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* The element argument has kind {@code TYPE_PARAMETER}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public R visitTypeParameter(TypeParameterElement e, P p) {
|
||||
assert e.getKind() == TYPE_PARAMETER: "Bad kind on TypeParameterElement";
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
}
|
||||
119
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor7.java
Normal file
119
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor7.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.*;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A visitor of program elements based on their {@linkplain
|
||||
* ElementKind kind} with default behavior appropriate for the {@link
|
||||
* SourceVersion#RELEASE_7 RELEASE_7} source version. For {@linkplain
|
||||
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it or the
|
||||
* {@code ElementKind} {@code enum} used in this case may have
|
||||
* constants added to it in the future to accommodate new, currently
|
||||
* unknown, language structures added to future versions of the
|
||||
* Java™ programming language. Therefore, methods whose names
|
||||
* begin with {@code "visit"} may be added to this class in the
|
||||
* future; to avoid incompatibilities, classes which extend this class
|
||||
* should not declare any instance methods with names beginning with
|
||||
* {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element kind
|
||||
* visitor class will also be introduced to correspond to the new
|
||||
* language level; this visitor will have different default behavior
|
||||
* for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see ElementKindVisitor6
|
||||
* @see ElementKindVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class ElementKindVisitor7<R, P> extends ElementKindVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementKindVisitor7() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected ElementKindVisitor7(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code RESOURCE_VARIABLE} variable element by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitVariableAsResourceVariable(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor8.java
Normal file
106
jdkSrc/jdk8/javax/lang/model/util/ElementKindVisitor8.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
/**
|
||||
* A visitor of program elements based on their {@linkplain
|
||||
* ElementKind kind} with default behavior appropriate for the {@link
|
||||
* SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain
|
||||
* Element elements} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it or the
|
||||
* {@code ElementKind} {@code enum} used in this case may have
|
||||
* constants added to it in the future to accommodate new, currently
|
||||
* unknown, language structures added to future versions of the
|
||||
* Java™ programming language. Therefore, methods whose names
|
||||
* begin with {@code "visit"} may be added to this class in the
|
||||
* future; to avoid incompatibilities, classes which extend this class
|
||||
* should not declare any instance methods with names beginning with
|
||||
* {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new abstract element kind
|
||||
* visitor class will also be introduced to correspond to the new
|
||||
* language level; this visitor will have different default behavior
|
||||
* for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see ElementKindVisitor6
|
||||
* @see ElementKindVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class ElementKindVisitor8<R, P> extends ElementKindVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementKindVisitor8() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected ElementKindVisitor8(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
}
|
||||
220
jdkSrc/jdk8/javax/lang/model/util/ElementScanner6.java
Normal file
220
jdkSrc/jdk8/javax/lang/model/util/ElementScanner6.java
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A scanning visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
|
||||
* class scan their component elements by calling {@code scan} on
|
||||
* their {@linkplain Element#getEnclosedElements enclosed elements},
|
||||
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
|
||||
* indicated in the individual method specifications. A subclass can
|
||||
* control the order elements are visited by overriding the
|
||||
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
|
||||
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
|
||||
* than {@code v.visit(e, p)} on the root objects of interest.
|
||||
*
|
||||
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
|
||||
* new method can cause the enclosed elements to be scanned in the
|
||||
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
|
||||
* fashion, the concrete visitor can control the ordering of traversal
|
||||
* over the component elements with respect to the additional
|
||||
* processing; for example, consistently calling
|
||||
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
|
||||
* methods will yield a preorder traversal, etc. If the component
|
||||
* elements should be traversed in some other order, instead of
|
||||
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
|
||||
* should call {@code scan} with the elements in the desired order.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new element scanner visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see ElementScanner7
|
||||
* @see ElementScanner8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
|
||||
/**
|
||||
* The specified default value.
|
||||
*/
|
||||
protected final R DEFAULT_VALUE;
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementScanner6(){
|
||||
DEFAULT_VALUE = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
protected ElementScanner6(R defaultValue){
|
||||
DEFAULT_VALUE = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over the given elements and calls {@link
|
||||
* #scan(Element, Object) scan(Element, P)} on each one. Returns
|
||||
* the result of the last call to {@code scan} or {@code
|
||||
* DEFAULT_VALUE} for an empty iterable.
|
||||
*
|
||||
* @param iterable the elements to scan
|
||||
* @param p additional parameter
|
||||
* @return the scan of the last element or {@code DEFAULT_VALUE} if no elements
|
||||
*/
|
||||
public final R scan(Iterable<? extends Element> iterable, P p) {
|
||||
R result = DEFAULT_VALUE;
|
||||
for(Element e : iterable)
|
||||
result = scan(e, p);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an element by calling {@code e.accept(this, p)};
|
||||
* this method may be overridden by subclasses.
|
||||
*
|
||||
* @param e the element to scan
|
||||
* @param p a scanner-specified parameter
|
||||
* @return the result of visiting {@code e}.
|
||||
*/
|
||||
public R scan(Element e, P p) {
|
||||
return e.accept(this, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method equivalent to {@code v.scan(e, null)}.
|
||||
*
|
||||
* @param e the element to scan
|
||||
* @return the result of scanning {@code e}.
|
||||
*/
|
||||
public final R scan(Element e) {
|
||||
return scan(e, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation scans the enclosed elements.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
public R visitPackage(PackageElement e, P p) {
|
||||
return scan(e.getEnclosedElements(), p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation scans the enclosed elements.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
public R visitType(TypeElement e, P p) {
|
||||
return scan(e.getEnclosedElements(), p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This implementation scans the enclosed elements, unless the
|
||||
* element is a {@code RESOURCE_VARIABLE} in which case {@code
|
||||
* visitUnknown} is called.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
public R visitVariable(VariableElement e, P p) {
|
||||
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
|
||||
return scan(e.getEnclosedElements(), p);
|
||||
else
|
||||
return visitUnknown(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation scans the parameters.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
public R visitExecutable(ExecutableElement e, P p) {
|
||||
return scan(e.getParameters(), p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation scans the enclosed elements.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
public R visitTypeParameter(TypeParameterElement e, P p) {
|
||||
return scan(e.getEnclosedElements(), p);
|
||||
}
|
||||
}
|
||||
122
jdkSrc/jdk8/javax/lang/model/util/ElementScanner7.java
Normal file
122
jdkSrc/jdk8/javax/lang/model/util/ElementScanner7.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A scanning visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
|
||||
* class scan their component elements by calling {@code scan} on
|
||||
* their {@linkplain Element#getEnclosedElements enclosed elements},
|
||||
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
|
||||
* indicated in the individual method specifications. A subclass can
|
||||
* control the order elements are visited by overriding the
|
||||
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
|
||||
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
|
||||
* than {@code v.visit(e, p)} on the root objects of interest.
|
||||
*
|
||||
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
|
||||
* new method can cause the enclosed elements to be scanned in the
|
||||
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
|
||||
* fashion, the concrete visitor can control the ordering of traversal
|
||||
* over the component elements with respect to the additional
|
||||
* processing; for example, consistently calling
|
||||
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
|
||||
* methods will yield a preorder traversal, etc. If the component
|
||||
* elements should be traversed in some other order, instead of
|
||||
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
|
||||
* should call {@code scan} with the elements in the desired order.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new element scanner visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see ElementScanner6
|
||||
* @see ElementScanner8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementScanner7(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
protected ElementScanner7(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation scans the enclosed elements.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of scanning
|
||||
*/
|
||||
@Override
|
||||
public R visitVariable(VariableElement e, P p) {
|
||||
return scan(e.getEnclosedElements(), p);
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/javax/lang/model/util/ElementScanner8.java
Normal file
110
jdkSrc/jdk8/javax/lang/model/util/ElementScanner8.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A scanning visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version. The <tt>visit<i>XYZ</i></tt> methods in this
|
||||
* class scan their component elements by calling {@code scan} on
|
||||
* their {@linkplain Element#getEnclosedElements enclosed elements},
|
||||
* {@linkplain ExecutableElement#getParameters parameters}, etc., as
|
||||
* indicated in the individual method specifications. A subclass can
|
||||
* control the order elements are visited by overriding the
|
||||
* <tt>visit<i>XYZ</i></tt> methods. Note that clients of a scanner
|
||||
* may get the desired behavior be invoking {@code v.scan(e, p)} rather
|
||||
* than {@code v.visit(e, p)} on the root objects of interest.
|
||||
*
|
||||
* <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
|
||||
* new method can cause the enclosed elements to be scanned in the
|
||||
* default way by calling <tt>super.visit<i>XYZ</i></tt>. In this
|
||||
* fashion, the concrete visitor can control the ordering of traversal
|
||||
* over the component elements with respect to the additional
|
||||
* processing; for example, consistently calling
|
||||
* <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
|
||||
* methods will yield a preorder traversal, etc. If the component
|
||||
* elements should be traversed in some other order, instead of
|
||||
* calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
|
||||
* should call {@code scan} with the elements in the desired order.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new element scanner visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see ElementScanner6
|
||||
* @see ElementScanner7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class ElementScanner8<R, P> extends ElementScanner7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected ElementScanner8(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the default value
|
||||
*/
|
||||
protected ElementScanner8(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
}
|
||||
264
jdkSrc/jdk8/javax/lang/model/util/Elements.java
Normal file
264
jdkSrc/jdk8/javax/lang/model/util/Elements.java
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* 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.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.lang.model.element.*;
|
||||
import javax.lang.model.type.*;
|
||||
|
||||
|
||||
/**
|
||||
* Utility methods for operating on program elements.
|
||||
*
|
||||
* <p><b>Compatibility Note:</b> 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#getElementUtils
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Elements {
|
||||
|
||||
/**
|
||||
* Returns a package given its fully qualified name.
|
||||
*
|
||||
* @param name fully qualified package name, or "" for an unnamed package
|
||||
* @return the named package, or {@code null} if it cannot be found
|
||||
*/
|
||||
PackageElement getPackageElement(CharSequence name);
|
||||
|
||||
/**
|
||||
* Returns a type element given its canonical name.
|
||||
*
|
||||
* @param name the canonical name
|
||||
* @return the named type element, or {@code null} if it cannot be found
|
||||
*/
|
||||
TypeElement getTypeElement(CharSequence name);
|
||||
|
||||
/**
|
||||
* Returns the values of an annotation's elements, including defaults.
|
||||
*
|
||||
* @see AnnotationMirror#getElementValues()
|
||||
* @param a annotation to examine
|
||||
* @return the values of the annotation's elements, including defaults
|
||||
*/
|
||||
Map<? extends ExecutableElement, ? extends AnnotationValue>
|
||||
getElementValuesWithDefaults(AnnotationMirror a);
|
||||
|
||||
/**
|
||||
* Returns the text of the documentation ("Javadoc")
|
||||
* comment of an element.
|
||||
*
|
||||
* <p> A documentation comment of an element is a comment that
|
||||
* begins with "{@code /**}" , ends with a separate
|
||||
* "<code>*/</code>", and immediately precedes the element,
|
||||
* ignoring white space. Therefore, a documentation comment
|
||||
* contains at least three"{@code *}" characters. The text
|
||||
* returned for the documentation comment is a processed form of
|
||||
* the comment as it appears in source code. The leading "{@code
|
||||
* /**}" and trailing "<code>*/</code>" are removed. For lines
|
||||
* of the comment starting after the initial "{@code /**}",
|
||||
* leading white space characters are discarded as are any
|
||||
* consecutive "{@code *}" characters appearing after the white
|
||||
* space or starting the line. The processed lines are then
|
||||
* concatenated together (including line terminators) and
|
||||
* returned.
|
||||
*
|
||||
* @param e the element being examined
|
||||
* @return the documentation comment of the element, or {@code null}
|
||||
* if there is none
|
||||
* @jls 3.6 White Space
|
||||
*/
|
||||
String getDocComment(Element e);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the element is deprecated, {@code false} otherwise.
|
||||
*
|
||||
* @param e the element being examined
|
||||
* @return {@code true} if the element is deprecated, {@code false} otherwise
|
||||
*/
|
||||
boolean isDeprecated(Element e);
|
||||
|
||||
/**
|
||||
* Returns the <i>binary name</i> of a type element.
|
||||
*
|
||||
* @param type the type element being examined
|
||||
* @return the binary name
|
||||
*
|
||||
* @see TypeElement#getQualifiedName
|
||||
* @jls 13.1 The Form of a Binary
|
||||
*/
|
||||
Name getBinaryName(TypeElement type);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the package of an element. The package of a package is
|
||||
* itself.
|
||||
*
|
||||
* @param type the element being examined
|
||||
* @return the package of an element
|
||||
*/
|
||||
PackageElement getPackageOf(Element type);
|
||||
|
||||
/**
|
||||
* Returns all members of a type element, whether inherited or
|
||||
* declared directly. For a class the result also includes its
|
||||
* constructors, but not local or anonymous classes.
|
||||
*
|
||||
* <p>Note that elements of certain kinds can be isolated using
|
||||
* methods in {@link ElementFilter}.
|
||||
*
|
||||
* @param type the type being examined
|
||||
* @return all members of the type
|
||||
* @see Element#getEnclosedElements
|
||||
*/
|
||||
List<? extends Element> getAllMembers(TypeElement type);
|
||||
|
||||
/**
|
||||
* Returns all annotations <i>present</i> on an element, whether
|
||||
* directly present or present via inheritance.
|
||||
*
|
||||
* @param e the element being examined
|
||||
* @return all annotations of the element
|
||||
* @see Element#getAnnotationMirrors
|
||||
* @see javax.lang.model.AnnotatedConstruct
|
||||
*/
|
||||
List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
|
||||
|
||||
/**
|
||||
* Tests whether one type, method, or field hides another.
|
||||
*
|
||||
* @param hider the first element
|
||||
* @param hidden the second element
|
||||
* @return {@code true} if and only if the first element hides
|
||||
* the second
|
||||
*/
|
||||
boolean hides(Element hider, Element hidden);
|
||||
|
||||
/**
|
||||
* Tests whether one method, as a member of a given type,
|
||||
* overrides another method.
|
||||
* When a non-abstract method overrides an abstract one, the
|
||||
* former is also said to <i>implement</i> the latter.
|
||||
*
|
||||
* <p> In the simplest and most typical usage, the value of the
|
||||
* {@code type} parameter will simply be the class or interface
|
||||
* directly enclosing {@code overrider} (the possibly-overriding
|
||||
* method). For example, suppose {@code m1} represents the method
|
||||
* {@code String.hashCode} and {@code m2} represents {@code
|
||||
* Object.hashCode}. We can then ask whether {@code m1} overrides
|
||||
* {@code m2} within the class {@code String} (it does):
|
||||
*
|
||||
* <blockquote>
|
||||
* {@code assert elements.overrides(m1, m2,
|
||||
* elements.getTypeElement("java.lang.String")); }
|
||||
* </blockquote>
|
||||
*
|
||||
* A more interesting case can be illustrated by the following example
|
||||
* in which a method in type {@code A} does not override a
|
||||
* like-named method in type {@code B}:
|
||||
*
|
||||
* <blockquote>
|
||||
* {@code class A { public void m() {} } }<br>
|
||||
* {@code interface B { void m(); } }<br>
|
||||
* ...<br>
|
||||
* {@code m1 = ...; // A.m }<br>
|
||||
* {@code m2 = ...; // B.m }<br>
|
||||
* {@code assert ! elements.overrides(m1, m2,
|
||||
* elements.getTypeElement("A")); }
|
||||
* </blockquote>
|
||||
*
|
||||
* When viewed as a member of a third type {@code C}, however,
|
||||
* the method in {@code A} does override the one in {@code B}:
|
||||
*
|
||||
* <blockquote>
|
||||
* {@code class C extends A implements B {} }<br>
|
||||
* ...<br>
|
||||
* {@code assert elements.overrides(m1, m2,
|
||||
* elements.getTypeElement("C")); }
|
||||
* </blockquote>
|
||||
*
|
||||
* @param overrider the first method, possible overrider
|
||||
* @param overridden the second method, possibly being overridden
|
||||
* @param type the type of which the first method is a member
|
||||
* @return {@code true} if and only if the first method overrides
|
||||
* the second
|
||||
* @jls 8.4.8 Inheritance, Overriding, and Hiding
|
||||
* @jls 9.4.1 Inheritance and Overriding
|
||||
*/
|
||||
boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
|
||||
TypeElement type);
|
||||
|
||||
/**
|
||||
* Returns the text of a <i>constant expression</i> representing a
|
||||
* primitive value or a string.
|
||||
* The text returned is in a form suitable for representing the value
|
||||
* in source code.
|
||||
*
|
||||
* @param value a primitive value or string
|
||||
* @return the text of a constant expression
|
||||
* @throws IllegalArgumentException if the argument is not a primitive
|
||||
* value or string
|
||||
*
|
||||
* @see VariableElement#getConstantValue()
|
||||
*/
|
||||
String getConstantExpression(Object value);
|
||||
|
||||
/**
|
||||
* Prints a representation of the elements to the given writer in
|
||||
* the specified order. The main purpose of this method is for
|
||||
* diagnostics. The exact format of the output is <em>not</em>
|
||||
* specified and is subject to change.
|
||||
*
|
||||
* @param w the writer to print the output to
|
||||
* @param elements the elements to print
|
||||
*/
|
||||
void printElements(java.io.Writer w, Element... elements);
|
||||
|
||||
/**
|
||||
* Return a name with the same sequence of characters as the
|
||||
* argument.
|
||||
*
|
||||
* @param cs the character sequence to return as a name
|
||||
* @return a name with the same sequence of characters as the argument
|
||||
*/
|
||||
Name getName(CharSequence cs);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the type element is a functional interface, {@code false} otherwise.
|
||||
*
|
||||
* @param type the type element being examined
|
||||
* @return {@code true} if the element is a functional interface, {@code false} otherwise
|
||||
* @jls 9.8 Functional Interfaces
|
||||
* @since 1.8
|
||||
*/
|
||||
boolean isFunctionalInterface(TypeElement type);
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
/*
|
||||
* 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.util.List;
|
||||
import javax.lang.model.element.*;
|
||||
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
|
||||
/**
|
||||
* A simple visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version. Visit methods call {@link
|
||||
* #defaultAction} passing their arguments to {@code defaultAction}'s
|
||||
* corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see SimpleAnnotationValueVisitor7
|
||||
* @see SimpleAnnotationValueVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class SimpleAnnotationValueVisitor6<R, P>
|
||||
extends AbstractAnnotationValueVisitor6<R, P> {
|
||||
|
||||
/**
|
||||
* Default value to be returned; {@link #defaultAction
|
||||
* defaultAction} returns this value unless the method is
|
||||
* overridden.
|
||||
*/
|
||||
protected final R DEFAULT_VALUE;
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor6() {
|
||||
super();
|
||||
DEFAULT_VALUE = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor6(R defaultValue) {
|
||||
super();
|
||||
DEFAULT_VALUE = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action for visit methods. The implementation in
|
||||
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
|
||||
* commonly override this method.
|
||||
*
|
||||
* @param o the value of the annotation
|
||||
* @param p a visitor-specified parameter
|
||||
* @return {@code DEFAULT_VALUE} unless overridden
|
||||
*/
|
||||
protected R defaultAction(Object o, P p) {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param b {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitBoolean(boolean b, P p) {
|
||||
return defaultAction(b, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param b {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitByte(byte b, P p) {
|
||||
return defaultAction(b, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param c {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitChar(char c, P p) {
|
||||
return defaultAction(c, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param d {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitDouble(double d, P p) {
|
||||
return defaultAction(d, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param f {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitFloat(float f, P p) {
|
||||
return defaultAction(f, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param i {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitInt(int i, P p) {
|
||||
return defaultAction(i, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param i {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitLong(long i, P p) {
|
||||
return defaultAction(i, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param s {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitShort(short s, P p) {
|
||||
return defaultAction(s, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param s {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitString(String s, P p) {
|
||||
return defaultAction(s, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitType(TypeMirror t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param c {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitEnumConstant(VariableElement c, P p) {
|
||||
return defaultAction(c, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param a {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitAnnotation(AnnotationMirror a, P p) {
|
||||
return defaultAction(a, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param vals {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitArray(List<? extends AnnotationValue> vals, P p) {
|
||||
return defaultAction(vals, p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version. Visit methods call {@link #defaultAction
|
||||
* defaultAction} passing their arguments to {@code defaultAction}'s
|
||||
* corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @see SimpleAnnotationValueVisitor6
|
||||
* @see SimpleAnnotationValueVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class SimpleAnnotationValueVisitor7<R, P> extends SimpleAnnotationValueVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor7() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor7(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor for annotation values with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version. Visit methods call {@link #defaultAction
|
||||
* defaultAction} passing their arguments to {@code defaultAction}'s
|
||||
* corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple annotation
|
||||
* value visitor class will also be introduced to correspond to the
|
||||
* new language level; this visitor will have different default
|
||||
* behavior for the visit method in question. When the new visitor is
|
||||
* introduced, all or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods
|
||||
* @param <P> the type of the additional parameter to this visitor's methods.
|
||||
*
|
||||
* @see SimpleAnnotationValueVisitor6
|
||||
* @see SimpleAnnotationValueVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class SimpleAnnotationValueVisitor8<R, P> extends SimpleAnnotationValueVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor8() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleAnnotationValueVisitor8(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
}
|
||||
190
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor6.java
Normal file
190
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor6.java
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A simple visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6}
|
||||
* source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_6} language
|
||||
* constructs call {@link #defaultAction defaultAction}, passing their
|
||||
* arguments to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* For constructs introduced in {@code RELEASE_7} and later, {@code
|
||||
* visitUnknown} is called instead.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need an additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see SimpleElementVisitor7
|
||||
* @see SimpleElementVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class SimpleElementVisitor6<R, P> extends AbstractElementVisitor6<R, P> {
|
||||
/**
|
||||
* Default value to be returned; {@link #defaultAction
|
||||
* defaultAction} returns this value unless the method is
|
||||
* overridden.
|
||||
*/
|
||||
protected final R DEFAULT_VALUE;
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleElementVisitor6(){
|
||||
DEFAULT_VALUE = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleElementVisitor6(R defaultValue){
|
||||
DEFAULT_VALUE = defaultValue;
|
||||
}
|
||||
/**
|
||||
* The default action for visit methods. The implementation in
|
||||
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
|
||||
* commonly override this method.
|
||||
*
|
||||
* @param e the element to process
|
||||
* @param p a visitor-specified parameter
|
||||
* @return {@code DEFAULT_VALUE} unless overridden
|
||||
*/
|
||||
protected R defaultAction(Element e, P p) {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPackage(PackageElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitType(TypeElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This implementation calls {@code defaultAction}, unless the
|
||||
* element is a {@code RESOURCE_VARIABLE} in which case {@code
|
||||
* visitUnknown} is called.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction} or {@code visitUnknown}
|
||||
*/
|
||||
public R visitVariable(VariableElement e, P p) {
|
||||
if (e.getKind() != ElementKind.RESOURCE_VARIABLE)
|
||||
return defaultAction(e, p);
|
||||
else
|
||||
return visitUnknown(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutable(ExecutableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeParameter(TypeParameterElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
}
|
||||
114
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor7.java
Normal file
114
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor7.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.lang.model.element.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7}
|
||||
* source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_7} and earlier
|
||||
* language constructs call {@link #defaultAction defaultAction},
|
||||
* passing their arguments to {@code defaultAction}'s corresponding
|
||||
* parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need an additional parameter.
|
||||
*
|
||||
* @see SimpleElementVisitor6
|
||||
* @see SimpleElementVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class SimpleElementVisitor7<R, P> extends SimpleElementVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleElementVisitor7(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleElementVisitor7(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param e {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitVariable(VariableElement e, P p) {
|
||||
return defaultAction(e, p);
|
||||
}
|
||||
}
|
||||
101
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor8.java
Normal file
101
jdkSrc/jdk8/javax/lang/model/util/SimpleElementVisitor8.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor of program elements with default behavior
|
||||
* appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
|
||||
* source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_7} and earlier
|
||||
* language constructs call {@link #defaultAction defaultAction},
|
||||
* passing their arguments to {@code defaultAction}'s corresponding
|
||||
* parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code ElementVisitor} interface
|
||||
* implemented by this class may have methods added to it in the
|
||||
* future to accommodate new, currently unknown, language structures
|
||||
* added to future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple element visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
|
||||
* for visitors that do not need an additional parameter.
|
||||
*
|
||||
* @see SimpleElementVisitor6
|
||||
* @see SimpleElementVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class SimpleElementVisitor8<R, P> extends SimpleElementVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleElementVisitor8(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleElementVisitor8(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
}
|
||||
228
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor6.java
Normal file
228
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor6.java
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* 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 javax.lang.model.type.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
|
||||
/**
|
||||
* A simple visitor of types with default behavior appropriate for the
|
||||
* {@link SourceVersion#RELEASE_6 RELEASE_6} source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_6} language
|
||||
* constructs call {@link #defaultAction defaultAction}, passing their
|
||||
* arguments to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* For constructs introduced in {@code RELEASE_7} and later, {@code
|
||||
* visitUnknown} is called instead.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see SimpleTypeVisitor7
|
||||
* @see SimpleTypeVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class SimpleTypeVisitor6<R, P> extends AbstractTypeVisitor6<R, P> {
|
||||
/**
|
||||
* Default value to be returned; {@link #defaultAction
|
||||
* defaultAction} returns this value unless the method is
|
||||
* overridden.
|
||||
*/
|
||||
protected final R DEFAULT_VALUE;
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleTypeVisitor6(){
|
||||
DEFAULT_VALUE = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleTypeVisitor6(R defaultValue){
|
||||
DEFAULT_VALUE = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default action for visit methods. The implementation in
|
||||
* this class just returns {@link #DEFAULT_VALUE}; subclasses will
|
||||
* commonly override this method.
|
||||
*
|
||||
* @param e the type to process
|
||||
* @param p a visitor-specified parameter
|
||||
* @return {@code DEFAULT_VALUE} unless overridden
|
||||
*/
|
||||
protected R defaultAction(TypeMirror e, P p) {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitive(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitNull(NullType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitArray(ArrayType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitDeclared(DeclaredType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitError(ErrorType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitTypeVariable(TypeVariable t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitWildcard(WildcardType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitExecutable(ExecutableType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc} This implementation calls {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitNoType(NoType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
115
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor7.java
Normal file
115
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor7.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.lang.model.type.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor of types with default behavior appropriate for the
|
||||
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_7} and earlier
|
||||
* language constructs call {@link #defaultAction defaultAction},
|
||||
* passing their arguments to {@code defaultAction}'s corresponding
|
||||
* parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see SimpleTypeVisitor6
|
||||
* @see SimpleTypeVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class SimpleTypeVisitor7<R, P> extends SimpleTypeVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleTypeVisitor7(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleTypeVisitor7(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation visits a {@code UnionType} by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitUnion(UnionType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
115
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor8.java
Normal file
115
jdkSrc/jdk8/javax/lang/model/util/SimpleTypeVisitor8.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.type.IntersectionType;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A simple visitor of types with default behavior appropriate for the
|
||||
* {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
|
||||
*
|
||||
* Visit methods corresponding to {@code RELEASE_8} and earlier
|
||||
* language constructs call {@link #defaultAction defaultAction},
|
||||
* passing their arguments to {@code defaultAction}'s corresponding
|
||||
* parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new simple type visitor
|
||||
* class will also be introduced to correspond to the new language
|
||||
* level; this visitor will have different default behavior for the
|
||||
* visit method in question. When the new visitor is introduced, all
|
||||
* or portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see SimpleTypeVisitor6
|
||||
* @see SimpleTypeVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class SimpleTypeVisitor8<R, P> extends SimpleTypeVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses {@code null} for the
|
||||
* default value.
|
||||
*/
|
||||
protected SimpleTypeVisitor8(){
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses; uses the argument for the
|
||||
* default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected SimpleTypeVisitor8(R defaultValue){
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation visits an {@code IntersectionType} by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitIntersection(IntersectionType t, P p){
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
310
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor6.java
Normal file
310
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor6.java
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.type.*;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A visitor of types based on their {@linkplain TypeKind kind} with
|
||||
* default behavior appropriate for the {@link SourceVersion#RELEASE_6
|
||||
* RELEASE_6} source version. For {@linkplain
|
||||
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new type kind visitor class
|
||||
* will also be introduced to correspond to the new language level;
|
||||
* this visitor will have different default behavior for the visit
|
||||
* method in question. When the new visitor is introduced, all or
|
||||
* portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
*
|
||||
* @see TypeKindVisitor7
|
||||
* @see TypeKindVisitor8
|
||||
* @since 1.6
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_6)
|
||||
public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses {@code null}
|
||||
* for the default value.
|
||||
*/
|
||||
protected TypeKindVisitor6() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses the argument
|
||||
* for the default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected TypeKindVisitor6(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a primitive type, dispatching to the visit method for
|
||||
* the specific {@linkplain TypeKind kind} of primitive type:
|
||||
* {@code BOOLEAN}, {@code BYTE}, etc.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the kind-specific visit method
|
||||
*/
|
||||
@Override
|
||||
public R visitPrimitive(PrimitiveType t, P p) {
|
||||
TypeKind k = t.getKind();
|
||||
switch (k) {
|
||||
case BOOLEAN:
|
||||
return visitPrimitiveAsBoolean(t, p);
|
||||
|
||||
case BYTE:
|
||||
return visitPrimitiveAsByte(t, p);
|
||||
|
||||
case SHORT:
|
||||
return visitPrimitiveAsShort(t, p);
|
||||
|
||||
case INT:
|
||||
return visitPrimitiveAsInt(t, p);
|
||||
|
||||
case LONG:
|
||||
return visitPrimitiveAsLong(t, p);
|
||||
|
||||
case CHAR:
|
||||
return visitPrimitiveAsChar(t, p);
|
||||
|
||||
case FLOAT:
|
||||
return visitPrimitiveAsFloat(t, p);
|
||||
|
||||
case DOUBLE:
|
||||
return visitPrimitiveAsDouble(t, p);
|
||||
|
||||
default:
|
||||
throw new AssertionError("Bad kind " + k + " for PrimitiveType" + t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code BOOLEAN} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsBoolean(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code BYTE} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsByte(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code SHORT} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsShort(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an {@code INT} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsInt(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code LONG} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsLong(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code CHAR} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsChar(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code FLOAT} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsFloat(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@code DOUBLE} primitive type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitPrimitiveAsDouble(PrimitiveType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link NoType} instance, dispatching to the visit method for
|
||||
* the specific {@linkplain TypeKind kind} of pseudo-type:
|
||||
* {@code VOID}, {@code PACKAGE}, or {@code NONE}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of the kind-specific visit method
|
||||
*/
|
||||
@Override
|
||||
public R visitNoType(NoType t, P p) {
|
||||
TypeKind k = t.getKind();
|
||||
switch (k) {
|
||||
case VOID:
|
||||
return visitNoTypeAsVoid(t, p);
|
||||
|
||||
case PACKAGE:
|
||||
return visitNoTypeAsPackage(t, p);
|
||||
|
||||
case NONE:
|
||||
return visitNoTypeAsNone(t, p);
|
||||
|
||||
default:
|
||||
throw new AssertionError("Bad kind " + k + " for NoType" + t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link TypeKind#VOID VOID} pseudo-type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitNoTypeAsVoid(NoType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link TypeKind#PACKAGE PACKAGE} pseudo-type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitNoTypeAsPackage(NoType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a {@link TypeKind#NONE NONE} pseudo-type by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t the type to visit
|
||||
* @param p a visitor-specified parameter
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
public R visitNoTypeAsNone(NoType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
117
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor7.java
Normal file
117
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor7.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 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 javax.lang.model.type.*;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
/**
|
||||
* A visitor of types based on their {@linkplain TypeKind kind} with
|
||||
* default behavior appropriate for the {@link SourceVersion#RELEASE_7
|
||||
* RELEASE_7} source version. For {@linkplain
|
||||
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new type kind visitor class
|
||||
* will also be introduced to correspond to the new language level;
|
||||
* this visitor will have different default behavior for the visit
|
||||
* method in question. When the new visitor is introduced, all or
|
||||
* portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see TypeKindVisitor6
|
||||
* @see TypeKindVisitor8
|
||||
* @since 1.7
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_7)
|
||||
public class TypeKindVisitor7<R, P> extends TypeKindVisitor6<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses {@code null}
|
||||
* for the default value.
|
||||
*/
|
||||
protected TypeKindVisitor7() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses the argument
|
||||
* for the default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected TypeKindVisitor7(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation visits a {@code UnionType} by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitUnion(UnionType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
117
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor8.java
Normal file
117
jdkSrc/jdk8/javax/lang/model/util/TypeKindVisitor8.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.type.*;
|
||||
import static javax.lang.model.SourceVersion.*;
|
||||
|
||||
/**
|
||||
* A visitor of types based on their {@linkplain TypeKind kind} with
|
||||
* default behavior appropriate for the {@link SourceVersion#RELEASE_8
|
||||
* RELEASE_8} source version. For {@linkplain
|
||||
* TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
|
||||
* kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
|
||||
* to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
|
||||
* first argument's kind. The <tt>visit<i>XYZKind</i></tt> methods
|
||||
* call {@link #defaultAction defaultAction}, passing their arguments
|
||||
* to {@code defaultAction}'s corresponding parameters.
|
||||
*
|
||||
* <p> Methods in this class may be overridden subject to their
|
||||
* general contract. Note that annotating methods in concrete
|
||||
* subclasses with {@link java.lang.Override @Override} will help
|
||||
* ensure that methods are overridden as intended.
|
||||
*
|
||||
* <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
|
||||
* by this class may have methods added to it in the future to
|
||||
* accommodate new, currently unknown, language structures added to
|
||||
* future versions of the Java™ programming language.
|
||||
* Therefore, methods whose names begin with {@code "visit"} may be
|
||||
* added to this class in the future; to avoid incompatibilities,
|
||||
* classes which extend this class should not declare any instance
|
||||
* methods with names beginning with {@code "visit"}.
|
||||
*
|
||||
* <p>When such a new visit method is added, the default
|
||||
* implementation in this class will be to call the {@link
|
||||
* #visitUnknown visitUnknown} method. A new type kind visitor class
|
||||
* will also be introduced to correspond to the new language level;
|
||||
* this visitor will have different default behavior for the visit
|
||||
* method in question. When the new visitor is introduced, all or
|
||||
* portions of this visitor may be deprecated.
|
||||
*
|
||||
* <p>Note that adding a default implementation of a new visit method
|
||||
* in a visitor class will occur instead of adding a <em>default
|
||||
* method</em> directly in the visitor interface since a Java SE 8
|
||||
* language feature cannot be used to this version of the API since
|
||||
* this version is required to be runnable on Java SE 7
|
||||
* implementations. Future versions of the API that are only required
|
||||
* to run on Java SE 8 and later may take advantage of default methods
|
||||
* in this situation.
|
||||
*
|
||||
* @param <R> the return type of this visitor's methods. Use {@link
|
||||
* Void} for visitors that do not need to return results.
|
||||
* @param <P> the type of the additional parameter to this visitor's
|
||||
* methods. Use {@code Void} for visitors that do not need an
|
||||
* additional parameter.
|
||||
*
|
||||
* @see TypeKindVisitor6
|
||||
* @see TypeKindVisitor7
|
||||
* @since 1.8
|
||||
*/
|
||||
@SupportedSourceVersion(RELEASE_8)
|
||||
public class TypeKindVisitor8<R, P> extends TypeKindVisitor7<R, P> {
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses {@code null}
|
||||
* for the default value.
|
||||
*/
|
||||
protected TypeKindVisitor8() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for concrete subclasses to call; uses the argument
|
||||
* for the default value.
|
||||
*
|
||||
* @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
|
||||
*/
|
||||
protected TypeKindVisitor8(R defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation visits an {@code IntersectionType} by calling
|
||||
* {@code defaultAction}.
|
||||
*
|
||||
* @param t {@inheritDoc}
|
||||
* @param p {@inheritDoc}
|
||||
* @return the result of {@code defaultAction}
|
||||
*/
|
||||
@Override
|
||||
public R visitIntersection(IntersectionType t, P p) {
|
||||
return defaultAction(t, p);
|
||||
}
|
||||
}
|
||||
312
jdkSrc/jdk8/javax/lang/model/util/Types.java
Normal file
312
jdkSrc/jdk8/javax/lang/model/util/Types.java
Normal file
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* 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><b>Compatibility Note:</b> 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<Object>();}
|
||||
* {@code list.add(list.get(0));}
|
||||
* </pre>
|
||||
*
|
||||
* <p>Since annotations are only meta-data associated with a type,
|
||||
* the set of annotations on either argument is <em>not</em> taken
|
||||
* into account when computing whether or not two {@code
|
||||
* TypeMirror} objects are the same type. In particular, two
|
||||
* {@code TypeMirror} objects can have different annotations and
|
||||
* still be considered the same.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return {@code true} if and only if the two types are the same
|
||||
*/
|
||||
boolean isSameType(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Tests whether one type is a subtype of another.
|
||||
* Any type is considered to be a subtype of itself.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return {@code true} if and only if the first type is a subtype
|
||||
* of the second
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
* @jls 4.10 Subtyping
|
||||
*/
|
||||
boolean isSubtype(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Tests whether one type is assignable to another.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return {@code true} if and only if the first type is assignable
|
||||
* to the second
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
* @jls 5.2 Assignment Conversion
|
||||
*/
|
||||
boolean isAssignable(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Tests whether one type argument <i>contains</i> another.
|
||||
*
|
||||
* @param t1 the first type
|
||||
* @param t2 the second type
|
||||
* @return {@code true} if and only if the first type contains the second
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
* @jls 4.5.1.1 Type Argument Containment and Equivalence
|
||||
*/
|
||||
boolean contains(TypeMirror t1, TypeMirror t2);
|
||||
|
||||
/**
|
||||
* Tests whether the signature of one method is a <i>subsignature</i>
|
||||
* of another.
|
||||
*
|
||||
* @param m1 the first method
|
||||
* @param m2 the second method
|
||||
* @return {@code true} if and only if the first signature is a
|
||||
* subsignature of the second
|
||||
* @jls 8.4.2 Method Signature
|
||||
*/
|
||||
boolean isSubsignature(ExecutableType m1, ExecutableType m2);
|
||||
|
||||
/**
|
||||
* Returns the direct supertypes of a type. The interface types, if any,
|
||||
* will appear last in the list.
|
||||
*
|
||||
* @param t the type being examined
|
||||
* @return the direct supertypes, or an empty list if none
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
*/
|
||||
List<? extends TypeMirror> directSupertypes(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Returns the erasure of a type.
|
||||
*
|
||||
* @param t the type to be erased
|
||||
* @return the erasure of the given type
|
||||
* @throws IllegalArgumentException if given a package type
|
||||
* @jls 4.6 Type Erasure
|
||||
*/
|
||||
TypeMirror erasure(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Returns the class of a boxed value of a given primitive type.
|
||||
* That is, <i>boxing conversion</i> is applied.
|
||||
*
|
||||
* @param p the primitive type to be converted
|
||||
* @return the class of a boxed value of type {@code p}
|
||||
* @jls 5.1.7 Boxing Conversion
|
||||
*/
|
||||
TypeElement boxedClass(PrimitiveType p);
|
||||
|
||||
/**
|
||||
* Returns the type (a primitive type) of unboxed values of a given type.
|
||||
* That is, <i>unboxing conversion</i> is applied.
|
||||
*
|
||||
* @param t the type to be unboxed
|
||||
* @return the type of an unboxed value of type {@code t}
|
||||
* @throws IllegalArgumentException if the given type has no
|
||||
* unboxing conversion
|
||||
* @jls 5.1.8 Unboxing Conversion
|
||||
*/
|
||||
PrimitiveType unboxedType(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Applies capture conversion to a type.
|
||||
*
|
||||
* @param t the type to be converted
|
||||
* @return the result of applying capture conversion
|
||||
* @throws IllegalArgumentException if given an executable or package type
|
||||
* @jls 5.1.10 Capture Conversion
|
||||
*/
|
||||
TypeMirror capture(TypeMirror t);
|
||||
|
||||
/**
|
||||
* Returns a primitive type.
|
||||
*
|
||||
* @param kind the kind of primitive type to return
|
||||
* @return a primitive type
|
||||
* @throws IllegalArgumentException if {@code kind} is not a primitive kind
|
||||
*/
|
||||
PrimitiveType getPrimitiveType(TypeKind kind);
|
||||
|
||||
/**
|
||||
* Returns the null type. This is the type of {@code null}.
|
||||
*
|
||||
* @return the null type
|
||||
*/
|
||||
NullType getNullType();
|
||||
|
||||
/**
|
||||
* Returns a pseudo-type used where no actual type is appropriate.
|
||||
* The kind of type to return may be either
|
||||
* {@link TypeKind#VOID VOID} or {@link TypeKind#NONE NONE}.
|
||||
* For packages, use
|
||||
* {@link Elements#getPackageElement(CharSequence)}{@code .asType()}
|
||||
* instead.
|
||||
*
|
||||
* @param kind the kind of type to return
|
||||
* @return a pseudo-type of kind {@code VOID} or {@code NONE}
|
||||
* @throws IllegalArgumentException if {@code kind} is not valid
|
||||
*/
|
||||
NoType getNoType(TypeKind kind);
|
||||
|
||||
/**
|
||||
* Returns an array type with the specified component type.
|
||||
*
|
||||
* @param componentType the component type
|
||||
* @return an array type with the specified component type.
|
||||
* @throws IllegalArgumentException if the component type is not valid for
|
||||
* an array
|
||||
*/
|
||||
ArrayType getArrayType(TypeMirror componentType);
|
||||
|
||||
/**
|
||||
* Returns a new wildcard type argument. Either of the wildcard's
|
||||
* bounds may be specified, or neither, but not both.
|
||||
*
|
||||
* @param extendsBound the extends (upper) bound, or {@code null} if none
|
||||
* @param superBound the super (lower) bound, or {@code null} if none
|
||||
* @return a new wildcard
|
||||
* @throws IllegalArgumentException if bounds are not valid
|
||||
*/
|
||||
WildcardType getWildcardType(TypeMirror extendsBound,
|
||||
TypeMirror superBound);
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to a type element and
|
||||
* actual type arguments.
|
||||
* Given the type element for {@code Set} and the type mirror
|
||||
* for {@code String},
|
||||
* for example, this method may be used to get the
|
||||
* parameterized type {@code Set<String>}.
|
||||
*
|
||||
* <p> The number of type arguments must either equal the
|
||||
* number of the type element's formal type parameters, or must be
|
||||
* zero. If zero, and if the type element is generic,
|
||||
* then the type element's raw type is returned.
|
||||
*
|
||||
* <p> If a parameterized type is being returned, its type element
|
||||
* must not be contained within a generic outer class.
|
||||
* The parameterized type {@code Outer<String>.Inner<Number>},
|
||||
* for example, may be constructed by first using this
|
||||
* method to get the type {@code Outer<String>}, and then invoking
|
||||
* {@link #getDeclaredType(DeclaredType, TypeElement, TypeMirror...)}.
|
||||
*
|
||||
* @param typeElem the type element
|
||||
* @param typeArgs the actual type arguments
|
||||
* @return the type corresponding to the type element and
|
||||
* actual type arguments
|
||||
* @throws IllegalArgumentException if too many or too few
|
||||
* type arguments are given, or if an inappropriate type
|
||||
* argument or type element is provided
|
||||
*/
|
||||
DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs);
|
||||
|
||||
/**
|
||||
* Returns the type corresponding to a type element
|
||||
* and actual type arguments, given a
|
||||
* {@linkplain DeclaredType#getEnclosingType() containing type}
|
||||
* of which it is a member.
|
||||
* The parameterized type {@code Outer<String>.Inner<Number>},
|
||||
* for example, may be constructed by first using
|
||||
* {@link #getDeclaredType(TypeElement, TypeMirror...)}
|
||||
* to get the type {@code Outer<String>}, and then invoking
|
||||
* this method.
|
||||
*
|
||||
* <p> If the containing type is a parameterized type,
|
||||
* the number of type arguments must equal the
|
||||
* number of {@code typeElem}'s formal type parameters.
|
||||
* If it is not parameterized or if it is {@code null}, this method is
|
||||
* equivalent to {@code getDeclaredType(typeElem, typeArgs)}.
|
||||
*
|
||||
* @param containing the containing type, or {@code null} if none
|
||||
* @param typeElem the type element
|
||||
* @param typeArgs the actual type arguments
|
||||
* @return the type corresponding to the type element and
|
||||
* actual type arguments, contained within the given type
|
||||
* @throws IllegalArgumentException if too many or too few
|
||||
* type arguments are given, or if an inappropriate type
|
||||
* argument, type element, or containing type is provided
|
||||
*/
|
||||
DeclaredType getDeclaredType(DeclaredType containing,
|
||||
TypeElement typeElem, TypeMirror... typeArgs);
|
||||
|
||||
/**
|
||||
* Returns the type of an element when that element is viewed as
|
||||
* a member of, or otherwise directly contained by, a given type.
|
||||
* For example,
|
||||
* when viewed as a member of the parameterized type {@code Set<String>},
|
||||
* the {@code Set.add} method is an {@code ExecutableType}
|
||||
* whose parameter is of type {@code String}.
|
||||
*
|
||||
* @param containing the containing type
|
||||
* @param element the element
|
||||
* @return the type of the element as viewed from the containing type
|
||||
* @throws IllegalArgumentException if the element is not a valid one
|
||||
* for the given type
|
||||
*/
|
||||
TypeMirror asMemberOf(DeclaredType containing, Element element);
|
||||
}
|
||||
43
jdkSrc/jdk8/javax/lang/model/util/package-info.java
Normal file
43
jdkSrc/jdk8/javax/lang/model/util/package-info.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Utilities to assist in the processing of
|
||||
* {@linkplain javax.lang.model.element program elements} and
|
||||
* {@linkplain javax.lang.model.type types}.
|
||||
*
|
||||
* <p> Unless otherwise specified in a particular implementation, the
|
||||
* collections returned by methods in this package should be expected
|
||||
* to be unmodifiable by the caller and unsafe for concurrent access.
|
||||
*
|
||||
* <p> Unless otherwise specified, methods in this package will throw
|
||||
* a {@code NullPointerException} if given a {@code null} argument.
|
||||
*
|
||||
* @author Joseph D. Darcy
|
||||
* @author Scott Seligman
|
||||
* @author Peter von der Ahé
|
||||
* @since 1.6
|
||||
*/
|
||||
package javax.lang.model.util;
|
||||
Reference in New Issue
Block a user