feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -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