├── sample ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ │ └── styles.xml │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── java │ │ └── me │ │ │ └── denley │ │ │ └── preferencebinder │ │ │ └── sample │ │ │ ├── PreferenceDefaults.java │ │ │ ├── FragmentSampleActivity.java │ │ │ ├── MainActivity.java │ │ │ └── SampleFragment.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── javax.annotation.processing.Processor │ │ └── java │ │ ├── me │ │ └── denley │ │ │ └── preferencebinder │ │ │ ├── PreferenceDefault.java │ │ │ ├── BindPref.java │ │ │ └── internal │ │ │ ├── PrefType.java │ │ │ ├── Binding.java │ │ │ ├── PrefBinding.java │ │ │ └── WidgetBindingType.java │ │ └── javax │ │ ├── lang │ │ └── model │ │ │ ├── type │ │ │ ├── NullType.java │ │ │ ├── ReferenceType.java │ │ │ ├── PrimitiveType.java │ │ │ ├── ArrayType.java │ │ │ ├── ErrorType.java │ │ │ ├── UnionType.java │ │ │ ├── package-info.java │ │ │ ├── NoType.java │ │ │ ├── IntersectionType.java │ │ │ ├── WildcardType.java │ │ │ ├── MirroredTypeException.java │ │ │ ├── UnknownTypeException.java │ │ │ ├── TypeVariable.java │ │ │ ├── DeclaredType.java │ │ │ ├── MirroredTypesException.java │ │ │ ├── ExecutableType.java │ │ │ ├── TypeKind.java │ │ │ └── TypeMirror.java │ │ │ ├── element │ │ │ ├── QualifiedNameable.java │ │ │ ├── Parameterizable.java │ │ │ ├── AnnotationValue.java │ │ │ ├── TypeParameterElement.java │ │ │ ├── AnnotationMirror.java │ │ │ ├── Modifier.java │ │ │ ├── UnknownElementException.java │ │ │ ├── PackageElement.java │ │ │ ├── UnknownAnnotationValueException.java │ │ │ ├── VariableElement.java │ │ │ ├── Name.java │ │ │ ├── NestingKind.java │ │ │ ├── ElementKind.java │ │ │ └── package-info.java │ │ │ ├── util │ │ │ ├── package-info.java │ │ │ ├── AbstractAnnotationValueVisitor7.java │ │ │ ├── AbstractAnnotationValueVisitor8.java │ │ │ ├── AbstractElementVisitor7.java │ │ │ ├── AbstractElementVisitor8.java │ │ │ ├── AbstractTypeVisitor7.java │ │ │ ├── AbstractTypeVisitor8.java │ │ │ ├── SimpleAnnotationValueVisitor7.java │ │ │ ├── SimpleAnnotationValueVisitor8.java │ │ │ ├── SimpleElementVisitor8.java │ │ │ ├── ElementKindVisitor8.java │ │ │ ├── SimpleElementVisitor7.java │ │ │ ├── SimpleTypeVisitor7.java │ │ │ ├── SimpleTypeVisitor8.java │ │ │ ├── AbstractAnnotationValueVisitor6.java │ │ │ ├── ElementScanner8.java │ │ │ ├── TypeKindVisitor7.java │ │ │ └── TypeKindVisitor8.java │ │ │ ├── UnknownEntityException.java │ │ │ └── package-info.java │ │ ├── tools │ │ ├── OptionChecker.java │ │ ├── DiagnosticListener.java │ │ ├── DiagnosticCollector.java │ │ ├── ForwardingJavaFileObject.java │ │ ├── Tool.java │ │ ├── package-info.java │ │ ├── StandardLocation.java │ │ ├── ForwardingFileObject.java │ │ └── JavaFileObject.java │ │ └── annotation │ │ ├── Resources.java │ │ ├── processing │ │ ├── package-info.java │ │ ├── Completion.java │ │ ├── SupportedOptions.java │ │ ├── SupportedSourceVersion.java │ │ ├── FilerException.java │ │ ├── SupportedAnnotationTypes.java │ │ ├── Completions.java │ │ ├── Messager.java │ │ └── RoundEnvironment.java │ │ ├── Generated.java │ │ ├── PreDestroy.java │ │ └── PostConstruct.java ├── build.gradle ├── proguard-rules.pro └── android-release-aar.gradle ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew.bat └── CHANGELOG.md /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea 4 | *.iml 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denley/preferencebinder/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | me.denley.preferencebinder.internal.PreferenceBinderProcessor -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denley/preferencebinder/HEAD/sample/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denley/preferencebinder/HEAD/sample/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denley/preferencebinder/HEAD/sample/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/denley/preferencebinder/HEAD/sample/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /sample/src/main/java/me/denley/preferencebinder/sample/PreferenceDefaults.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.sample; 2 | 3 | import me.denley.preferencebinder.PreferenceDefault; 4 | 5 | public class PreferenceDefaults { 6 | 7 | @PreferenceDefault("integer_pref_key") 8 | public static final int INTEGER_PREF_DEFAULT = 50; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PreferenceBinder Sample 5 | PreferenceBinder Fragment Sample 6 | 7 | Sample Boolean 8 | Sample Integer 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/java/me/denley/preferencebinder/sample/FragmentSampleActivity.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.sample; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | 6 | 7 | public class FragmentSampleActivity extends Activity { 8 | 9 | @Override protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | 12 | getFragmentManager() 13 | .beginTransaction() 14 | .add(android.R.id.content, new SampleFragment()) 15 | .commit(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 4 9 | targetSdkVersion 22 10 | } 11 | 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | 19 | lintOptions { 20 | abortOnError false 21 | } 22 | } 23 | 24 | dependencies { 25 | 26 | } 27 | 28 | apply from: 'android-release-aar.gradle' -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/PreferenceDefault.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.RetentionPolicy.CLASS; 8 | 9 | /** 10 | * Assign a static field to be used as a default value for a preference. 11 | */ 12 | @Retention(CLASS) @Target(FIELD) 13 | public @interface PreferenceDefault { 14 | 15 | /** SharedPreferences key to listen for changes to its value. */ 16 | String value(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/NullType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * Represents the null type. 31 | * This is the type of the expression {@code null}, 32 | * 33 | * @author Joseph D. Darcy 34 | * @author Scott Seligman 35 | * @author Peter von der Ahé 36 | * @since 1.6 37 | */ 38 | 39 | public interface NullType extends ReferenceType { 40 | } 41 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Program Files (x86)/Android/android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Program Files (x86)\Android\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/ReferenceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * Represents a reference type. 31 | * These include class and interface types, array types, type variables, 32 | * and the null type. 33 | * 34 | * @author Joseph D. Darcy 35 | * @author Scott Seligman 36 | * @author Peter von der Ahé 37 | * @since 1.6 38 | */ 39 | public interface ReferenceType extends TypeMirror { 40 | } 41 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/QualifiedNameable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | /** 29 | * A mixin interface for an element that has a qualified name. 30 | * 31 | * @author Joseph D. Darcy 32 | * @since 1.7 33 | */ 34 | public interface QualifiedNameable extends Element { 35 | /** 36 | * Returns the fully qualified name of an element. 37 | * 38 | * @return the fully qualified name of an element 39 | */ 40 | Name getQualifiedName(); 41 | } 42 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/PrimitiveType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * Represents a primitive type. These include 31 | * {@code boolean}, {@code byte}, {@code short}, {@code int}, 32 | * {@code long}, {@code char}, {@code float}, and {@code double}. 33 | * 34 | * @author Joseph D. Darcy 35 | * @author Scott Seligman 36 | * @author Peter von der Ahé 37 | * @since 1.6 38 | */ 39 | public interface PrimitiveType extends TypeMirror { 40 | } 41 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "20.0.0" 6 | 7 | defaultConfig { 8 | applicationId "me.denley.preferencebinder.sample" 9 | minSdkVersion 11 10 | targetSdkVersion 22 11 | versionCode project.VERSION_CODE 12 | versionName project.VERSION_NAME 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | dependencies { 27 | compile project(':library') 28 | provided project(':library') 29 | // compile(group: project.GROUP_ID, name: project.ARTIFACT_ID, version: project.VERSION_NAME, ext: 'pom') 30 | } 31 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/OptionChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | /** 29 | * Interface for recognizing options. 30 | * 31 | * @author Peter von der Ahé 32 | * @since 1.6 33 | */ 34 | public interface OptionChecker { 35 | 36 | /** 37 | * Determines if the given option is supported and if so, the 38 | * number of arguments the option takes. 39 | * 40 | * @param option an option 41 | * @return the number of arguments the given option takes or -1 if 42 | * the option is not supported 43 | */ 44 | int isSupportedOption(String option); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/Resources.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation; 27 | import java.lang.annotation.*; 28 | import static java.lang.annotation.ElementType.*; 29 | import static java.lang.annotation.RetentionPolicy.*; 30 | 31 | /** 32 | * This class is used to allow multiple resources declarations. 33 | * 34 | * @see javax.annotation.Resource 35 | * @since Common Annotations 1.0 36 | */ 37 | 38 | @Documented 39 | @Retention(RUNTIME) 40 | @Target(TYPE) 41 | public @interface Resources { 42 | /** 43 | * Array used for multiple resource declarations. 44 | */ 45 | Resource[] value(); 46 | } 47 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/Parameterizable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * A mixin interface for an element that has type parameters. 32 | * 33 | * @author Joseph D. Darcy 34 | * @since 1.7 35 | */ 36 | public interface Parameterizable extends Element { 37 | /** 38 | * Returns the formal type parameters of the type element in 39 | * declaration order. 40 | * 41 | * @return the formal type parameters, or an empty list 42 | * if there are none 43 | */ 44 | List getTypeParameters(); 45 | } 46 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/ArrayType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * Represents an array type. 31 | * A multidimensional array type is represented as an array type 32 | * whose component type is also an array type. 33 | * 34 | * @author Joseph D. Darcy 35 | * @author Scott Seligman 36 | * @author Peter von der Ahé 37 | * @since 1.6 38 | */ 39 | public interface ArrayType extends ReferenceType { 40 | 41 | /** 42 | * Returns the component type of this array type. 43 | * 44 | * @return the component type of this array type 45 | */ 46 | TypeMirror getComponentType(); 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/ErrorType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | /** 29 | * Represents a class or interface type that cannot be properly modeled. 30 | * This may be the result of a processing error, 31 | * such as a missing class file or erroneous source code. 32 | * Most queries for 33 | * information derived from such a type (such as its members or its 34 | * supertype) will not, in general, return meaningful results. 35 | * 36 | * @author Joseph D. Darcy 37 | * @author Scott Seligman 38 | * @author Peter von der Ahé 39 | * @since 1.6 40 | */ 41 | public interface ErrorType extends DeclaredType { 42 | } 43 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/UnionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * Represents a union type. 32 | * 33 | * As of the {@link javax.lang.model.SourceVersion#RELEASE_7 34 | * RELEASE_7} source version, union types can appear as the type 35 | * of a multi-catch exception parameter. 36 | * 37 | * @since 1.7 38 | */ 39 | public interface UnionType extends TypeMirror { 40 | 41 | /** 42 | * Return the alternatives comprising this union type. 43 | * 44 | * @return the alternatives comprising this union type. 45 | */ 46 | List getAlternatives(); 47 | } 48 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Interfaces used to model Java programming language types. 28 | * 29 | *

Unless otherwise specified in a particular implementation, the 30 | * collections returned by methods in this package should be expected 31 | * to be unmodifiable by the caller and unsafe for concurrent access. 32 | * 33 | *

Unless otherwise specified, methods in this package will throw 34 | * a {@code NullPointerException} if given a {@code null} argument. 35 | * 36 | * @author Joseph D. Darcy 37 | * @author Scott Seligman 38 | * @author Peter von der Ahé 39 | * @since 1.6 40 | */ 41 | package javax.lang.model.type; 42 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Utilities to assist in the processing of 28 | * {@linkplain javax.lang.model.element program elements} and 29 | * {@linkplain javax.lang.model.type types}. 30 | * 31 | *

Unless otherwise specified in a particular implementation, the 32 | * collections returned by methods in this package should be expected 33 | * to be unmodifiable by the caller and unsafe for concurrent access. 34 | * 35 | *

Unless otherwise specified, methods in this package will throw 36 | * a {@code NullPointerException} if given a {@code null} argument. 37 | * 38 | * @author Joseph D. Darcy 39 | * @author Scott Seligman 40 | * @author Peter von der Ahé 41 | * @since 1.6 42 | */ 43 | package javax.lang.model.util; 44 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Facilities for declaring annotation processors and for 28 | * allowing annotation processors to communicate with an annotation processing 29 | * tool environment. 30 | * 31 | *

Unless otherwise specified in a particular implementation, the 32 | * collections returned by methods in this package should be expected 33 | * to be unmodifiable by the caller and unsafe for concurrent access. 34 | * 35 | *

Unless otherwise specified, methods in this package will throw 36 | * a {@code NullPointerException} if given a {@code null} argument. 37 | * 38 | * @author Joseph D. Darcy 39 | * @author Scott Seligman 40 | * @author Peter von der Ahé 41 | * @since 1.6 42 | */ 43 | package javax.annotation.processing; 44 | -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/BindPref.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import me.denley.preferencebinder.internal.WidgetBindingType; 7 | 8 | import static java.lang.annotation.ElementType.FIELD; 9 | import static java.lang.annotation.ElementType.METHOD; 10 | import static java.lang.annotation.RetentionPolicy.CLASS; 11 | 12 | /** 13 | * Bind a field to the preference value with the specified key. 14 | */ 15 | @Retention(CLASS) @Target({FIELD, METHOD}) 16 | public @interface BindPref { 17 | 18 | /** SharedPreferences key for the preference value to be found */ 19 | String[] value(); 20 | 21 | /** Whether or not to initialize this field/method when binding occurs */ 22 | boolean init() default true; 23 | 24 | /** Whether or not to update this field or call this method again when the preference value changes */ 25 | boolean listen() default true; 26 | 27 | /** The method to use to bind to a widget */ 28 | WidgetBindingType bindTo() default WidgetBindingType.ASSIGN; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/DiagnosticListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | /** 29 | * Interface for receiving diagnostics from tools. 30 | * 31 | * @param the type of source objects used by diagnostics received 32 | * by this listener 33 | * 34 | * @author Jonathan Gibbons 35 | * @author Peter von der Ahé 36 | * @since 1.6 37 | */ 38 | public interface DiagnosticListener { 39 | /** 40 | * Invoked when a problem is found. 41 | * 42 | * @param diagnostic a diagnostic representing the problem that 43 | * was found 44 | * @throws NullPointerException if the diagnostic argument is 45 | * {@code null} and the implementation cannot handle {@code null} 46 | * arguments 47 | */ 48 | void report(Diagnostic diagnostic); 49 | } 50 | -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/internal/PrefType.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.internal; 2 | 3 | public enum PrefType { 4 | // Defaults are arbitrary as we always check that a value exists 5 | BOOLEAN("boolean", "getBoolean", "false"), 6 | FLOAT("float", "getFloat", "0"), 7 | INTEGER("int", "getInt", "0"), 8 | LONG("long", "getLong", "0"), 9 | STRING("java.lang.String", "getString", "null"), 10 | STRING_SET("java.util.Set", "getStringSet", "null"); 11 | 12 | private String fieldTypeDef; 13 | private String methodName; 14 | private String defaultValue; 15 | 16 | PrefType(String fieldTypeDef, String methodName, String defaultValue){ 17 | this.fieldTypeDef = fieldTypeDef; 18 | this.methodName = methodName; 19 | this.defaultValue = defaultValue; 20 | } 21 | 22 | public String getFieldTypeDef() { 23 | return fieldTypeDef; 24 | } 25 | 26 | public String getSharedPrefsMethodName() { 27 | return methodName; 28 | } 29 | 30 | public String getDefaultValue() { 31 | return defaultValue; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/Completion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | /** 29 | * A suggested {@linkplain Processor#getCompletions completion} for an 30 | * annotation. A completion is text meant to be inserted into a 31 | * program as part of an annotation. 32 | * 33 | * @author Joseph D. Darcy 34 | * @author Scott Seligman 35 | * @author Peter von der Ahé 36 | * @since 1.6 37 | */ 38 | public interface Completion { 39 | 40 | /** 41 | * Returns the text of the suggested completion. 42 | * @return the text of the suggested completion. 43 | */ 44 | String getValue(); 45 | 46 | /** 47 | * Returns an informative message about the completion. 48 | * @return an informative message about the completion. 49 | */ 50 | String getMessage(); 51 | } 52 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/NoType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import javax.lang.model.element.ExecutableElement; 29 | 30 | 31 | /** 32 | * A pseudo-type used where no actual type is appropriate. 33 | * The kinds of {@code NoType} are: 34 | *

41 | * 42 | * @author Joseph D. Darcy 43 | * @author Scott Seligman 44 | * @author Peter von der Ahé 45 | * @see ExecutableElement#getReturnType() 46 | * @since 1.6 47 | */ 48 | 49 | public interface NoType extends TypeMirror { 50 | } 51 | -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/internal/Binding.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.internal; 2 | 3 | import java.lang.annotation.ElementType; 4 | 5 | /** A single field or method binding. */ 6 | class Binding { 7 | 8 | private final String name; 9 | private final String type; 10 | private final ElementType elementType; 11 | private final WidgetBindingType bindingType; 12 | 13 | public Binding(String name, String type, ElementType elementType, WidgetBindingType bindingType) { 14 | this.name = name; 15 | this.type = type; 16 | this.elementType = elementType; 17 | this.bindingType = bindingType; 18 | } 19 | 20 | /** The name of the field or method */ 21 | String getName(){ 22 | return name; 23 | } 24 | 25 | /** The fully qualified object type of the field or method parameter (or primative) */ 26 | String getType(){ 27 | return type; 28 | } 29 | 30 | /** Either ElementType.FIELD or ElementType.METHOD */ 31 | ElementType getBindingType(){ 32 | return elementType; 33 | } 34 | 35 | WidgetBindingType getWidgetBindingType() { 36 | return bindingType; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 20 | 21 | 22 | 28 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/SupportedOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import java.lang.annotation.*; 29 | import static java.lang.annotation.RetentionPolicy.*; 30 | import static java.lang.annotation.ElementType.*; 31 | 32 | /** 33 | * An annotation used to indicate what options an annotation processor 34 | * supports. The {@link Processor#getSupportedOptions} method can 35 | * construct its result from the value of this annotation, as done by 36 | * {@link AbstractProcessor#getSupportedOptions}. Only {@linkplain 37 | * Processor#getSupportedOptions strings conforming to the 38 | * grammar} should be used as values. 39 | * 40 | * @author Joseph D. Darcy 41 | * @author Scott Seligman 42 | * @author Peter von der Ahé 43 | * @since 1.6 44 | */ 45 | @Documented 46 | @Target(TYPE) 47 | @Retention(RUNTIME) 48 | public @interface SupportedOptions { 49 | /** 50 | * Returns the supported options. 51 | * @return the supported options 52 | */ 53 | String [] value(); 54 | } 55 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/SupportedSourceVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import java.lang.annotation.*; 29 | import static java.lang.annotation.RetentionPolicy.*; 30 | import static java.lang.annotation.ElementType.*; 31 | import javax.lang.model.SourceVersion; 32 | 33 | 34 | /** 35 | * An annotation used to indicate the latest source version an 36 | * annotation processor supports. The {@link 37 | * Processor#getSupportedSourceVersion} method can construct its 38 | * result from the value of this annotation, as done by {@link 39 | * AbstractProcessor#getSupportedSourceVersion}. 40 | * 41 | * @author Joseph D. Darcy 42 | * @author Scott Seligman 43 | * @author Peter von der Ahé 44 | * @since 1.6 45 | */ 46 | @Documented 47 | @Target(TYPE) 48 | @Retention(RUNTIME) 49 | public @interface SupportedSourceVersion { 50 | /** 51 | * Returns the latest supported source version. 52 | * @return the latest supported source version 53 | */ 54 | SourceVersion value(); 55 | } 56 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/FilerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import java.io.IOException; 29 | 30 | /** 31 | * Indicates a {@link Filer} detected an attempt to open a file that 32 | * would violate the guarantees provided by the {@code Filer}. Those 33 | * guarantees include not creating the same file more than once, not 34 | * creating multiple files corresponding to the same type, and not 35 | * creating files for types with invalid names. 36 | * 37 | * @author Joseph D. Darcy 38 | * @author Scott Seligman 39 | * @author Peter von der Ahé 40 | * @since 1.6 41 | */ 42 | public class FilerException extends IOException { 43 | static final long serialVersionUID = 8426423106453163293L; 44 | /** 45 | * Constructs an exception with the specified detail message. 46 | * @param s the detail message, which should include the name of 47 | * the file attempting to be opened; may be {@code null} 48 | */ 49 | public FilerException(String s) { 50 | super(s); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/DiagnosticCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Collections; 30 | import java.util.List; 31 | 32 | /** 33 | * Provides an easy way to collect diagnostics in a list. 34 | * 35 | * @param the type of source objects used by diagnostics received 36 | * by this object 37 | * 38 | * @author Peter von der Ahé 39 | * @since 1.6 40 | */ 41 | public final class DiagnosticCollector implements DiagnosticListener { 42 | private List> diagnostics = 43 | Collections.synchronizedList(new ArrayList>()); 44 | 45 | public void report(Diagnostic diagnostic) { 46 | diagnostic.getClass(); // null check 47 | diagnostics.add(diagnostic); 48 | } 49 | 50 | /** 51 | * Gets a list view of diagnostics collected by this object. 52 | * 53 | * @return a list view of diagnostics 54 | */ 55 | public List> getDiagnostics() { 56 | return Collections.unmodifiableList(diagnostics); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/SupportedAnnotationTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import java.lang.annotation.*; 29 | import static java.lang.annotation.RetentionPolicy.*; 30 | import static java.lang.annotation.ElementType.*; 31 | 32 | /** 33 | * An annotation used to indicate what annotation types an annotation 34 | * processor supports. The {@link 35 | * Processor#getSupportedAnnotationTypes} method can construct its 36 | * result from the value of this annotation, as done by {@link 37 | * AbstractProcessor#getSupportedAnnotationTypes}. Only {@linkplain 38 | * Processor#getSupportedAnnotationTypes strings conforming to the 39 | * grammar} should be used as values. 40 | * 41 | * @author Joseph D. Darcy 42 | * @author Scott Seligman 43 | * @author Peter von der Ahé 44 | * @since 1.6 45 | */ 46 | @Documented 47 | @Target(TYPE) 48 | @Retention(RUNTIME) 49 | public @interface SupportedAnnotationTypes { 50 | /** 51 | * Returns the names of the supported annotation types. 52 | * @return the names of the supported annotation types 53 | */ 54 | String [] value(); 55 | } 56 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/IntersectionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * Represents an intersection type. 32 | * 33 | *

An intersection type can be either implicitly or explicitly 34 | * declared in a program. For example, the bound of the type parameter 35 | * {@code } is an (implicit) intersection 36 | * type. As of {@link javax.lang.model.SourceVersion#RELEASE_8 37 | * RELEASE_8}, this is represented by an {@code IntersectionType} with 38 | * {@code Number} and {@code Runnable} as its bounds. 39 | * 40 | * @implNote Also as of {@link 41 | * javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}, in the 42 | * reference implementation an {@code IntersectionType} is used to 43 | * model the explicit target type of a cast expression. 44 | * 45 | * @since 1.8 46 | */ 47 | public interface IntersectionType extends TypeMirror { 48 | 49 | /** 50 | * Return the bounds comprising this intersection type. 51 | * 52 | * @return the bounds of this intersection types. 53 | */ 54 | List getBounds(); 55 | } 56 | -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/internal/PrefBinding.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.internal; 2 | 3 | import java.util.Collection; 4 | import java.util.LinkedHashSet; 5 | import java.util.Set; 6 | 7 | public class PrefBinding { 8 | private final String key; 9 | private PrefType type; 10 | private final String defaultStaticField; 11 | private final Set initBindings = new LinkedHashSet<>(); 12 | private final Set listenerBindings = new LinkedHashSet<>(); 13 | 14 | PrefBinding(String key, PrefType type, String defaultField) { 15 | this.key = key; 16 | this.type = type; 17 | this.defaultStaticField = defaultField; 18 | } 19 | 20 | public String getKey() { 21 | return key; 22 | } 23 | 24 | public PrefType getType() { 25 | return type; 26 | } 27 | 28 | public void setType(PrefType type) { 29 | this.type = type; 30 | } 31 | 32 | public String getDefaultStaticField() { 33 | return defaultStaticField; 34 | } 35 | 36 | public Collection getInitBindings() { 37 | return initBindings; 38 | } 39 | 40 | public Collection getListenerBindings() { 41 | return listenerBindings; 42 | } 43 | 44 | public void addInitBinding(Binding binding) { 45 | initBindings.add(binding); 46 | } 47 | 48 | public void addListenerBinding(Binding binding) { 49 | listenerBindings.add(binding); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/WildcardType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * Represents a wildcard type argument. 31 | * Examples include:


32 |  *   ?
33 |  *   ? extends Number
34 |  *   ? super T
35 |  * 
36 | * 37 | *

A wildcard may have its upper bound explicitly set by an 38 | * {@code extends} clause, its lower bound explicitly set by a 39 | * {@code super} clause, or neither (but not both). 40 | * 41 | * @author Joseph D. Darcy 42 | * @author Scott Seligman 43 | * @author Peter von der Ahé 44 | * @since 1.6 45 | */ 46 | public interface WildcardType extends TypeMirror { 47 | 48 | /** 49 | * Returns the upper bound of this wildcard. 50 | * If no upper bound is explicitly declared, 51 | * {@code null} is returned. 52 | * 53 | * @return the upper bound of this wildcard 54 | */ 55 | TypeMirror getExtendsBound(); 56 | 57 | /** 58 | * Returns the lower bound of this wildcard. 59 | * If no lower bound is explicitly declared, 60 | * {@code null} is returned. 61 | * 62 | * @return the lower bound of this wildcard 63 | */ 64 | TypeMirror getSuperBound(); 65 | } 66 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/UnknownEntityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model; 27 | 28 | /** 29 | * Superclass of exceptions which indicate that an unknown kind of 30 | * entity was encountered. This situation can occur if the language 31 | * evolves and new kinds of constructs are introduced. Subclasses of 32 | * this exception may be thrown by visitors to indicate that the 33 | * visitor was created for a prior version of the language. 34 | * 35 | *

A common superclass for those exceptions allows a single catch 36 | * block to have code handling them uniformly. 37 | * 38 | * @author Joseph D. Darcy 39 | * @see javax.lang.model.element.UnknownElementException 40 | * @see javax.lang.model.element.UnknownAnnotationValueException 41 | * @see javax.lang.model.type.UnknownTypeException 42 | * @since 1.7 43 | */ 44 | public class UnknownEntityException extends RuntimeException { 45 | 46 | private static final long serialVersionUID = 269L; 47 | 48 | /** 49 | * Creates a new {@code UnknownEntityException} with the specified 50 | * detail message. 51 | * 52 | * @param message the detail message 53 | */ 54 | protected UnknownEntityException(String message) { 55 | super(message); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/ForwardingJavaFileObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import javax.lang.model.element.Modifier; 29 | import javax.lang.model.element.NestingKind; 30 | 31 | /** 32 | * Forwards calls to a given file object. Subclasses of this class 33 | * might override some of these methods and might also provide 34 | * additional fields and methods. 35 | * 36 | * @param the kind of file object forwarded to by this object 37 | * @author Peter von der Ahé 38 | * @since 1.6 39 | */ 40 | public class ForwardingJavaFileObject 41 | extends ForwardingFileObject 42 | implements JavaFileObject 43 | { 44 | 45 | /** 46 | * Creates a new instance of ForwardingJavaFileObject. 47 | * @param fileObject delegate to this file object 48 | */ 49 | protected ForwardingJavaFileObject(F fileObject) { 50 | super(fileObject); 51 | } 52 | 53 | public Kind getKind() { 54 | return fileObject.getKind(); 55 | } 56 | 57 | public boolean isNameCompatible(String simpleName, Kind kind) { 58 | return fileObject.isNameCompatible(simpleName, kind); 59 | } 60 | 61 | public NestingKind getNestingKind() { return fileObject.getNestingKind(); } 62 | 63 | public Modifier getAccessLevel() { return fileObject.getAccessLevel(); } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /library/android-release-aar.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | 3 | def groupId = project.GROUP_ID 4 | def artifactId = project.ARTIFACT_ID 5 | def version = project.VERSION_NAME 6 | 7 | def localReleaseDest = "${buildDir}/release/${version}" 8 | 9 | task androidJavadocs(type: Javadoc) { 10 | source = android.sourceSets.main.java.srcDirs 11 | failOnError false 12 | exclude '**/javax/**' 13 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 14 | } 15 | 16 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { 17 | classifier = 'javadoc' 18 | from androidJavadocs.destinationDir 19 | exclude '**/javax/**' 20 | } 21 | 22 | task androidSourcesJar(type: Jar) { 23 | classifier = 'sources' 24 | from android.sourceSets.main.java.srcDirs 25 | exclude '**/javax/**' 26 | } 27 | 28 | uploadArchives { 29 | repositories.mavenDeployer { 30 | pom.groupId = groupId 31 | pom.artifactId = artifactId 32 | pom.version = version 33 | // Add other pom properties here if you want (developer details / licenses) 34 | repository(url: "file://${localReleaseDest}") 35 | } 36 | } 37 | 38 | task zipRelease(type: Zip) { 39 | from localReleaseDest 40 | destinationDir buildDir 41 | archiveName "release-${version}.zip" 42 | } 43 | 44 | task generateRelease << { 45 | println "Release ${version} can be found at ${localReleaseDest}/" 46 | println "Release ${version} zipped can be found ${buildDir}/release-${version}.zip" 47 | } 48 | 49 | generateRelease.dependsOn(uploadArchives) 50 | generateRelease.dependsOn(zipRelease) 51 | 52 | 53 | artifacts { 54 | archives androidSourcesJar 55 | archives androidJavadocsJar 56 | } -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Classes and hierarchies of packages used to model the Java 28 | * programming language. 29 | * 30 | * The members of this package and its subpackages are for use in 31 | * language modeling and language processing tasks and APIs including, 32 | * but not limited to, the {@linkplain javax.annotation.processing 33 | * annotation processing} framework. 34 | * 35 | *

This language model follows a mirror-based design; see 36 | * 37 | *

38 | * Gilad Bracha and David Ungar. Mirrors: Design Principles for 39 | * Meta-level Facilities of Object-Oriented Programming Languages. 40 | * In Proc. of the ACM Conf. on Object-Oriented Programming, Systems, 41 | * Languages and Applications, October 2004. 42 | *
43 | * 44 | * In particular, the model makes a distinction between static 45 | * language constructs, like the {@linkplain javax.lang.model.element 46 | * element} representing {@code java.util.Set}, and the family of 47 | * {@linkplain javax.lang.model.type types} that may be associated 48 | * with an element, like the raw type {@code java.util.Set}, {@code 49 | * java.util.Set}, and {@code java.util.Set}. 50 | * 51 | *

Unless otherwise specified, methods in this package will throw 52 | * a {@code NullPointerException} if given a {@code null} argument. 53 | * 54 | * @author Joseph D. Darcy 55 | * @author Scott Seligman 56 | * @author Peter von der Ahé 57 | * @since 1.6 58 | */ 59 | 60 | package javax.lang.model; 61 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/AnnotationValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | /** 29 | * Represents a value of an annotation type element. 30 | * A value is of one of the following types: 31 | *

  • a wrapper class (such as {@link Integer}) for a primitive type 32 | *
  • {@code String} 33 | *
  • {@code TypeMirror} 34 | *
  • {@code VariableElement} (representing an enum constant) 35 | *
  • {@code AnnotationMirror} 36 | *
  • {@code List} 37 | * (representing the elements, in declared order, if the value is an array) 38 | *
39 | * 40 | * @author Joseph D. Darcy 41 | * @author Scott Seligman 42 | * @author Peter von der Ahé 43 | * @since 1.6 44 | */ 45 | public interface AnnotationValue { 46 | 47 | /** 48 | * Returns the value. 49 | * 50 | * @return the value 51 | */ 52 | Object getValue(); 53 | 54 | /** 55 | * Returns a string representation of this value. 56 | * This is returned in a form suitable for representing this value 57 | * in the source code of an annotation. 58 | * 59 | * @return a string representation of this value 60 | */ 61 | String toString(); 62 | 63 | /** 64 | * Applies a visitor to this value. 65 | * 66 | * @param the return type of the visitor's methods 67 | * @param

the type of the additional parameter to the visitor's methods 68 | * @param v the visitor operating on this value 69 | * @param p additional parameter to the visitor 70 | * @return a visitor-specified result 71 | */ 72 | R accept(AnnotationValueVisitor v, P p); 73 | } 74 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/TypeParameterElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import java.util.List; 29 | import javax.lang.model.type.TypeMirror; 30 | import javax.lang.model.type.TypeVariable; 31 | 32 | /** 33 | * Represents a formal type parameter of a generic class, interface, method, 34 | * or constructor element. 35 | * A type parameter declares a {@link TypeVariable}. 36 | * 37 | * @author Joseph D. Darcy 38 | * @author Scott Seligman 39 | * @author Peter von der Ahé 40 | * @see TypeVariable 41 | * @since 1.6 42 | */ 43 | public interface TypeParameterElement extends Element { 44 | 45 | /** 46 | * Returns the generic class, interface, method, or constructor that is 47 | * parameterized by this type parameter. 48 | * 49 | * @return the generic class, interface, method, or constructor that is 50 | * parameterized by this type parameter 51 | */ 52 | Element getGenericElement(); 53 | 54 | /** 55 | * Returns the bounds of this type parameter. 56 | * These are the types given by the {@code extends} clause 57 | * used to declare this type parameter. 58 | * If no explicit {@code extends} clause was used, 59 | * then {@code java.lang.Object} is considered to be the sole bound. 60 | * 61 | * @return the bounds of this type parameter, or an empty list if 62 | * there are none 63 | */ 64 | List getBounds(); 65 | 66 | /** 67 | * Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter. 68 | * 69 | * @return the generic element of this type parameter 70 | */ 71 | @Override 72 | Element getEnclosingElement(); 73 | } 74 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/Tool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import java.util.Set; 29 | import java.io.InputStream; 30 | import java.io.OutputStream; 31 | import javax.lang.model.SourceVersion; 32 | 33 | /** 34 | * Common interface for tools that can be invoked from a program. 35 | * A tool is traditionally a command line program such as a compiler. 36 | * The set of tools available with a platform is defined by the 37 | * vendor. 38 | * 39 | *

Tools can be located using {@link 40 | * java.util.ServiceLoader#load(Class)}. 41 | * 42 | * @author Neal M Gafter 43 | * @author Peter von der Ahé 44 | * @author Jonathan Gibbons 45 | * @since 1.6 46 | */ 47 | public interface Tool { 48 | 49 | /** 50 | * Run the tool with the given I/O channels and arguments. By 51 | * convention a tool returns 0 for success and nonzero for errors. 52 | * Any diagnostics generated will be written to either {@code out} 53 | * or {@code err} in some unspecified format. 54 | * 55 | * @param in "standard" input; use System.in if null 56 | * @param out "standard" output; use System.out if null 57 | * @param err "standard" error; use System.err if null 58 | * @param arguments arguments to pass to the tool 59 | * @return 0 for success; nonzero otherwise 60 | * @throws NullPointerException if the array of arguments contains 61 | * any {@code null} elements. 62 | */ 63 | int run(InputStream in, OutputStream out, OutputStream err, String... arguments); 64 | 65 | /** 66 | * Gets the source versions of the Java™ programming language 67 | * supported by this tool. 68 | * @return a set of supported source versions 69 | */ 70 | Set getSourceVersions(); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/MirroredTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import java.io.ObjectInputStream; 29 | import java.io.IOException; 30 | import javax.lang.model.element.Element; 31 | 32 | 33 | /** 34 | * Thrown when an application attempts to access the {@link Class} object 35 | * corresponding to a {@link TypeMirror}. 36 | * 37 | * @author Joseph D. Darcy 38 | * @author Scott Seligman 39 | * @author Peter von der Ahé 40 | * @see MirroredTypesException 41 | * @see Element#getAnnotation(Class) 42 | * @since 1.6 43 | */ 44 | public class MirroredTypeException extends MirroredTypesException { 45 | 46 | private static final long serialVersionUID = 269; 47 | 48 | private transient TypeMirror type; // cannot be serialized 49 | 50 | /** 51 | * Constructs a new MirroredTypeException for the specified type. 52 | * 53 | * @param type the type being accessed 54 | */ 55 | public MirroredTypeException(TypeMirror type) { 56 | super("Attempt to access Class object for TypeMirror " + type.toString(), type); 57 | this.type = type; 58 | } 59 | 60 | /** 61 | * Returns the type mirror corresponding to the type being accessed. 62 | * The type mirror may be unavailable if this exception has been 63 | * serialized and then read back in. 64 | * 65 | * @return the type mirror, or {@code null} if unavailable 66 | */ 67 | public TypeMirror getTypeMirror() { 68 | return type; 69 | } 70 | 71 | /** 72 | * Explicitly set all transient fields. 73 | */ 74 | private void readObject(ObjectInputStream s) 75 | throws IOException, ClassNotFoundException { 76 | s.defaultReadObject(); 77 | type = null; 78 | types = null; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/AnnotationMirror.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import java.util.Map; 29 | import javax.lang.model.type.DeclaredType; 30 | 31 | /** 32 | * Represents an annotation. An annotation associates a value with 33 | * each element of an annotation type. 34 | * 35 | *

Annotations should be compared using the {@code equals} 36 | * method. There is no guarantee that any particular annotation will 37 | * always be represented by the same object. 38 | * 39 | * @author Joseph D. Darcy 40 | * @author Scott Seligman 41 | * @author Peter von der Ahé 42 | * @since 1.6 43 | */ 44 | public interface AnnotationMirror { 45 | 46 | /** 47 | * Returns the type of this annotation. 48 | * 49 | * @return the type of this annotation 50 | */ 51 | DeclaredType getAnnotationType(); 52 | 53 | /** 54 | * Returns the values of this annotation's elements. 55 | * This is returned in the form of a map that associates elements 56 | * with their corresponding values. 57 | * Only those elements with values explicitly present in the 58 | * annotation are included, not those that are implicitly assuming 59 | * their default values. 60 | * The order of the map matches the order in which the 61 | * values appear in the annotation's source. 62 | * 63 | *

Note that an annotation mirror of a marker annotation type 64 | * will by definition have an empty map. 65 | * 66 | *

To fill in default values, use {@link 67 | * javax.lang.model.util.Elements#getElementValuesWithDefaults 68 | * getElementValuesWithDefaults}. 69 | * 70 | * @return the values of this annotation's elements, 71 | * or an empty map if there are none 72 | */ 73 | Map getElementValues(); 74 | } 75 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/Modifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | 29 | /** 30 | * Represents a modifier on a program element such 31 | * as a class, method, or field. 32 | * 33 | *

Not all modifiers are applicable to all kinds of elements. 34 | * When two or more modifiers appear in the source code of an element 35 | * then it is customary, though not required, that they appear in the same 36 | * order as the constants listed in the detail section below. 37 | * 38 | *

Note that it is possible additional modifiers will be added in 39 | * future versions of the platform. 40 | * 41 | * @author Joseph D. Darcy 42 | * @author Scott Seligman 43 | * @author Peter von der Ahé 44 | * @since 1.6 45 | */ 46 | 47 | public enum Modifier { 48 | 49 | // See JLS sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1. 50 | // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism. 51 | 52 | /** The modifier {@code public} */ PUBLIC, 53 | /** The modifier {@code protected} */ PROTECTED, 54 | /** The modifier {@code private} */ PRIVATE, 55 | /** The modifier {@code abstract} */ ABSTRACT, 56 | /** 57 | * The modifier {@code default} 58 | * @since 1.8 59 | */ 60 | DEFAULT, 61 | /** The modifier {@code static} */ STATIC, 62 | /** The modifier {@code final} */ FINAL, 63 | /** The modifier {@code transient} */ TRANSIENT, 64 | /** The modifier {@code volatile} */ VOLATILE, 65 | /** The modifier {@code synchronized} */ SYNCHRONIZED, 66 | /** The modifier {@code native} */ NATIVE, 67 | /** The modifier {@code strictfp} */ STRICTFP; 68 | 69 | /** 70 | * Returns this modifier's name in lowercase. 71 | */ 72 | public String toString() { 73 | return name().toLowerCase(java.util.Locale.US); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/Generated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation; 27 | import java.lang.annotation.*; 28 | import static java.lang.annotation.ElementType.*; 29 | import static java.lang.annotation.RetentionPolicy.*; 30 | 31 | /** 32 | * The Generated annotation is used to mark source code that has been generated. 33 | * It can also be used to differentiate user written code from generated code 34 | * in a single file. When used, the value element must have the name of the 35 | * code generator. The recommended convention is to use the fully qualified 36 | * name of the code generator in the value field . 37 | *

For example: com.company.package.classname. 38 | * The date element is used to indicate the date the source was generated. 39 | * The date element must follow the ISO 8601 standard. For example the date 40 | * element would have the following value 2001-07-04T12:08:56.235-0700 41 | * which represents 2001-07-04 12:08:56 local time in the U.S. Pacific 42 | * Time time zone.

43 | *

The comment element is a place holder for any comments that the code 44 | * generator may want to include in the generated code.

45 | * 46 | * @since Common Annotations 1.0 47 | */ 48 | 49 | @Documented 50 | @Retention(SOURCE) 51 | @Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, 52 | LOCAL_VARIABLE, PARAMETER}) 53 | public @interface Generated { 54 | /** 55 | * The value element MUST have the name of the code generator. 56 | * The recommended convention is to use the fully qualified name of the 57 | * code generator. For example: com.acme.generator.CodeGen. 58 | */ 59 | String[] value(); 60 | 61 | /** 62 | * Date when the source was generated. 63 | */ 64 | String date() default ""; 65 | 66 | /** 67 | * A place holder for any comments that the code generator may want to 68 | * include in the generated code. 69 | */ 70 | String comments() default ""; 71 | } 72 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/Completions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | /** 29 | * Utility class for assembling {@link Completion} objects. 30 | * 31 | * @author Joseph D. Darcy 32 | * @author Scott Seligman 33 | * @author Peter von der Ahé 34 | * @since 1.6 35 | */ 36 | public class Completions { 37 | // No instances for you. 38 | private Completions() {} 39 | 40 | private static class SimpleCompletion implements Completion { 41 | private String value; 42 | private String message; 43 | 44 | SimpleCompletion(String value, String message) { 45 | if (value == null || message == null) 46 | throw new NullPointerException("Null completion strings not accepted."); 47 | this.value = value; 48 | this.message = message; 49 | } 50 | 51 | public String getValue() { 52 | return value; 53 | } 54 | 55 | 56 | public String getMessage() { 57 | return message; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "[\"" + value + "\", \"" + message + "\"]"; 63 | } 64 | // Default equals and hashCode are fine. 65 | } 66 | 67 | /** 68 | * Returns a completion of the value and message. 69 | * 70 | * @param value the text of the completion 71 | * @param message a message about the completion 72 | * @return a completion of the provided value and message 73 | */ 74 | public static Completion of(String value, String message) { 75 | return new SimpleCompletion(value, message); 76 | } 77 | 78 | /** 79 | * Returns a completion of the value and an empty message 80 | * 81 | * @param value the text of the completion 82 | * @return a completion of the value and an empty message 83 | */ 84 | public static Completion of(String value) { 85 | return new SimpleCompletion(value, ""); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/UnknownTypeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import javax.lang.model.UnknownEntityException; 29 | 30 | /** 31 | * Indicates that an unknown kind of type was encountered. This can 32 | * occur if the language evolves and new kinds of types are added to 33 | * the {@code TypeMirror} hierarchy. May be thrown by a {@linkplain 34 | * TypeVisitor type visitor} to indicate that the visitor was created 35 | * for a prior version of the language. 36 | * 37 | * @author Joseph D. Darcy 38 | * @author Scott Seligman 39 | * @author Peter von der Ahé 40 | * @see TypeVisitor#visitUnknown 41 | * @since 1.6 42 | */ 43 | public class UnknownTypeException extends UnknownEntityException { 44 | 45 | private static final long serialVersionUID = 269L; 46 | 47 | private transient TypeMirror type; 48 | private transient Object parameter; 49 | 50 | /** 51 | * Creates a new {@code UnknownTypeException}.The {@code p} 52 | * parameter may be used to pass in an additional argument with 53 | * information about the context in which the unknown type was 54 | * encountered; for example, the visit methods of {@link 55 | * TypeVisitor} may pass in their additional parameter. 56 | * 57 | * @param t the unknown type, may be {@code null} 58 | * @param p an additional parameter, may be {@code null} 59 | */ 60 | public UnknownTypeException(TypeMirror t, Object p) { 61 | super("Unknown type: " + t); 62 | type = t; 63 | this.parameter = p; 64 | } 65 | 66 | /** 67 | * Returns the unknown type. 68 | * The value may be unavailable if this exception has been 69 | * serialized and then read back in. 70 | * 71 | * @return the unknown type, or {@code null} if unavailable 72 | */ 73 | public TypeMirror getUnknownType() { 74 | return type; 75 | } 76 | 77 | /** 78 | * Returns the additional argument. 79 | * 80 | * @return the additional argument 81 | */ 82 | public Object getArgument() { 83 | return parameter; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/TypeVariable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | import javax.lang.model.element.Element; 30 | import javax.lang.model.element.TypeParameterElement; 31 | import javax.lang.model.util.Types; 32 | 33 | 34 | /** 35 | * Represents a type variable. 36 | * A type variable may be explicitly declared by a 37 | * {@linkplain TypeParameterElement type parameter} of a 38 | * type, method, or constructor. 39 | * A type variable may also be declared implicitly, as by 40 | * the capture conversion of a wildcard type argument 41 | * (see chapter 5 of 42 | * The Java™ Language Specification). 43 | * 44 | * @author Joseph D. Darcy 45 | * @author Scott Seligman 46 | * @author Peter von der Ahé 47 | * @see TypeParameterElement 48 | * @since 1.6 49 | */ 50 | public interface TypeVariable extends ReferenceType { 51 | 52 | /** 53 | * Returns the element corresponding to this type variable. 54 | * 55 | * @return the element corresponding to this type variable 56 | */ 57 | Element asElement(); 58 | 59 | /** 60 | * Returns the upper bound of this type variable. 61 | * 62 | *

If this type variable was declared with no explicit 63 | * upper bounds, the result is {@code java.lang.Object}. 64 | * If it was declared with multiple upper bounds, 65 | * the result is an {@linkplain IntersectionType intersection type}; 66 | * individual bounds can be found by examining the result's 67 | * {@linkplain IntersectionType#getBounds() bounds}. 68 | * 69 | * @return the upper bound of this type variable 70 | */ 71 | TypeMirror getUpperBound(); 72 | 73 | /** 74 | * Returns the lower bound of this type variable. While a type 75 | * parameter cannot include an explicit lower bound declaration, 76 | * capture conversion can produce a type variable with a 77 | * non-trivial lower bound. Type variables otherwise have a 78 | * lower bound of {@link NullType}. 79 | * 80 | * @return the lower bound of this type variable 81 | */ 82 | TypeMirror getLowerBound(); 83 | } 84 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/UnknownElementException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import javax.lang.model.UnknownEntityException; 29 | 30 | /** 31 | * Indicates that an unknown kind of element was encountered. This 32 | * can occur if the language evolves and new kinds of elements are 33 | * added to the {@code Element} hierarchy. May be thrown by an 34 | * {@linkplain ElementVisitor element visitor} to indicate that the 35 | * visitor was created for a prior version of the language. 36 | * 37 | * @author Joseph D. Darcy 38 | * @author Scott Seligman 39 | * @author Peter von der Ahé 40 | * @see ElementVisitor#visitUnknown 41 | * @since 1.6 42 | */ 43 | public class UnknownElementException extends UnknownEntityException { 44 | 45 | private static final long serialVersionUID = 269L; 46 | 47 | private transient Element element; 48 | private transient Object parameter; 49 | 50 | /** 51 | * Creates a new {@code UnknownElementException}. The {@code p} 52 | * parameter may be used to pass in an additional argument with 53 | * information about the context in which the unknown element was 54 | * encountered; for example, the visit methods of {@link 55 | * ElementVisitor} may pass in their additional parameter. 56 | * 57 | * @param e the unknown element, may be {@code null} 58 | * @param p an additional parameter, may be {@code null} 59 | */ 60 | public UnknownElementException(Element e, Object p) { 61 | super("Unknown element: " + e); 62 | element = e; 63 | this.parameter = p; 64 | } 65 | 66 | /** 67 | * Returns the unknown element. 68 | * The value may be unavailable if this exception has been 69 | * serialized and then read back in. 70 | * 71 | * @return the unknown element, or {@code null} if unavailable 72 | */ 73 | public Element getUnknownElement() { 74 | return element; 75 | } 76 | 77 | /** 78 | * Returns the additional argument. 79 | * 80 | * @return the additional argument 81 | */ 82 | public Object getArgument() { 83 | return parameter; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/PackageElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * Represents a package program element. Provides access to information 32 | * about the package and its members. 33 | * 34 | * @author Joseph D. Darcy 35 | * @author Scott Seligman 36 | * @author Peter von der Ahé 37 | * @see javax.lang.model.util.Elements#getPackageOf 38 | * @since 1.6 39 | */ 40 | public interface PackageElement extends Element, QualifiedNameable { 41 | 42 | /** 43 | * Returns the fully qualified name of this package. 44 | * This is also known as the package's canonical name. 45 | * 46 | * @return the fully qualified name of this package, or an 47 | * empty name if this is an unnamed package 48 | * @jls 6.7 Fully Qualified Names and Canonical Names 49 | */ 50 | Name getQualifiedName(); 51 | 52 | /** 53 | * Returns the simple name of this package. For an unnamed 54 | * package, an empty name is returned. 55 | * 56 | * @return the simple name of this package or an empty name if 57 | * this is an unnamed package 58 | */ 59 | @Override 60 | Name getSimpleName(); 61 | 62 | /** 63 | * Returns the {@linkplain NestingKind#TOP_LEVEL top-level} 64 | * classes and interfaces within this package. Note that 65 | * subpackages are not considered to be enclosed by a 66 | * package. 67 | * 68 | * @return the top-level classes and interfaces within this 69 | * package 70 | */ 71 | @Override 72 | List getEnclosedElements(); 73 | 74 | /** 75 | * Returns {@code true} is this is an unnamed package and {@code 76 | * false} otherwise. 77 | * 78 | * @return {@code true} is this is an unnamed package and {@code 79 | * false} otherwise 80 | * @jls 7.4.2 Unnamed Packages 81 | */ 82 | boolean isUnnamed(); 83 | 84 | /** 85 | * Returns {@code null} since a package is not enclosed by another 86 | * element. 87 | * 88 | * @return {@code null} 89 | */ 90 | @Override 91 | Element getEnclosingElement(); 92 | } 93 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/UnknownAnnotationValueException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import javax.lang.model.UnknownEntityException; 29 | 30 | /** 31 | * Indicates that an unknown kind of annotation value was encountered. 32 | * This can occur if the language evolves and new kinds of annotation 33 | * values can be stored in an annotation. May be thrown by an 34 | * {@linkplain AnnotationValueVisitor annotation value visitor} to 35 | * indicate that the visitor was created for a prior version of the 36 | * language. 37 | * 38 | * @author Joseph D. Darcy 39 | * @author Scott Seligman 40 | * @author Peter von der Ahé 41 | * @see AnnotationValueVisitor#visitUnknown 42 | * @since 1.6 43 | */ 44 | public class UnknownAnnotationValueException extends UnknownEntityException { 45 | 46 | private static final long serialVersionUID = 269L; 47 | 48 | private transient AnnotationValue av; 49 | private transient Object parameter; 50 | 51 | /** 52 | * Creates a new {@code UnknownAnnotationValueException}. The 53 | * {@code p} parameter may be used to pass in an additional 54 | * argument with information about the context in which the 55 | * unknown annotation value was encountered; for example, the 56 | * visit methods of {@link AnnotationValueVisitor} may pass in 57 | * their additional parameter. 58 | * 59 | * @param av the unknown annotation value, may be {@code null} 60 | * @param p an additional parameter, may be {@code null} 61 | */ 62 | public UnknownAnnotationValueException(AnnotationValue av, Object p) { 63 | super("Unknown annotation value: " + av); 64 | this.av = av; 65 | this.parameter = p; 66 | } 67 | 68 | /** 69 | * Returns the unknown annotation value. 70 | * The value may be unavailable if this exception has been 71 | * serialized and then read back in. 72 | * 73 | * @return the unknown element, or {@code null} if unavailable 74 | */ 75 | public AnnotationValue getUnknownAnnotationValue() { 76 | return av; 77 | } 78 | 79 | /** 80 | * Returns the additional argument. 81 | * 82 | * @return the additional argument 83 | */ 84 | public Object getArgument() { 85 | return parameter; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/DeclaredType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | import java.util.List; 30 | 31 | import javax.lang.model.element.Element; 32 | import javax.lang.model.element.TypeElement; 33 | import javax.lang.model.util.Types; 34 | 35 | 36 | /** 37 | * Represents a declared type, either a class type or an interface type. 38 | * This includes parameterized types such as {@code java.util.Set} 39 | * as well as raw types. 40 | * 41 | *

While a {@code TypeElement} represents a class or interface 42 | * element, a {@code DeclaredType} represents a class 43 | * or interface type, the latter being a use 44 | * (or invocation) of the former. 45 | * See {@link TypeElement} for more on this distinction. 46 | * 47 | *

The supertypes (both class and interface types) of a declared 48 | * type may be found using the {@link 49 | * Types#directSupertypes(TypeMirror)} method. This returns the 50 | * supertypes with any type arguments substituted in. 51 | * 52 | * @author Joseph D. Darcy 53 | * @author Scott Seligman 54 | * @author Peter von der Ahé 55 | * @see TypeElement 56 | * @since 1.6 57 | */ 58 | public interface DeclaredType extends ReferenceType { 59 | 60 | /** 61 | * Returns the element corresponding to this type. 62 | * 63 | * @return the element corresponding to this type 64 | */ 65 | Element asElement(); 66 | 67 | /** 68 | * Returns the type of the innermost enclosing instance or a 69 | * {@code NoType} of kind {@code NONE} if there is no enclosing 70 | * instance. Only types corresponding to inner classes have an 71 | * enclosing instance. 72 | * 73 | * @return a type mirror for the enclosing type 74 | * @jls 8.1.3 Inner Classes and Enclosing Instances 75 | * @jls 15.9.2 Determining Enclosing Instances 76 | */ 77 | TypeMirror getEnclosingType(); 78 | 79 | /** 80 | * Returns the actual type arguments of this type. 81 | * For a type nested within a parameterized type 82 | * (such as {@code Outer.Inner}), only the type 83 | * arguments of the innermost type are included. 84 | * 85 | * @return the actual type arguments of this type, or an empty list 86 | * if none 87 | */ 88 | List getTypeArguments(); 89 | } 90 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/MirroredTypesException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.Collections; 31 | import java.io.ObjectInputStream; 32 | import java.io.IOException; 33 | import javax.lang.model.element.Element; 34 | 35 | 36 | /** 37 | * Thrown when an application attempts to access a sequence of {@link 38 | * Class} objects each corresponding to a {@link TypeMirror}. 39 | * 40 | * @author Joseph D. Darcy 41 | * @author Scott Seligman 42 | * @author Peter von der Ahé 43 | * @see MirroredTypeException 44 | * @see Element#getAnnotation(Class) 45 | * @since 1.6 46 | */ 47 | public class MirroredTypesException extends RuntimeException { 48 | 49 | private static final long serialVersionUID = 269; 50 | 51 | transient List types; // cannot be serialized 52 | 53 | /* 54 | * Trusted constructor to be called by MirroredTypeException. 55 | */ 56 | MirroredTypesException(String message, TypeMirror type) { 57 | super(message); 58 | List tmp = (new ArrayList()); 59 | tmp.add(type); 60 | types = Collections.unmodifiableList(tmp); 61 | } 62 | 63 | /** 64 | * Constructs a new MirroredTypesException for the specified types. 65 | * 66 | * @param types the types being accessed 67 | */ 68 | public MirroredTypesException(List types) { 69 | super("Attempt to access Class objects for TypeMirrors " + 70 | (types = // defensive copy 71 | new ArrayList(types)).toString() ); 72 | this.types = Collections.unmodifiableList(types); 73 | } 74 | 75 | /** 76 | * Returns the type mirrors corresponding to the types being accessed. 77 | * The type mirrors may be unavailable if this exception has been 78 | * serialized and then read back in. 79 | * 80 | * @return the type mirrors in construction order, or {@code null} if unavailable 81 | */ 82 | public List getTypeMirrors() { 83 | return types; 84 | } 85 | 86 | /** 87 | * Explicitly set all transient fields. 88 | */ 89 | private void readObject(ObjectInputStream s) 90 | throws IOException, ClassNotFoundException { 91 | s.defaultReadObject(); 92 | types = null; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/PreDestroy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation; 27 | 28 | import java.lang.annotation.*; 29 | import static java.lang.annotation.ElementType.*; 30 | import static java.lang.annotation.RetentionPolicy.*; 31 | 32 | /** 33 | * The PreDestroy annotation is used on methods as a callback notification to 34 | * signal that the instance is in the process of being removed by the 35 | * container. The method annotated with PreDestroy is typically used to 36 | * release resources that it has been holding. This annotation MUST be 37 | * supported by all container managed objects that support PostConstruct 38 | * except the application client container in Java EE 5. The method on which 39 | * the PreDestroy annotation is applied MUST fulfill all of the following 40 | * criteria: 41 | *

42 | *

    43 | *
  • The method MUST NOT have any parameters except in the case of 44 | * interceptors in which case it takes an InvocationContext object as 45 | * defined by the Interceptors specification.
  • 46 | *
  • The method defined on an interceptor class MUST HAVE one of the 47 | * following signatures: 48 | *

    49 | * void <METHOD>(InvocationContext) 50 | *

    51 | * Object <METHOD>(InvocationContext) throws Exception 52 | *

    53 | * Note: A PreDestroy interceptor method must not throw application 54 | * exceptions, but it may be declared to throw checked exceptions including 55 | * the java.lang.Exception if the same interceptor method interposes on 56 | * business or timeout methods in addition to lifecycle events. If a 57 | * PreDestroy interceptor method returns a value, it is ignored by 58 | * the container. 59 | *

  • 60 | *
  • The method defined on a non-interceptor class MUST HAVE the 61 | * following signature: 62 | *

    63 | * void <METHOD>() 64 | *

  • 65 | *
  • The method on which PreDestroy is applied MAY be public, protected, 66 | * package private or private.
  • 67 | *
  • The method MUST NOT be static.
  • 68 | *
  • The method MAY be final.
  • 69 | *
  • If the method throws an unchecked exception it is ignored except in the 70 | * case of EJBs where the EJB can handle exceptions.
  • 71 | *
72 | * 73 | * @see javax.annotation.PostConstruct 74 | * @see javax.annotation.Resource 75 | * @since Common Annotations 1.0 76 | */ 77 | 78 | @Documented 79 | @Retention (RUNTIME) 80 | @Target(METHOD) 81 | public @interface PreDestroy { 82 | } 83 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Provides interfaces for tools which can be invoked from a program, 28 | * for example, compilers. 29 | * 30 | *

These interfaces and classes are required as part of the 31 | * Java™ Platform, Standard Edition (Java SE), 32 | * but there is no requirement to provide any tools implementing them. 33 | * 34 | *

Unless explicitly allowed, all methods in this package might 35 | * throw a {@linkplain java.lang.NullPointerException} if given a 36 | * {@code null} argument or if given a 37 | * {@linkplain java.lang.Iterable list or collection} containing 38 | * {@code null} elements. Similarly, no method may return 39 | * {@code null} unless explicitly allowed. 40 | * 41 | *

This package is the home of the Java programming language compiler framework. This 42 | * framework allows clients of the framework to locate and run 43 | * compilers from programs. The framework also provides Service 44 | * Provider Interfaces (SPI) for structured access to diagnostics 45 | * ({@linkplain javax.tools.DiagnosticListener}) as well as a file 46 | * abstraction for overriding file access ({@linkplain 47 | * javax.tools.JavaFileManager} and {@linkplain 48 | * javax.tools.JavaFileObject}). See {@linkplain 49 | * javax.tools.JavaCompiler} for more details on using the SPI. 50 | * 51 | *

There is no requirement for a compiler at runtime. However, if 52 | * a default compiler is provided, it can be located using the 53 | * {@linkplain javax.tools.ToolProvider}, for example: 54 | * 55 | *

{@code JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();} 56 | * 57 | *

It is possible to provide alternative compilers or tools 58 | * through the {@linkplain java.util.ServiceLoader service provider 59 | * mechanism}. 60 | * 61 | *

For example, if {@code com.vendor.VendorJavaCompiler} is a 62 | * provider of the {@code JavaCompiler} tool then its jar file 63 | * would contain the file {@code 64 | * META-INF/services/javax.tools.JavaCompiler}. This file would 65 | * contain the single line: 66 | * 67 | *

{@code com.vendor.VendorJavaCompiler} 68 | * 69 | *

If the jar file is on the class path, VendorJavaCompiler can be 70 | * located using code like this: 71 | * 72 | *

{@code JavaCompiler compiler = ServiceLoader.load(JavaCompiler.class).iterator().next();} 73 | * 74 | * @author Peter von der Ahé 75 | * @author Jonathan Gibbons 76 | * @since 1.6 77 | */ 78 | package javax.tools; 79 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/VariableElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | import javax.lang.model.util.Elements; 29 | 30 | /** 31 | * Represents a field, {@code enum} constant, method or constructor 32 | * parameter, local variable, resource variable, or exception 33 | * parameter. 34 | * 35 | * @author Joseph D. Darcy 36 | * @author Scott Seligman 37 | * @author Peter von der Ahé 38 | * @since 1.6 39 | */ 40 | public interface VariableElement extends Element { 41 | 42 | /** 43 | * Returns the value of this variable if this is a {@code final} 44 | * field initialized to a compile-time constant. Returns {@code 45 | * null} otherwise. The value will be of a primitive type or a 46 | * {@code String}. If the value is of a primitive type, it is 47 | * wrapped in the appropriate wrapper class (such as {@link 48 | * Integer}). 49 | * 50 | *

Note that not all {@code final} fields will have 51 | * constant values. In particular, {@code enum} constants are 52 | * not considered to be compile-time constants. To have a 53 | * constant value, a field's type must be either a primitive type 54 | * or {@code String}. 55 | * 56 | * @return the value of this variable if this is a {@code final} 57 | * field initialized to a compile-time constant, or {@code null} 58 | * otherwise 59 | * 60 | * @see Elements#getConstantExpression(Object) 61 | * @jls 15.28 Constant Expression 62 | * @jls 4.12.4 final Variables 63 | */ 64 | Object getConstantValue(); 65 | 66 | /** 67 | * Returns the simple name of this variable element. 68 | * 69 | *

For method and constructor parameters, the name of each 70 | * parameter must be distinct from the names of all other 71 | * parameters of the same executable. If the original source 72 | * names are not available, an implementation may synthesize names 73 | * subject to the distinctness requirement above. 74 | * 75 | * @return the simple name of this variable element 76 | */ 77 | @Override 78 | Name getSimpleName(); 79 | 80 | /** 81 | * Returns the enclosing element of this variable. 82 | * 83 | * The enclosing element of a method or constructor parameter is 84 | * the executable declaring the parameter. 85 | * 86 | * @return the enclosing element of this variable 87 | */ 88 | @Override 89 | Element getEnclosingElement(); 90 | } 91 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/PostConstruct.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation; 27 | 28 | import java.lang.annotation.*; 29 | import static java.lang.annotation.ElementType.*; 30 | import static java.lang.annotation.RetentionPolicy.*; 31 | 32 | /** 33 | * The PostConstruct annotation is used on a method that needs to be executed 34 | * after dependency injection is done to perform any initialization. This 35 | * method MUST be invoked before the class is put into service. This 36 | * annotation MUST be supported on all classes that support dependency 37 | * injection. The method annotated with PostConstruct MUST be invoked even 38 | * if the class does not request any resources to be injected. Only one 39 | * method can be annotated with this annotation. The method on which the 40 | * PostConstruct annotation is applied MUST fulfill all of the following 41 | * criteria: 42 | *

43 | *

    44 | *
  • The method MUST NOT have any parameters except in the case of 45 | * interceptors in which case it takes an InvocationContext object as 46 | * defined by the Interceptors specification.
  • 47 | *
  • The method defined on an interceptor class MUST HAVE one of the 48 | * following signatures: 49 | *

    50 | * void <METHOD>(InvocationContext) 51 | *

    52 | * Object <METHOD>(InvocationContext) throws Exception 53 | *

    54 | * Note: A PostConstruct interceptor method must not throw application 55 | * exceptions, but it may be declared to throw checked exceptions including 56 | * the java.lang.Exception if the same interceptor method interposes on 57 | * business or timeout methods in addition to lifecycle events. If a 58 | * PostConstruct interceptor method returns a value, it is ignored by 59 | * the container. 60 | *

  • 61 | *
  • The method defined on a non-interceptor class MUST HAVE the 62 | * following signature: 63 | *

    64 | * void <METHOD>() 65 | *

  • 66 | *
  • The method on which PostConstruct is applied MAY be public, protected, 67 | * package private or private.
  • 68 | *
  • The method MUST NOT be static except for the application client.
  • 69 | *
  • The method MAY be final.
  • 70 | *
  • If the method throws an unchecked exception the class MUST NOT be put into 71 | * service except in the case of EJBs where the EJB can handle exceptions and 72 | * even recover from them.
73 | * @since Common Annotations 1.0 74 | * @see javax.annotation.PreDestroy 75 | * @see javax.annotation.Resource 76 | */ 77 | @Documented 78 | @Retention (RUNTIME) 79 | @Target(METHOD) 80 | public @interface PostConstruct { 81 | } 82 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractAnnotationValueVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import static javax.lang.model.SourceVersion.*; 29 | import javax.lang.model.SourceVersion; 30 | import javax.annotation.processing.SupportedSourceVersion; 31 | 32 | /** 33 | * A skeletal visitor for annotation values with default behavior 34 | * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} 35 | * source version. 36 | * 37 | *

WARNING: The {@code AnnotationValueVisitor} interface 38 | * implemented by this class may have methods added to it in the 39 | * future to accommodate new, currently unknown, language structures 40 | * added to future versions of the Java™ programming language. 41 | * Therefore, methods whose names begin with {@code "visit"} may be 42 | * added to this class in the future; to avoid incompatibilities, 43 | * classes which extend this class should not declare any instance 44 | * methods with names beginning with {@code "visit"}. 45 | * 46 | *

When such a new visit method is added, the default 47 | * implementation in this class will be to call the {@link 48 | * #visitUnknown visitUnknown} method. A new abstract annotation 49 | * value visitor class will also be introduced to correspond to the 50 | * new language level; this visitor will have different default 51 | * behavior for the visit method in question. When the new visitor is 52 | * introduced, all or portions of this visitor may be deprecated. 53 | * 54 | *

Note that adding a default implementation of a new visit method 55 | * in a visitor class will occur instead of adding a default 56 | * method directly in the visitor interface since a Java SE 8 57 | * language feature cannot be used to this version of the API since 58 | * this version is required to be runnable on Java SE 7 59 | * implementations. Future versions of the API that are only required 60 | * to run on Java SE 8 and later may take advantage of default methods 61 | * in this situation. 62 | * 63 | * @param the return type of this visitor's methods 64 | * @param

the type of the additional parameter to this visitor's methods. 65 | * 66 | * @see AbstractAnnotationValueVisitor6 67 | * @see AbstractAnnotationValueVisitor8 68 | * @since 1.7 69 | */ 70 | @SupportedSourceVersion(RELEASE_7) 71 | public abstract class AbstractAnnotationValueVisitor7 extends AbstractAnnotationValueVisitor6 { 72 | 73 | /** 74 | * Constructor for concrete subclasses to call. 75 | */ 76 | protected AbstractAnnotationValueVisitor7() { 77 | super(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractAnnotationValueVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import static javax.lang.model.SourceVersion.*; 29 | import javax.lang.model.SourceVersion; 30 | import javax.annotation.processing.SupportedSourceVersion; 31 | 32 | /** 33 | * A skeletal visitor for annotation values with default behavior 34 | * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} 35 | * source version. 36 | * 37 | *

WARNING: The {@code AnnotationValueVisitor} interface 38 | * implemented by this class may have methods added to it in the 39 | * future to accommodate new, currently unknown, language structures 40 | * added to future versions of the Java™ programming language. 41 | * Therefore, methods whose names begin with {@code "visit"} may be 42 | * added to this class in the future; to avoid incompatibilities, 43 | * classes which extend this class should not declare any instance 44 | * methods with names beginning with {@code "visit"}. 45 | * 46 | *

When such a new visit method is added, the default 47 | * implementation in this class will be to call the {@link 48 | * #visitUnknown visitUnknown} method. A new abstract annotation 49 | * value visitor class will also be introduced to correspond to the 50 | * new language level; this visitor will have different default 51 | * behavior for the visit method in question. When the new visitor is 52 | * introduced, all or portions of this visitor may be deprecated. 53 | * 54 | *

Note that adding a default implementation of a new visit method 55 | * in a visitor class will occur instead of adding a default 56 | * method directly in the visitor interface since a Java SE 8 57 | * language feature cannot be used to this version of the API since 58 | * this version is required to be runnable on Java SE 7 59 | * implementations. Future versions of the API that are only required 60 | * to run on Java SE 8 and later may take advantage of default methods 61 | * in this situation. 62 | * 63 | * @param the return type of this visitor's methods 64 | * @param

the type of the additional parameter to this visitor's methods. 65 | * 66 | * @see AbstractAnnotationValueVisitor6 67 | * @see AbstractAnnotationValueVisitor7 68 | * @since 1.8 69 | */ 70 | @SupportedSourceVersion(RELEASE_8) 71 | public abstract class AbstractAnnotationValueVisitor8 extends AbstractAnnotationValueVisitor7 { 72 | 73 | /** 74 | * Constructor for concrete subclasses to call. 75 | */ 76 | protected AbstractAnnotationValueVisitor8() { 77 | super(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/Name.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | /** 29 | * An immutable sequence of characters. When created by the same 30 | * implementation, objects implementing this interface must obey the 31 | * general {@linkplain Object#equals equals contract} when compared 32 | * with each other. Therefore, {@code Name} objects from the same 33 | * implementation are usable in collections while {@code Name}s from 34 | * different implementations may not work properly in collections. 35 | * 36 | *

An empty {@code Name} has a length of zero. 37 | * 38 | *

In the context of {@linkplain 39 | * javax.annotation.processing.ProcessingEnvironment annotation 40 | * processing}, the guarantees for "the same" implementation must 41 | * include contexts where the {@linkplain javax.annotation.processing 42 | * API mediated} side effects of {@linkplain 43 | * javax.annotation.processing.Processor processors} could be visible 44 | * to each other, including successive annotation processing 45 | * {@linkplain javax.annotation.processing.RoundEnvironment rounds}. 46 | * 47 | * @author Joseph D. Darcy 48 | * @author Scott Seligman 49 | * @author Peter von der Ahé 50 | * @see javax.lang.model.util.Elements#getName 51 | * @since 1.6 52 | */ 53 | public interface Name extends CharSequence { 54 | /** 55 | * Returns {@code true} if the argument represents the same 56 | * name as {@code this}, and {@code false} otherwise. 57 | * 58 | *

Note that the identity of a {@code Name} is a function both 59 | * of its content in terms of a sequence of characters as well as 60 | * the implementation which created it. 61 | * 62 | * @param obj the object to be compared with this element 63 | * @return {@code true} if the specified object represents the same 64 | * name as this 65 | * @see Element#equals 66 | */ 67 | boolean equals(Object obj); 68 | 69 | /** 70 | * Obeys the general contract of {@link Object#hashCode Object.hashCode}. 71 | * 72 | * @see #equals 73 | */ 74 | int hashCode(); 75 | 76 | /** 77 | * Compares this name to the specified {@code CharSequence}. The result 78 | * is {@code true} if and only if this name represents the same sequence 79 | * of {@code char} values as the specified sequence. 80 | * 81 | * @return {@code true} if this name represents the same sequence 82 | * of {@code char} values as the specified sequence, {@code false} 83 | * otherwise 84 | * 85 | * @param cs The sequence to compare this name against 86 | * @see String#contentEquals(CharSequence) 87 | */ 88 | boolean contentEquals(CharSequence cs); 89 | } 90 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractElementVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | 32 | 33 | /** 34 | * A skeletal visitor of program elements with default behavior 35 | * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} 36 | * source version. 37 | * 38 | *

WARNING: The {@code ElementVisitor} interface 39 | * implemented by this class may have methods added to it in the 40 | * future to accommodate new, currently unknown, language structures 41 | * added to future versions of the Java™ programming language. 42 | * Therefore, methods whose names begin with {@code "visit"} may be 43 | * added to this class in the future; to avoid incompatibilities, 44 | * classes which extend this class should not declare any instance 45 | * methods with names beginning with {@code "visit"}. 46 | * 47 | *

When such a new visit method is added, the default 48 | * implementation in this class will be to call the {@link 49 | * #visitUnknown visitUnknown} method. A new abstract element visitor 50 | * class will also be introduced to correspond to the new language 51 | * level; this visitor will have different default behavior for the 52 | * visit method in question. When the new visitor is introduced, all 53 | * or portions of this visitor may be deprecated. 54 | * 55 | *

Note that adding a default implementation of a new visit method 56 | * in a visitor class will occur instead of adding a default 57 | * method directly in the visitor interface since a Java SE 8 58 | * language feature cannot be used to this version of the API since 59 | * this version is required to be runnable on Java SE 7 60 | * implementations. Future versions of the API that are only required 61 | * to run on Java SE 8 and later may take advantage of default methods 62 | * in this situation. 63 | * 64 | * @param the return type of this visitor's methods. Use {@link 65 | * Void} for visitors that do not need to return results. 66 | * @param

the type of the additional parameter to this visitor's 67 | * methods. Use {@code Void} for visitors that do not need an 68 | * additional parameter. 69 | * 70 | * @see AbstractElementVisitor6 71 | * @see AbstractElementVisitor8 72 | * @since 1.7 73 | */ 74 | @SupportedSourceVersion(RELEASE_7) 75 | public abstract class AbstractElementVisitor7 extends AbstractElementVisitor6 { 76 | /** 77 | * Constructor for concrete subclasses to call. 78 | */ 79 | protected AbstractElementVisitor7(){ 80 | super(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractElementVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | 32 | 33 | /** 34 | * A skeletal visitor of program elements with default behavior 35 | * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} 36 | * source version. 37 | * 38 | *

WARNING: The {@code ElementVisitor} interface 39 | * implemented by this class may have methods added to it in the 40 | * future to accommodate new, currently unknown, language structures 41 | * added to future versions of the Java™ programming language. 42 | * Therefore, methods whose names begin with {@code "visit"} may be 43 | * added to this class in the future; to avoid incompatibilities, 44 | * classes which extend this class should not declare any instance 45 | * methods with names beginning with {@code "visit"}. 46 | * 47 | *

When such a new visit method is added, the default 48 | * implementation in this class will be to call the {@link 49 | * #visitUnknown visitUnknown} method. A new abstract element visitor 50 | * class will also be introduced to correspond to the new language 51 | * level; this visitor will have different default behavior for the 52 | * visit method in question. When the new visitor is introduced, all 53 | * or portions of this visitor may be deprecated. 54 | * 55 | *

Note that adding a default implementation of a new visit method 56 | * in a visitor class will occur instead of adding a default 57 | * method directly in the visitor interface since a Java SE 8 58 | * language feature cannot be used to this version of the API since 59 | * this version is required to be runnable on Java SE 7 60 | * implementations. Future versions of the API that are only required 61 | * to run on Java SE 8 and later may take advantage of default methods 62 | * in this situation. 63 | * 64 | * @param the return type of this visitor's methods. Use {@link 65 | * Void} for visitors that do not need to return results. 66 | * @param

the type of the additional parameter to this visitor's 67 | * methods. Use {@code Void} for visitors that do not need an 68 | * additional parameter. 69 | * 70 | * @see AbstractElementVisitor6 71 | * @see AbstractElementVisitor7 72 | * @since 1.8 73 | */ 74 | @SupportedSourceVersion(RELEASE_8) 75 | public abstract class AbstractElementVisitor8 extends AbstractElementVisitor7 { 76 | /** 77 | * Constructor for concrete subclasses to call. 78 | */ 79 | protected AbstractElementVisitor8(){ 80 | super(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/StandardLocation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import javax.tools.JavaFileManager.Location; 29 | 30 | import java.util.concurrent.*; 31 | 32 | /** 33 | * Standard locations of file objects. 34 | * 35 | * @author Peter von der Ahé 36 | * @since 1.6 37 | */ 38 | public enum StandardLocation implements Location { 39 | 40 | /** 41 | * Location of new class files. 42 | */ 43 | CLASS_OUTPUT, 44 | 45 | /** 46 | * Location of new source files. 47 | */ 48 | SOURCE_OUTPUT, 49 | 50 | /** 51 | * Location to search for user class files. 52 | */ 53 | CLASS_PATH, 54 | 55 | /** 56 | * Location to search for existing source files. 57 | */ 58 | SOURCE_PATH, 59 | 60 | /** 61 | * Location to search for annotation processors. 62 | */ 63 | ANNOTATION_PROCESSOR_PATH, 64 | 65 | /** 66 | * Location to search for platform classes. Sometimes called 67 | * the boot class path. 68 | */ 69 | PLATFORM_CLASS_PATH, 70 | 71 | /** 72 | * Location of new native header files. 73 | * @since 1.8 74 | */ 75 | NATIVE_HEADER_OUTPUT; 76 | 77 | /** 78 | * Gets a location object with the given name. The following 79 | * property must hold: {@code locationFor(x) == 80 | * locationFor(y)} if and only if {@code x.equals(y)}. 81 | * The returned location will be an output location if and only if 82 | * name ends with {@code "_OUTPUT"}. 83 | * 84 | * @param name a name 85 | * @return a location 86 | */ 87 | public static Location locationFor(final String name) { 88 | if (locations.isEmpty()) { 89 | // can't use valueOf which throws IllegalArgumentException 90 | for (Location location : values()) 91 | locations.putIfAbsent(location.getName(), location); 92 | } 93 | locations.putIfAbsent(name.toString(/* null-check */), new Location() { 94 | public String getName() { return name; } 95 | public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); } 96 | }); 97 | return locations.get(name); 98 | } 99 | //where 100 | private static final ConcurrentMap locations 101 | = new ConcurrentHashMap(); 102 | 103 | public String getName() { return name(); } 104 | 105 | public boolean isOutputLocation() { 106 | switch (this) { 107 | case CLASS_OUTPUT: 108 | case SOURCE_OUTPUT: 109 | case NATIVE_HEADER_OUTPUT: 110 | return true; 111 | default: 112 | return false; 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractTypeVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.type.*; 29 | 30 | /** 31 | * A skeletal visitor of types with default behavior appropriate for 32 | * the {@link javax.lang.model.SourceVersion#RELEASE_7 RELEASE_7} 33 | * source version. 34 | * 35 | *

WARNING: The {@code TypeVisitor} interface implemented 36 | * by this class may have methods added to it in the future to 37 | * accommodate new, currently unknown, language structures added to 38 | * future versions of the Java™ programming language. 39 | * Therefore, methods whose names begin with {@code "visit"} may be 40 | * added to this class in the future; to avoid incompatibilities, 41 | * classes which extend this class should not declare any instance 42 | * methods with names beginning with {@code "visit"}. 43 | * 44 | *

When such a new visit method is added, the default 45 | * implementation in this class will be to call the {@link 46 | * #visitUnknown visitUnknown} method. A new abstract type visitor 47 | * class will also be introduced to correspond to the new language 48 | * level; this visitor will have different default behavior for the 49 | * visit method in question. When the new visitor is introduced, all 50 | * or portions of this visitor may be deprecated. 51 | * 52 | *

Note that adding a default implementation of a new visit method 53 | * in a visitor class will occur instead of adding a default 54 | * method directly in the visitor interface since a Java SE 8 55 | * language feature cannot be used to this version of the API since 56 | * this version is required to be runnable on Java SE 7 57 | * implementations. Future versions of the API that are only required 58 | * to run on Java SE 8 and later may take advantage of default methods 59 | * in this situation. 60 | * 61 | * @param the return type of this visitor's methods. Use {@link 62 | * Void} for visitors that do not need to return results. 63 | * @param

the type of the additional parameter to this visitor's 64 | * methods. Use {@code Void} for visitors that do not need an 65 | * additional parameter. 66 | * 67 | * @see AbstractTypeVisitor6 68 | * @see AbstractTypeVisitor8 69 | * @since 1.7 70 | */ 71 | public abstract class AbstractTypeVisitor7 extends AbstractTypeVisitor6 { 72 | /** 73 | * Constructor for concrete subclasses to call. 74 | */ 75 | protected AbstractTypeVisitor7() { 76 | super(); 77 | } 78 | 79 | /** 80 | * Visits a {@code UnionType} in a manner defined by a subclass. 81 | * 82 | * @param t {@inheritDoc} 83 | * @param p {@inheritDoc} 84 | * @return the result of the visit as defined by a subclass 85 | */ 86 | public abstract R visitUnion(UnionType t, P p); 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractTypeVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.type.*; 29 | 30 | /** 31 | * A skeletal visitor of types with default behavior appropriate for 32 | * the {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8} 33 | * source version. 34 | * 35 | *

WARNING: The {@code TypeVisitor} interface implemented 36 | * by this class may have methods added to it in the future to 37 | * accommodate new, currently unknown, language structures added to 38 | * future versions of the Java™ programming language. 39 | * Therefore, methods whose names begin with {@code "visit"} may be 40 | * added to this class in the future; to avoid incompatibilities, 41 | * classes which extend this class should not declare any instance 42 | * methods with names beginning with {@code "visit"}. 43 | * 44 | *

When such a new visit method is added, the default 45 | * implementation in this class will be to call the {@link 46 | * #visitUnknown visitUnknown} method. A new abstract type visitor 47 | * class will also be introduced to correspond to the new language 48 | * level; this visitor will have different default behavior for the 49 | * visit method in question. When the new visitor is introduced, all 50 | * or portions of this visitor may be deprecated. 51 | * 52 | *

Note that adding a default implementation of a new visit method 53 | * in a visitor class will occur instead of adding a default 54 | * method directly in the visitor interface since a Java SE 8 55 | * language feature cannot be used to this version of the API since 56 | * this version is required to be runnable on Java SE 7 57 | * implementations. Future versions of the API that are only required 58 | * to run on Java SE 8 and later may take advantage of default methods 59 | * in this situation. 60 | * 61 | * @param the return type of this visitor's methods. Use {@link 62 | * Void} for visitors that do not need to return results. 63 | * @param

the type of the additional parameter to this visitor's 64 | * methods. Use {@code Void} for visitors that do not need an 65 | * additional parameter. 66 | * 67 | * @see AbstractTypeVisitor6 68 | * @see AbstractTypeVisitor7 69 | * @since 1.8 70 | */ 71 | public abstract class AbstractTypeVisitor8 extends AbstractTypeVisitor7 { 72 | /** 73 | * Constructor for concrete subclasses to call. 74 | */ 75 | protected AbstractTypeVisitor8() { 76 | super(); 77 | } 78 | 79 | /** 80 | * Visits an {@code IntersectionType} in a manner defined by a subclass. 81 | * 82 | * @param t {@inheritDoc} 83 | * @param p {@inheritDoc} 84 | * @return the result of the visit as defined by a subclass 85 | */ 86 | public abstract R visitIntersection(IntersectionType t, P p); 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/NestingKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | /** 29 | * The nesting kind of a type element. 30 | * Type elements come in four varieties: 31 | * top-level, member, local, and anonymous. 32 | * Nesting kind is a non-standard term used here to denote this 33 | * classification. 34 | * 35 | *

Note that it is possible additional nesting kinds will be added 36 | * in future versions of the platform. 37 | * 38 | *

Example: The classes below are annotated with their nesting kind. 39 | *

 40 |  *
 41 |  * import java.lang.annotation.*;
 42 |  * import static java.lang.annotation.RetentionPolicy.*;
 43 |  * import javax.lang.model.element.*;
 44 |  * import static javax.lang.model.element.NestingKind.*;
 45 |  *
 46 |  * @Nesting(TOP_LEVEL)
 47 |  * public class NestingExamples {
 48 |  *     @Nesting(MEMBER)
 49 |  *     static class MemberClass1{}
 50 |  *
 51 |  *     @Nesting(MEMBER)
 52 |  *     class MemberClass2{}
 53 |  *
 54 |  *     public static void main(String... argv) {
 55 |  *         @Nesting(LOCAL)
 56 |  *         class LocalClass{};
 57 |  *
 58 |  *         Class<?>[] classes = {
 59 |  *             NestingExamples.class,
 60 |  *             MemberClass1.class,
 61 |  *             MemberClass2.class,
 62 |  *             LocalClass.class
 63 |  *         };
 64 |  *
 65 |  *         for(Class<?> clazz : classes) {
 66 |  *             System.out.format("%s is %s%n",
 67 |  *                               clazz.getName(),
 68 |  *                               clazz.getAnnotation(Nesting.class).value());
 69 |  *         }
 70 |  *     }
 71 |  * }
 72 |  *
 73 |  * @Retention(RUNTIME)
 74 |  * @interface Nesting {
 75 |  *     NestingKind value();
 76 |  * }
 77 |  * 
78 | * 79 | * @author Joseph D. Darcy 80 | * @author Scott Seligman 81 | * @author Peter von der Ahé 82 | * @since 1.6 83 | */ 84 | public enum NestingKind { 85 | /** 86 | * A top-level type, not contained within another type. 87 | */ 88 | TOP_LEVEL, 89 | 90 | /** 91 | * A type that is a named member of another type. 92 | */ 93 | MEMBER, 94 | 95 | /** 96 | * A named type declared within a construct other than a type. 97 | */ 98 | LOCAL, 99 | 100 | /** 101 | * A type without a name. 102 | */ 103 | ANONYMOUS; 104 | 105 | /** 106 | * Does this constant correspond to a nested type element? 107 | * A nested type element is any that is not top-level. 108 | * An inner type element is any nested type element that 109 | * is not {@linkplain Modifier#STATIC static}. 110 | * @return whether or not the constant is nested 111 | */ 112 | public boolean isNested() { 113 | return this != TOP_LEVEL; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /library/src/main/java/me/denley/preferencebinder/internal/WidgetBindingType.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.internal; 2 | 3 | public enum WidgetBindingType { 4 | 5 | ASSIGN( 6 | null, 7 | "%s = %s", 8 | null, 9 | null 10 | ), 11 | ACTIVATED( 12 | PrefType.BOOLEAN, 13 | "%s.setActivated(%s)", 14 | null, 15 | null 16 | ), 17 | ENABLED( 18 | PrefType.BOOLEAN, 19 | "%s.setEnabled(%s)", 20 | null, 21 | null 22 | ), 23 | SELECTED( 24 | PrefType.BOOLEAN, 25 | "%s.setSelected(%s)", 26 | null, 27 | null 28 | ), 29 | VISIBILITY( 30 | PrefType.BOOLEAN, 31 | "%s.setVisibility(%s ? android.view.View.VISIBLE : android.view.View.GONE)", 32 | null, 33 | null 34 | ), 35 | CHECKED( 36 | PrefType.BOOLEAN, 37 | 38 | "%s.setChecked(%s)", 39 | 40 | "%s.setOnCheckedChangeListener(new android.widget.CompoundButton.OnCheckedChangeListener() {\n" + 41 | " @Override public void onCheckedChanged(final android.widget.CompoundButton buttonView, final boolean isChecked) {\n" + 42 | " prefs.edit().putBoolean(%s, isChecked).apply();\n" + 43 | " }\n" + 44 | " })", 45 | 46 | "%s.setOnCheckedChangeListener(null)" 47 | ), 48 | TEXT( 49 | PrefType.STRING, 50 | "%s.setText(%s)", 51 | null, 52 | null 53 | ), 54 | PROGRESS( 55 | PrefType.INTEGER, 56 | "%s.setProgress(%s)", 57 | null, 58 | null 59 | ), 60 | SEEKBAR_PROGRESS( 61 | PrefType.INTEGER, 62 | 63 | "%s.setProgress(%s)", 64 | 65 | "%s.setOnSeekBarChangeListener(new android.widget.SeekBar.OnSeekBarChangeListener() {\n" + 66 | " @Override public void onProgressChanged(final android.widget.SeekBar seekBar, final int progress, final boolean fromUser) {\n" + 67 | " prefs.edit().putInt(%s, progress).apply();\n" + 68 | " }\n" + 69 | " @Override public void onStartTrackingTouch(final android.widget.SeekBar seekBar) { }\n" + 70 | " @Override public void onStopTrackingTouch(final android.widget.SeekBar seekBar) { }\n" + 71 | " })", 72 | 73 | "%s.setOnSeekBarChangeListener(null)" 74 | ), 75 | MAX_PROGRESS( 76 | PrefType.INTEGER, 77 | "%s.setMax(%s)", 78 | null, 79 | null 80 | ); 81 | 82 | public final PrefType prefType; 83 | public final String bindingCall; 84 | public final String listenerCall; 85 | public final String listenerUnbind; 86 | 87 | WidgetBindingType(PrefType prefType, String bindingCall, String listenerCall, String listenerUnbind) { 88 | this.prefType = prefType; 89 | this.bindingCall = bindingCall; 90 | this.listenerCall = listenerCall; 91 | this.listenerUnbind = listenerUnbind; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | ## 3.1.0 - Unreleased 5 | ### Fixed 6 | - `PreferenceBinder.bind` and `PreferenceBinder.unbind` statement check now looks inside blocks/scopes (e.g. `if` blocks). 7 | - Added `PreferenceBinder.bind(Context context, Object target, SharedPreferences prefs)` to allow testing with mocked `SharedPreferences` files. 8 | 9 | ## 3.0.2 - 2015-08-03 10 | ### Removed 11 | - Removed compiler check for `PreferenceBinder.bind` and `PreferenceBinder.unbind` method calls pending testing and stability improvement to the feature 12 | 13 | ## 3.0.1 - 2015-08-02 14 | ### Fixed 15 | - Fixed NullPointerException when using this library in classes with abstract methods. 16 | - Updated bind/unbind statement checker to look in scopes inside methods. 17 | 18 | ## 3.0.0 - 2015-07-25 19 | ### Changed 20 | - New annotation `@BindPref` replaces both `@InjectPreference` and `@OnPreferenceChanged`. The `listen` flag now defaults to true 21 | - All instances of "inject", "injector", and "injection" have been replaced with "bind", "binding", and "binding". 22 | - `@PreferenceDefault` annotated fields now apply globally (application-wide) rather than just for their containing class. 23 | 24 | ### Added 25 | - `@BindPref` annotation may now be used on certain widget types (fields), to automatically bind the preference value to a widget's method. See README.md for details. 26 | - Compiler now checks for `PreferenceBinder.bind` and `PreferenceBinder.unbind` (when necessary) method calls in classes with `@BindPref` annotations. 27 | 28 | ## 2.2.1 - 2015-03-28 29 | ### Fixed 30 | - Set minSdk to 4, to prevent unnecessary permissions being added by default (see [this reference](https://code.google.com/p/android/issues/detail?id=4101) for explanation) 31 | 32 | ## 2.2.0 - 2015-03-01 33 | ### Added 34 | - Optional "listen" flag for `@InjectPreference` annotation as shorthand for also adding `@OnPreferenceChange` annotation to the same element 35 | - `OnPreferenceChange` annotations on methods can now contain multiple keys (if the method has zero parameters) 36 | 37 | ### Changed 38 | - Method calls now always occur after field updates for any given preference key (for both initialization and updates) 39 | - Annotated methods can now contain zero parameters, to disregard the preference value. 40 | 41 | ## 2.1.1 - 2015-02-25 42 | ### Added 43 | - `PreferenceInjector.bind(Fragment target)` method. The `Context` can be inferred from the `Fragment`. 44 | - `PreferenceInjector.bind(Service target)` method. The `Context` can be inferred from the `Service`. 45 | 46 | ## 2.1.0 - 2015-02-19 47 | ### Added 48 | - `@PreferenceDefault` annotation, to specify injection values when none exists in the `SharedPreferences` file 49 | 50 | ### Fixed 51 | - `String` and `Set` are now properly recognized as valid types 52 | 53 | ## 2.0.0 - 2015-02-19 54 | ### Changed 55 | - Removed `initialize` flag from `@OnPreferenceChange` annotation, `@InjectPreference` can now be applied to methods instead 56 | - Removed `autoUpdate` flag from `@InjectPreference` annotation, `@OnPreferenceChange` can now be applied to fields instead 57 | - `PreferenceInjector.unbind` no longer needs to be called if no `@OnPreferenceChange` annotations exist 58 | 59 | ## 1.0 - 2015-02-18 60 | ### Added 61 | - @InjectPreference and code generation for it 62 | - @OnPreferenceChange and code generation for it -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/ElementKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.element; 27 | 28 | /** 29 | * The {@code kind} of an element. 30 | * 31 | *

Note that it is possible additional element kinds will be added 32 | * to accommodate new, currently unknown, language structures added to 33 | * future versions of the Java™ programming language. 34 | * 35 | * @author Joseph D. Darcy 36 | * @author Scott Seligman 37 | * @author Peter von der Ahé 38 | * @see Element 39 | * @since 1.6 40 | */ 41 | public enum ElementKind { 42 | 43 | /** A package. */ 44 | PACKAGE, 45 | 46 | // Declared types 47 | /** An enum type. */ 48 | ENUM, 49 | /** A class not described by a more specific kind (like {@code ENUM}). */ 50 | CLASS, 51 | /** An annotation type. */ 52 | ANNOTATION_TYPE, 53 | /** 54 | * An interface not described by a more specific kind (like 55 | * {@code ANNOTATION_TYPE}). 56 | */ 57 | INTERFACE, 58 | 59 | // Variables 60 | /** An enum constant. */ 61 | ENUM_CONSTANT, 62 | /** 63 | * A field not described by a more specific kind (like 64 | * {@code ENUM_CONSTANT}). 65 | */ 66 | FIELD, 67 | /** A parameter of a method or constructor. */ 68 | PARAMETER, 69 | /** A local variable. */ 70 | LOCAL_VARIABLE, 71 | /** A parameter of an exception handler. */ 72 | EXCEPTION_PARAMETER, 73 | 74 | // Executables 75 | /** A method. */ 76 | METHOD, 77 | /** A constructor. */ 78 | CONSTRUCTOR, 79 | /** A static initializer. */ 80 | STATIC_INIT, 81 | /** An instance initializer. */ 82 | INSTANCE_INIT, 83 | 84 | /** A type parameter. */ 85 | TYPE_PARAMETER, 86 | 87 | /** 88 | * An implementation-reserved element. This is not the element 89 | * you are looking for. 90 | */ 91 | OTHER, 92 | 93 | /** 94 | * A resource variable. 95 | * @since 1.7 96 | */ 97 | RESOURCE_VARIABLE; 98 | 99 | 100 | /** 101 | * Returns {@code true} if this is a kind of class: 102 | * either {@code CLASS} or {@code ENUM}. 103 | * 104 | * @return {@code true} if this is a kind of class 105 | */ 106 | public boolean isClass() { 107 | return this == CLASS || this == ENUM; 108 | } 109 | 110 | /** 111 | * Returns {@code true} if this is a kind of interface: 112 | * either {@code INTERFACE} or {@code ANNOTATION_TYPE}. 113 | * 114 | * @return {@code true} if this is a kind of interface 115 | */ 116 | public boolean isInterface() { 117 | return this == INTERFACE || this == ANNOTATION_TYPE; 118 | } 119 | 120 | /** 121 | * Returns {@code true} if this is a kind of field: 122 | * either {@code FIELD} or {@code ENUM_CONSTANT}. 123 | * 124 | * @return {@code true} if this is a kind of field 125 | */ 126 | public boolean isField() { 127 | return this == FIELD || this == ENUM_CONSTANT; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/ExecutableType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | import java.util.List; 30 | 31 | import javax.lang.model.element.ExecutableElement; 32 | 33 | /** 34 | * Represents the type of an executable. An executable 35 | * is a method, constructor, or initializer. 36 | * 37 | *

The executable is 38 | * represented as when viewed as a method (or constructor or 39 | * initializer) of some reference type. 40 | * If that reference type is parameterized, then its actual 41 | * type arguments are substituted into any types returned by the methods of 42 | * this interface. 43 | * 44 | * @author Joseph D. Darcy 45 | * @author Scott Seligman 46 | * @author Peter von der Ahé 47 | * @see ExecutableElement 48 | * @since 1.6 49 | */ 50 | public interface ExecutableType extends TypeMirror { 51 | 52 | /** 53 | * Returns the type variables declared by the formal type parameters 54 | * of this executable. 55 | * 56 | * @return the type variables declared by the formal type parameters, 57 | * or an empty list if there are none 58 | */ 59 | List getTypeVariables(); 60 | 61 | /** 62 | * Returns the return type of this executable. 63 | * Returns a {@link NoType} with kind {@link TypeKind#VOID VOID} 64 | * if this executable is not a method, or is a method that does not 65 | * return a value. 66 | * 67 | * @return the return type of this executable 68 | */ 69 | TypeMirror getReturnType(); 70 | 71 | /** 72 | * Returns the types of this executable's formal parameters. 73 | * 74 | * @return the types of this executable's formal parameters, 75 | * or an empty list if there are none 76 | */ 77 | List getParameterTypes(); 78 | 79 | /** 80 | * Returns the receiver type of this executable, 81 | * or {@link javax.lang.model.type.NoType NoType} with 82 | * kind {@link javax.lang.model.type.TypeKind#NONE NONE} 83 | * if the executable has no receiver type. 84 | * 85 | * An executable which is an instance method, or a constructor of an 86 | * inner class, has a receiver type derived from the {@linkplain 87 | * ExecutableElement#getEnclosingElement declaring type}. 88 | * 89 | * An executable which is a static method, or a constructor of a 90 | * non-inner class, or an initializer (static or instance), has no 91 | * receiver type. 92 | * 93 | * @return the receiver type of this executable 94 | * @since 1.8 95 | */ 96 | TypeMirror getReceiverType(); 97 | 98 | /** 99 | * Returns the exceptions and other throwables listed in this 100 | * executable's {@code throws} clause. 101 | * 102 | * @return the exceptions and other throwables listed in this 103 | * executable's {@code throws} clause, 104 | * or an empty list if there are none. 105 | */ 106 | List getThrownTypes(); 107 | } 108 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/Messager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import javax.annotation.*; 29 | import javax.tools.Diagnostic; 30 | import javax.lang.model.element.*; 31 | 32 | /** 33 | * A {@code Messager} provides the way for an annotation processor to 34 | * report error messages, warnings, and other notices. Elements, 35 | * annotations, and annotation values can be passed to provide a 36 | * location hint for the message. However, such location hints may be 37 | * unavailable or only approximate. 38 | * 39 | *

Printing a message with an {@linkplain 40 | * javax.tools.Diagnostic.Kind#ERROR error kind} will {@linkplain 41 | * RoundEnvironment#errorRaised raise an error}. 42 | * 43 | *

Note that the messages "printed" by methods in this 44 | * interface may or may not appear as textual output to a location 45 | * like {@link System#out} or {@link System#err}. Implementations may 46 | * choose to present this information in a different fashion, such as 47 | * messages in a window. 48 | * 49 | * @author Joseph D. Darcy 50 | * @author Scott Seligman 51 | * @author Peter von der Ahé 52 | * @see ProcessingEnvironment#getLocale 53 | * @since 1.6 54 | */ 55 | public interface Messager { 56 | /** 57 | * Prints a message of the specified kind. 58 | * 59 | * @param kind the kind of message 60 | * @param msg the message, or an empty string if none 61 | */ 62 | void printMessage(Diagnostic.Kind kind, CharSequence msg); 63 | 64 | /** 65 | * Prints a message of the specified kind at the location of the 66 | * element. 67 | * 68 | * @param kind the kind of message 69 | * @param msg the message, or an empty string if none 70 | * @param e the element to use as a position hint 71 | */ 72 | void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e); 73 | 74 | /** 75 | * Prints a message of the specified kind at the location of the 76 | * annotation mirror of the annotated element. 77 | * 78 | * @param kind the kind of message 79 | * @param msg the message, or an empty string if none 80 | * @param e the annotated element 81 | * @param a the annotation to use as a position hint 82 | */ 83 | void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a); 84 | 85 | /** 86 | * Prints a message of the specified kind at the location of the 87 | * annotation value inside the annotation mirror of the annotated 88 | * element. 89 | * 90 | * @param kind the kind of message 91 | * @param msg the message, or an empty string if none 92 | * @param e the annotated element 93 | * @param a the annotation containing the annotation value 94 | * @param v the annotation value to use as a position hint 95 | */ 96 | void printMessage(Diagnostic.Kind kind, 97 | CharSequence msg, 98 | Element e, 99 | AnnotationMirror a, 100 | AnnotationValue v); 101 | } 102 | -------------------------------------------------------------------------------- /sample/src/main/java/me/denley/preferencebinder/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.sample; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.SharedPreferences; 6 | import android.os.Bundle; 7 | import android.os.Handler; 8 | import android.os.Looper; 9 | import android.preference.PreferenceManager; 10 | import android.widget.CheckBox; 11 | import android.widget.SeekBar; 12 | 13 | import me.denley.preferencebinder.BindPref; 14 | import me.denley.preferencebinder.PreferenceBinder; 15 | import me.denley.preferencebinder.R; 16 | import me.denley.preferencebinder.internal.WidgetBindingType; 17 | 18 | 19 | public class MainActivity extends Activity { 20 | 21 | private static final long PREFERENCE_CHANGE_INTERVAL_MS = 500; 22 | private static final long PREFERENCE_CHANGE_INITIAL_WAIT_MS = 3000; 23 | 24 | 25 | @BindPref(value = "boolean_pref_key", bindTo = WidgetBindingType.CHECKED) 26 | CheckBox booleanPreferenceDisplay; 27 | 28 | @BindPref(value = "integer_pref_key", bindTo = WidgetBindingType.SEEKBAR_PROGRESS) 29 | SeekBar integerPreferenceDisplay; 30 | 31 | @BindPref(value = "boolean_pref_key", listen = true) 32 | boolean booleanPrefValue; 33 | 34 | Looper preferenceChangeLooper; 35 | Handler handler; 36 | 37 | Runnable externalPreferenceChanger = new Runnable(){ 38 | public void run(){ 39 | changePreferenceValues(); 40 | handler.postDelayed(externalPreferenceChanger, PREFERENCE_CHANGE_INTERVAL_MS); 41 | } 42 | }; 43 | 44 | @Override protected void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_main); 47 | booleanPreferenceDisplay = (CheckBox) findViewById(R.id.pref_boolean); 48 | integerPreferenceDisplay = (SeekBar) findViewById(R.id.pref_integer); 49 | PreferenceBinder.bind(this); 50 | startHandlerOnBackgroundThread(); 51 | } 52 | 53 | @BindPref(value = {"integer_pref_key", "boolean_pref_key"}, init = false) 54 | void onNewValue3(){ 55 | 56 | } 57 | 58 | private void startHandlerOnBackgroundThread(){ 59 | new Thread(){ 60 | public void run(){ 61 | startHandler(); 62 | Looper.loop(); 63 | } 64 | }.start(); 65 | } 66 | 67 | private void startHandler(){ 68 | Looper.prepare(); 69 | preferenceChangeLooper = Looper.myLooper(); 70 | handler = new Handler(preferenceChangeLooper); 71 | handler.postDelayed(externalPreferenceChanger, PREFERENCE_CHANGE_INITIAL_WAIT_MS); 72 | } 73 | 74 | @SuppressLint("CommitPrefEdits") 75 | private void changePreferenceValues(){ 76 | final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 77 | final boolean booleanPrefValue = !prefs.getBoolean("boolean_pref_key", false); 78 | final int integerPrefValue = (prefs.getInt("integer_pref_key", 0) + 1) % 100; 79 | 80 | prefs.edit() 81 | .putBoolean("boolean_pref_key", booleanPrefValue) 82 | .putInt("integer_pref_key", integerPrefValue) 83 | .commit(); 84 | } 85 | 86 | @Override protected void onDestroy() { 87 | PreferenceBinder.unbind(this); 88 | handler.removeCallbacks(externalPreferenceChanger); 89 | if(preferenceChangeLooper != null) { 90 | preferenceChangeLooper.quit(); 91 | } 92 | super.onDestroy(); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/ForwardingFileObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import java.io.IOException; 29 | import java.io.InputStream; 30 | import java.io.OutputStream; 31 | import java.io.Reader; 32 | import java.io.Writer; 33 | import java.net.URI; 34 | 35 | /** 36 | * Forwards calls to a given file object. Subclasses of this class 37 | * might override some of these methods and might also provide 38 | * additional fields and methods. 39 | * 40 | * @param the kind of file object forwarded to by this object 41 | * @author Peter von der Ahé 42 | * @since 1.6 43 | */ 44 | public class ForwardingFileObject implements FileObject { 45 | 46 | /** 47 | * The file object which all methods are delegated to. 48 | */ 49 | protected final F fileObject; 50 | 51 | /** 52 | * Creates a new instance of ForwardingFileObject. 53 | * @param fileObject delegate to this file object 54 | */ 55 | protected ForwardingFileObject(F fileObject) { 56 | fileObject.getClass(); // null check 57 | this.fileObject = fileObject; 58 | } 59 | 60 | public URI toUri() { 61 | return fileObject.toUri(); 62 | } 63 | 64 | public String getName() { 65 | return fileObject.getName(); 66 | } 67 | 68 | /** 69 | * @throws IllegalStateException {@inheritDoc} 70 | * @throws UnsupportedOperationException {@inheritDoc} 71 | * @throws IOException {@inheritDoc} 72 | */ 73 | public InputStream openInputStream() throws IOException { 74 | return fileObject.openInputStream(); 75 | } 76 | 77 | /** 78 | * @throws IllegalStateException {@inheritDoc} 79 | * @throws UnsupportedOperationException {@inheritDoc} 80 | * @throws IOException {@inheritDoc} 81 | */ 82 | public OutputStream openOutputStream() throws IOException { 83 | return fileObject.openOutputStream(); 84 | } 85 | 86 | /** 87 | * @throws IllegalStateException {@inheritDoc} 88 | * @throws UnsupportedOperationException {@inheritDoc} 89 | * @throws IOException {@inheritDoc} 90 | */ 91 | public Reader openReader(boolean ignoreEncodingErrors) throws IOException { 92 | return fileObject.openReader(ignoreEncodingErrors); 93 | } 94 | 95 | /** 96 | * @throws IllegalStateException {@inheritDoc} 97 | * @throws UnsupportedOperationException {@inheritDoc} 98 | * @throws IOException {@inheritDoc} 99 | */ 100 | public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 101 | return fileObject.getCharContent(ignoreEncodingErrors); 102 | } 103 | 104 | /** 105 | * @throws IllegalStateException {@inheritDoc} 106 | * @throws UnsupportedOperationException {@inheritDoc} 107 | * @throws IOException {@inheritDoc} 108 | */ 109 | public Writer openWriter() throws IOException { 110 | return fileObject.openWriter(); 111 | } 112 | 113 | public long getLastModified() { 114 | return fileObject.getLastModified(); 115 | } 116 | 117 | public boolean delete() { 118 | return fileObject.delete(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleAnnotationValueVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | 32 | /** 33 | * A simple visitor for annotation values with default behavior 34 | * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} 35 | * source version. Visit methods call {@link #defaultAction 36 | * defaultAction} passing their arguments to {@code defaultAction}'s 37 | * corresponding parameters. 38 | * 39 | *

Methods in this class may be overridden subject to their 40 | * general contract. Note that annotating methods in concrete 41 | * subclasses with {@link java.lang.Override @Override} will help 42 | * ensure that methods are overridden as intended. 43 | * 44 | *

WARNING: The {@code AnnotationValueVisitor} interface 45 | * implemented by this class may have methods added to it in the 46 | * future to accommodate new, currently unknown, language structures 47 | * added to future versions of the Java™ programming language. 48 | * Therefore, methods whose names begin with {@code "visit"} may be 49 | * added to this class in the future; to avoid incompatibilities, 50 | * classes which extend this class should not declare any instance 51 | * methods with names beginning with {@code "visit"}. 52 | * 53 | *

When such a new visit method is added, the default 54 | * implementation in this class will be to call the {@link 55 | * #visitUnknown visitUnknown} method. A new simple annotation 56 | * value visitor class will also be introduced to correspond to the 57 | * new language level; this visitor will have different default 58 | * behavior for the visit method in question. When the new visitor is 59 | * introduced, all or portions of this visitor may be deprecated. 60 | * 61 | *

Note that adding a default implementation of a new visit method 62 | * in a visitor class will occur instead of adding a default 63 | * method directly in the visitor interface since a Java SE 8 64 | * language feature cannot be used to this version of the API since 65 | * this version is required to be runnable on Java SE 7 66 | * implementations. Future versions of the API that are only required 67 | * to run on Java SE 8 and later may take advantage of default methods 68 | * in this situation. 69 | * 70 | * @param the return type of this visitor's methods 71 | * @param

the type of the additional parameter to this visitor's methods. 72 | * 73 | * @see SimpleAnnotationValueVisitor6 74 | * @see SimpleAnnotationValueVisitor8 75 | * @since 1.7 76 | */ 77 | @SupportedSourceVersion(RELEASE_7) 78 | public class SimpleAnnotationValueVisitor7 extends SimpleAnnotationValueVisitor6 { 79 | /** 80 | * Constructor for concrete subclasses; uses {@code null} for the 81 | * default value. 82 | */ 83 | protected SimpleAnnotationValueVisitor7() { 84 | super(null); 85 | } 86 | 87 | /** 88 | * Constructor for concrete subclasses; uses the argument for the 89 | * default value. 90 | * 91 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 92 | */ 93 | protected SimpleAnnotationValueVisitor7(R defaultValue) { 94 | super(defaultValue); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleAnnotationValueVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | 32 | /** 33 | * A simple visitor for annotation values with default behavior 34 | * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} 35 | * source version. Visit methods call {@link #defaultAction 36 | * defaultAction} passing their arguments to {@code defaultAction}'s 37 | * corresponding parameters. 38 | * 39 | *

Methods in this class may be overridden subject to their 40 | * general contract. Note that annotating methods in concrete 41 | * subclasses with {@link java.lang.Override @Override} will help 42 | * ensure that methods are overridden as intended. 43 | * 44 | *

WARNING: The {@code AnnotationValueVisitor} interface 45 | * implemented by this class may have methods added to it in the 46 | * future to accommodate new, currently unknown, language structures 47 | * added to future versions of the Java™ programming language. 48 | * Therefore, methods whose names begin with {@code "visit"} may be 49 | * added to this class in the future; to avoid incompatibilities, 50 | * classes which extend this class should not declare any instance 51 | * methods with names beginning with {@code "visit"}. 52 | * 53 | *

When such a new visit method is added, the default 54 | * implementation in this class will be to call the {@link 55 | * #visitUnknown visitUnknown} method. A new simple annotation 56 | * value visitor class will also be introduced to correspond to the 57 | * new language level; this visitor will have different default 58 | * behavior for the visit method in question. When the new visitor is 59 | * introduced, all or portions of this visitor may be deprecated. 60 | * 61 | *

Note that adding a default implementation of a new visit method 62 | * in a visitor class will occur instead of adding a default 63 | * method directly in the visitor interface since a Java SE 8 64 | * language feature cannot be used to this version of the API since 65 | * this version is required to be runnable on Java SE 7 66 | * implementations. Future versions of the API that are only required 67 | * to run on Java SE 8 and later may take advantage of default methods 68 | * in this situation. 69 | * 70 | * @param the return type of this visitor's methods 71 | * @param

the type of the additional parameter to this visitor's methods. 72 | * 73 | * @see SimpleAnnotationValueVisitor6 74 | * @see SimpleAnnotationValueVisitor7 75 | * @since 1.8 76 | */ 77 | @SupportedSourceVersion(RELEASE_8) 78 | public class SimpleAnnotationValueVisitor8 extends SimpleAnnotationValueVisitor7 { 79 | /** 80 | * Constructor for concrete subclasses; uses {@code null} for the 81 | * default value. 82 | */ 83 | protected SimpleAnnotationValueVisitor8() { 84 | super(null); 85 | } 86 | 87 | /** 88 | * Constructor for concrete subclasses; uses the argument for the 89 | * default value. 90 | * 91 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 92 | */ 93 | protected SimpleAnnotationValueVisitor8(R defaultValue) { 94 | super(defaultValue); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/TypeKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | 29 | /** 30 | * The kind of a type mirror. 31 | * 32 | *

Note that it is possible additional type kinds will be added to 33 | * accommodate new, currently unknown, language structures added to 34 | * future versions of the Java™ programming language. 35 | * 36 | * @author Joseph D. Darcy 37 | * @author Scott Seligman 38 | * @author Peter von der Ahé 39 | * @see TypeMirror 40 | * @since 1.6 41 | */ 42 | public enum TypeKind { 43 | /** 44 | * The primitive type {@code boolean}. 45 | */ 46 | BOOLEAN, 47 | 48 | /** 49 | * The primitive type {@code byte}. 50 | */ 51 | BYTE, 52 | 53 | /** 54 | * The primitive type {@code short}. 55 | */ 56 | SHORT, 57 | 58 | /** 59 | * The primitive type {@code int}. 60 | */ 61 | INT, 62 | 63 | /** 64 | * The primitive type {@code long}. 65 | */ 66 | LONG, 67 | 68 | /** 69 | * The primitive type {@code char}. 70 | */ 71 | CHAR, 72 | 73 | /** 74 | * The primitive type {@code float}. 75 | */ 76 | FLOAT, 77 | 78 | /** 79 | * The primitive type {@code double}. 80 | */ 81 | DOUBLE, 82 | 83 | /** 84 | * The pseudo-type corresponding to the keyword {@code void}. 85 | * @see NoType 86 | */ 87 | VOID, 88 | 89 | /** 90 | * A pseudo-type used where no actual type is appropriate. 91 | * @see NoType 92 | */ 93 | NONE, 94 | 95 | /** 96 | * The null type. 97 | */ 98 | NULL, 99 | 100 | /** 101 | * An array type. 102 | */ 103 | ARRAY, 104 | 105 | /** 106 | * A class or interface type. 107 | */ 108 | DECLARED, 109 | 110 | /** 111 | * A class or interface type that could not be resolved. 112 | */ 113 | ERROR, 114 | 115 | /** 116 | * A type variable. 117 | */ 118 | TYPEVAR, 119 | 120 | /** 121 | * A wildcard type argument. 122 | */ 123 | WILDCARD, 124 | 125 | /** 126 | * A pseudo-type corresponding to a package element. 127 | * @see NoType 128 | */ 129 | PACKAGE, 130 | 131 | /** 132 | * A method, constructor, or initializer. 133 | */ 134 | EXECUTABLE, 135 | 136 | /** 137 | * An implementation-reserved type. 138 | * This is not the type you are looking for. 139 | */ 140 | OTHER, 141 | 142 | /** 143 | * A union type. 144 | * 145 | * @since 1.7 146 | */ 147 | UNION, 148 | 149 | /** 150 | * An intersection type. 151 | * 152 | * @since 1.8 153 | */ 154 | INTERSECTION; 155 | 156 | /** 157 | * Returns {@code true} if this kind corresponds to a primitive 158 | * type and {@code false} otherwise. 159 | * @return {@code true} if this kind corresponds to a primitive type 160 | */ 161 | public boolean isPrimitive() { 162 | switch(this) { 163 | case BOOLEAN: 164 | case BYTE: 165 | case SHORT: 166 | case INT: 167 | case LONG: 168 | case CHAR: 169 | case FLOAT: 170 | case DOUBLE: 171 | return true; 172 | 173 | default: 174 | return false; 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/type/TypeMirror.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.type; 27 | 28 | import java.lang.annotation.Annotation; 29 | import java.util.List; 30 | import javax.lang.model.element.*; 31 | import javax.lang.model.util.Types; 32 | 33 | /** 34 | * Represents a type in the Java programming language. 35 | * Types include primitive types, declared types (class and interface types), 36 | * array types, type variables, and the null type. 37 | * Also represented are wildcard type arguments, 38 | * the signature and return types of executables, 39 | * and pseudo-types corresponding to packages and to the keyword {@code void}. 40 | * 41 | *

Types should be compared using the utility methods in {@link 42 | * Types}. There is no guarantee that any particular type will always 43 | * be represented by the same object. 44 | * 45 | *

To implement operations based on the class of an {@code 46 | * TypeMirror} object, either use a {@linkplain TypeVisitor visitor} 47 | * or use the result of the {@link #getKind} method. Using {@code 48 | * instanceof} is not necessarily a reliable idiom for 49 | * determining the effective class of an object in this modeling 50 | * hierarchy since an implementation may choose to have a single 51 | * object implement multiple {@code TypeMirror} subinterfaces. 52 | * 53 | * @author Joseph D. Darcy 54 | * @author Scott Seligman 55 | * @author Peter von der Ahé 56 | * @see Element 57 | * @see Types 58 | * @since 1.6 59 | */ 60 | public interface TypeMirror extends javax.lang.model.AnnotatedConstruct { 61 | 62 | /** 63 | * Returns the {@code kind} of this type. 64 | * 65 | * @return the kind of this type 66 | */ 67 | TypeKind getKind(); 68 | 69 | /** 70 | * Obeys the general contract of {@link Object#equals Object.equals}. 71 | * This method does not, however, indicate whether two types represent 72 | * the same type. 73 | * Semantic comparisons of type equality should instead use 74 | * {@link Types#isSameType(TypeMirror, TypeMirror)}. 75 | * The results of {@code t1.equals(t2)} and 76 | * {@code Types.isSameType(t1, t2)} may differ. 77 | * 78 | * @param obj the object to be compared with this type 79 | * @return {@code true} if the specified object is equal to this one 80 | */ 81 | boolean equals(Object obj); 82 | 83 | /** 84 | * Obeys the general contract of {@link Object#hashCode Object.hashCode}. 85 | * 86 | * @see #equals 87 | */ 88 | int hashCode(); 89 | 90 | /** 91 | * Returns an informative string representation of this type. If 92 | * possible, the string should be of a form suitable for 93 | * representing this type in source code. Any names embedded in 94 | * the result are qualified if possible. 95 | * 96 | * @return a string representation of this type 97 | */ 98 | String toString(); 99 | 100 | /** 101 | * Applies a visitor to this type. 102 | * 103 | * @param the return type of the visitor's methods 104 | * @param

the type of the additional parameter to the visitor's methods 105 | * @param v the visitor operating on this type 106 | * @param p additional parameter to the visitor 107 | * @return a visitor-specified result 108 | */ 109 | R accept(TypeVisitor v, P p); 110 | } 111 | -------------------------------------------------------------------------------- /sample/src/main/java/me/denley/preferencebinder/sample/SampleFragment.java: -------------------------------------------------------------------------------- 1 | package me.denley.preferencebinder.sample; 2 | 3 | import android.app.Fragment; 4 | import android.content.SharedPreferences; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.os.Looper; 8 | import android.preference.PreferenceManager; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.CheckBox; 13 | import android.widget.SeekBar; 14 | 15 | import java.util.Set; 16 | 17 | import me.denley.preferencebinder.BindPref; 18 | import me.denley.preferencebinder.PreferenceBinder; 19 | import me.denley.preferencebinder.R; 20 | 21 | public class SampleFragment extends Fragment { 22 | 23 | private static final long PREFERENCE_CHANGE_INTERVAL_MS = 500; 24 | private static final long PREFERENCE_CHANGE_INITIAL_WAIT_MS = 3000; 25 | 26 | CheckBox booleanPreferenceDisplay; 27 | SeekBar integerPreferenceDisplay; 28 | 29 | @BindPref("boolean_pref_key") 30 | boolean booleanPrefValue; 31 | 32 | @BindPref(value = "string_pref_key", listen = false) 33 | String stringPrefValue; 34 | 35 | @BindPref(value = "string_set_pref_key", listen = false) 36 | Set stringSetPrefValue; 37 | 38 | Looper preferenceChangeLooper; 39 | Handler handler; 40 | 41 | Runnable externalPreferenceChanger = new Runnable(){ 42 | public void run(){ 43 | changePreferenceValues(); 44 | handler.postDelayed(externalPreferenceChanger, PREFERENCE_CHANGE_INTERVAL_MS); 45 | } 46 | }; 47 | 48 | @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 49 | final View view = inflater.inflate(R.layout.activity_main, container, false); 50 | booleanPreferenceDisplay = (CheckBox) view.findViewById(R.id.pref_boolean); 51 | integerPreferenceDisplay = (SeekBar) view.findViewById(R.id.pref_integer); 52 | PreferenceBinder.bind(this); 53 | 54 | startHandlerOnBackgroundThread(); 55 | return view; 56 | } 57 | 58 | @Override public void onDestroyView() { 59 | super.onDestroyView(); 60 | 61 | PreferenceBinder.unbind(this); 62 | 63 | if(preferenceChangeLooper != null) { 64 | preferenceChangeLooper.quit(); 65 | } 66 | super.onDestroy(); 67 | } 68 | 69 | @BindPref("integer_pref_key") 70 | void onNewValue(int newValue){ 71 | integerPreferenceDisplay.setProgress(newValue); 72 | } 73 | 74 | @BindPref("boolean_pref_key") 75 | void onNewValue2(boolean newValue){ 76 | booleanPreferenceDisplay.setChecked(booleanPrefValue); 77 | } 78 | 79 | private void startHandlerOnBackgroundThread(){ 80 | new Thread(){ 81 | public void run(){ 82 | startHandler(); 83 | Looper.loop(); 84 | } 85 | }.start(); 86 | } 87 | 88 | private void startHandler(){ 89 | Looper.prepare(); 90 | preferenceChangeLooper = Looper.myLooper(); 91 | handler = new Handler(preferenceChangeLooper); 92 | handler.postDelayed(externalPreferenceChanger, PREFERENCE_CHANGE_INITIAL_WAIT_MS); 93 | } 94 | 95 | private void changePreferenceValues(){ 96 | final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); 97 | final boolean booleanPrefValue = !prefs.getBoolean("boolean_pref_key", false); 98 | final int integerPrefValue = (prefs.getInt("integer_pref_key", 0) + 1) % 100; 99 | 100 | prefs.edit() 101 | .putBoolean("boolean_pref_key", booleanPrefValue) 102 | .putInt("integer_pref_key", integerPrefValue) 103 | .apply(); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleElementVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | 32 | /** 33 | * A simple visitor of program elements with default behavior 34 | * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} 35 | * source version. 36 | * 37 | * Visit methods corresponding to {@code RELEASE_7} and earlier 38 | * language constructs call {@link #defaultAction defaultAction}, 39 | * passing their arguments to {@code defaultAction}'s corresponding 40 | * parameters. 41 | * 42 | *

Methods in this class may be overridden subject to their 43 | * general contract. Note that annotating methods in concrete 44 | * subclasses with {@link java.lang.Override @Override} will help 45 | * ensure that methods are overridden as intended. 46 | * 47 | *

WARNING: The {@code ElementVisitor} interface 48 | * implemented by this class may have methods added to it in the 49 | * future to accommodate new, currently unknown, language structures 50 | * added to future versions of the Java™ programming language. 51 | * Therefore, methods whose names begin with {@code "visit"} may be 52 | * added to this class in the future; to avoid incompatibilities, 53 | * classes which extend this class should not declare any instance 54 | * methods with names beginning with {@code "visit"}. 55 | * 56 | *

When such a new visit method is added, the default 57 | * implementation in this class will be to call the {@link 58 | * #visitUnknown visitUnknown} method. A new simple element visitor 59 | * class will also be introduced to correspond to the new language 60 | * level; this visitor will have different default behavior for the 61 | * visit method in question. When the new visitor is introduced, all 62 | * or portions of this visitor may be deprecated. 63 | * 64 | *

Note that adding a default implementation of a new visit method 65 | * in a visitor class will occur instead of adding a default 66 | * method directly in the visitor interface since a Java SE 8 67 | * language feature cannot be used to this version of the API since 68 | * this version is required to be runnable on Java SE 7 69 | * implementations. Future versions of the API that are only required 70 | * to run on Java SE 8 and later may take advantage of default methods 71 | * in this situation. 72 | * 73 | * @param the return type of this visitor's methods. Use {@code Void} 74 | * for visitors that do not need to return results. 75 | * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} 76 | * for visitors that do not need an additional parameter. 77 | * 78 | * @see SimpleElementVisitor6 79 | * @see SimpleElementVisitor7 80 | * @since 1.8 81 | */ 82 | @SupportedSourceVersion(RELEASE_8) 83 | public class SimpleElementVisitor8 extends SimpleElementVisitor7 { 84 | /** 85 | * Constructor for concrete subclasses; uses {@code null} for the 86 | * default value. 87 | */ 88 | protected SimpleElementVisitor8(){ 89 | super(null); 90 | } 91 | 92 | /** 93 | * Constructor for concrete subclasses; uses the argument for the 94 | * default value. 95 | * 96 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 97 | */ 98 | protected SimpleElementVisitor8(R defaultValue){ 99 | super(defaultValue); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /library/src/main/java/javax/tools/JavaFileObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.tools; 27 | 28 | import javax.lang.model.element.NestingKind; 29 | import javax.lang.model.element.Modifier; 30 | 31 | /** 32 | * File abstraction for tools operating on Java™ programming language 33 | * source and class files. 34 | * 35 | *

All methods in this interface might throw a SecurityException if 36 | * a security exception occurs. 37 | * 38 | *

Unless explicitly allowed, all methods in this interface might 39 | * throw a NullPointerException if given a {@code null} argument. 40 | * 41 | * @author Peter von der Ahé 42 | * @author Jonathan Gibbons 43 | * @see JavaFileManager 44 | * @since 1.6 45 | */ 46 | public interface JavaFileObject extends FileObject { 47 | 48 | /** 49 | * Kinds of JavaFileObjects. 50 | */ 51 | enum Kind { 52 | /** 53 | * Source files written in the Java programming language. For 54 | * example, regular files ending with {@code .java}. 55 | */ 56 | SOURCE(".java"), 57 | 58 | /** 59 | * Class files for the Java Virtual Machine. For example, 60 | * regular files ending with {@code .class}. 61 | */ 62 | CLASS(".class"), 63 | 64 | /** 65 | * HTML files. For example, regular files ending with {@code 66 | * .html}. 67 | */ 68 | HTML(".html"), 69 | 70 | /** 71 | * Any other kind. 72 | */ 73 | OTHER(""); 74 | /** 75 | * The extension which (by convention) is normally used for 76 | * this kind of file object. If no convention exists, the 77 | * empty string ({@code ""}) is used. 78 | */ 79 | public final String extension; 80 | private Kind(String extension) { 81 | extension.getClass(); // null check 82 | this.extension = extension; 83 | } 84 | }; 85 | 86 | /** 87 | * Gets the kind of this file object. 88 | * 89 | * @return the kind 90 | */ 91 | Kind getKind(); 92 | 93 | /** 94 | * Checks if this file object is compatible with the specified 95 | * simple name and kind. A simple name is a single identifier 96 | * (not qualified) as defined in 97 | * The Java™ Language Specification, 98 | * section 6.2 "Names and Identifiers". 99 | * 100 | * @param simpleName a simple name of a class 101 | * @param kind a kind 102 | * @return {@code true} if this file object is compatible; false 103 | * otherwise 104 | */ 105 | boolean isNameCompatible(String simpleName, Kind kind); 106 | 107 | /** 108 | * Provides a hint about the nesting level of the class 109 | * represented by this file object. This method may return 110 | * {@link NestingKind#MEMBER} to mean 111 | * {@link NestingKind#LOCAL} or {@link NestingKind#ANONYMOUS}. 112 | * If the nesting level is not known or this file object does not 113 | * represent a class file this method returns {@code null}. 114 | * 115 | * @return the nesting kind, or {@code null} if the nesting kind 116 | * is not known 117 | */ 118 | NestingKind getNestingKind(); 119 | 120 | /** 121 | * Provides a hint about the access level of the class represented 122 | * by this file object. If the access level is not known or if 123 | * this file object does not represent a class file this method 124 | * returns {@code null}. 125 | * 126 | * @return the access level 127 | */ 128 | Modifier getAccessLevel(); 129 | 130 | } 131 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/ElementKindVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.element.*; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | import javax.lang.model.SourceVersion; 32 | 33 | /** 34 | * A visitor of program elements based on their {@linkplain 35 | * ElementKind kind} with default behavior appropriate for the {@link 36 | * SourceVersion#RELEASE_8 RELEASE_8} source version. For {@linkplain 37 | * Element elements} XYZ that may have more than one 38 | * kind, the visitXYZ methods in this class delegate 39 | * to the visitXYZKind method corresponding to the 40 | * first argument's kind. The visitXYZKind methods 41 | * call {@link #defaultAction defaultAction}, passing their arguments 42 | * to {@code defaultAction}'s corresponding parameters. 43 | * 44 | *

Methods in this class may be overridden subject to their 45 | * general contract. Note that annotating methods in concrete 46 | * subclasses with {@link java.lang.Override @Override} will help 47 | * ensure that methods are overridden as intended. 48 | * 49 | *

WARNING: The {@code ElementVisitor} interface 50 | * implemented by this class may have methods added to it or the 51 | * {@code ElementKind} {@code enum} used in this case may have 52 | * constants added to it in the future to accommodate new, currently 53 | * unknown, language structures added to future versions of the 54 | * Java™ programming language. Therefore, methods whose names 55 | * begin with {@code "visit"} may be added to this class in the 56 | * future; to avoid incompatibilities, classes which extend this class 57 | * should not declare any instance methods with names beginning with 58 | * {@code "visit"}. 59 | * 60 | *

When such a new visit method is added, the default 61 | * implementation in this class will be to call the {@link 62 | * #visitUnknown visitUnknown} method. A new abstract element kind 63 | * visitor class will also be introduced to correspond to the new 64 | * language level; this visitor will have different default behavior 65 | * for the visit method in question. When the new visitor is 66 | * introduced, all or portions of this visitor may be deprecated. 67 | * 68 | *

Note that adding a default implementation of a new visit method 69 | * in a visitor class will occur instead of adding a default 70 | * method directly in the visitor interface since a Java SE 8 71 | * language feature cannot be used to this version of the API since 72 | * this version is required to be runnable on Java SE 7 73 | * implementations. Future versions of the API that are only required 74 | * to run on Java SE 8 and later may take advantage of default methods 75 | * in this situation. 76 | * 77 | * @param the return type of this visitor's methods. Use {@link 78 | * Void} for visitors that do not need to return results. 79 | * @param

the type of the additional parameter to this visitor's 80 | * methods. Use {@code Void} for visitors that do not need an 81 | * additional parameter. 82 | * 83 | * @see ElementKindVisitor6 84 | * @see ElementKindVisitor7 85 | * @since 1.8 86 | */ 87 | @SupportedSourceVersion(RELEASE_8) 88 | public class ElementKindVisitor8 extends ElementKindVisitor7 { 89 | /** 90 | * Constructor for concrete subclasses; uses {@code null} for the 91 | * default value. 92 | */ 93 | protected ElementKindVisitor8() { 94 | super(null); 95 | } 96 | 97 | /** 98 | * Constructor for concrete subclasses; uses the argument for the 99 | * default value. 100 | * 101 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 102 | */ 103 | protected ElementKindVisitor8(R defaultValue) { 104 | super(defaultValue); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleElementVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.element.*; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import javax.lang.model.SourceVersion; 31 | import static javax.lang.model.SourceVersion.*; 32 | 33 | /** 34 | * A simple visitor of program elements with default behavior 35 | * appropriate for the {@link SourceVersion#RELEASE_7 RELEASE_7} 36 | * source version. 37 | * 38 | * Visit methods corresponding to {@code RELEASE_7} and earlier 39 | * language constructs call {@link #defaultAction defaultAction}, 40 | * passing their arguments to {@code defaultAction}'s corresponding 41 | * parameters. 42 | * 43 | *

Methods in this class may be overridden subject to their 44 | * general contract. Note that annotating methods in concrete 45 | * subclasses with {@link java.lang.Override @Override} will help 46 | * ensure that methods are overridden as intended. 47 | * 48 | *

WARNING: The {@code ElementVisitor} interface 49 | * implemented by this class may have methods added to it in the 50 | * future to accommodate new, currently unknown, language structures 51 | * added to future versions of the Java™ programming language. 52 | * Therefore, methods whose names begin with {@code "visit"} may be 53 | * added to this class in the future; to avoid incompatibilities, 54 | * classes which extend this class should not declare any instance 55 | * methods with names beginning with {@code "visit"}. 56 | * 57 | *

When such a new visit method is added, the default 58 | * implementation in this class will be to call the {@link 59 | * #visitUnknown visitUnknown} method. A new simple element visitor 60 | * class will also be introduced to correspond to the new language 61 | * level; this visitor will have different default behavior for the 62 | * visit method in question. When the new visitor is introduced, all 63 | * or portions of this visitor may be deprecated. 64 | * 65 | *

Note that adding a default implementation of a new visit method 66 | * in a visitor class will occur instead of adding a default 67 | * method directly in the visitor interface since a Java SE 8 68 | * language feature cannot be used to this version of the API since 69 | * this version is required to be runnable on Java SE 7 70 | * implementations. Future versions of the API that are only required 71 | * to run on Java SE 8 and later may take advantage of default methods 72 | * in this situation. 73 | * 74 | * @param the return type of this visitor's methods. Use {@code Void} 75 | * for visitors that do not need to return results. 76 | * @param

the type of the additional parameter to this visitor's methods. Use {@code Void} 77 | * for visitors that do not need an additional parameter. 78 | * 79 | * @see SimpleElementVisitor6 80 | * @see SimpleElementVisitor8 81 | * @since 1.7 82 | */ 83 | @SupportedSourceVersion(RELEASE_7) 84 | public class SimpleElementVisitor7 extends SimpleElementVisitor6 { 85 | /** 86 | * Constructor for concrete subclasses; uses {@code null} for the 87 | * default value. 88 | */ 89 | protected SimpleElementVisitor7(){ 90 | super(null); 91 | } 92 | 93 | /** 94 | * Constructor for concrete subclasses; uses the argument for the 95 | * default value. 96 | * 97 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 98 | */ 99 | protected SimpleElementVisitor7(R defaultValue){ 100 | super(defaultValue); 101 | } 102 | 103 | /** 104 | * This implementation calls {@code defaultAction}. 105 | * 106 | * @param e {@inheritDoc} 107 | * @param p {@inheritDoc} 108 | * @return the result of {@code defaultAction} 109 | */ 110 | @Override 111 | public R visitVariable(VariableElement e, P p) { 112 | return defaultAction(e, p); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleTypeVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.type.*; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import javax.lang.model.SourceVersion; 31 | import static javax.lang.model.SourceVersion.*; 32 | 33 | /** 34 | * A simple visitor of types with default behavior appropriate for the 35 | * {@link SourceVersion#RELEASE_7 RELEASE_7} source version. 36 | * 37 | * Visit methods corresponding to {@code RELEASE_7} and earlier 38 | * language constructs call {@link #defaultAction defaultAction}, 39 | * passing their arguments to {@code defaultAction}'s corresponding 40 | * parameters. 41 | * 42 | *

Methods in this class may be overridden subject to their 43 | * general contract. Note that annotating methods in concrete 44 | * subclasses with {@link java.lang.Override @Override} will help 45 | * ensure that methods are overridden as intended. 46 | * 47 | *

WARNING: The {@code TypeVisitor} interface implemented 48 | * by this class may have methods added to it in the future to 49 | * accommodate new, currently unknown, language structures added to 50 | * future versions of the Java™ programming language. 51 | * Therefore, methods whose names begin with {@code "visit"} may be 52 | * added to this class in the future; to avoid incompatibilities, 53 | * classes which extend this class should not declare any instance 54 | * methods with names beginning with {@code "visit"}. 55 | * 56 | *

When such a new visit method is added, the default 57 | * implementation in this class will be to call the {@link 58 | * #visitUnknown visitUnknown} method. A new simple type visitor 59 | * class will also be introduced to correspond to the new language 60 | * level; this visitor will have different default behavior for the 61 | * visit method in question. When the new visitor is introduced, all 62 | * or portions of this visitor may be deprecated. 63 | * 64 | *

Note that adding a default implementation of a new visit method 65 | * in a visitor class will occur instead of adding a default 66 | * method directly in the visitor interface since a Java SE 8 67 | * language feature cannot be used to this version of the API since 68 | * this version is required to be runnable on Java SE 7 69 | * implementations. Future versions of the API that are only required 70 | * to run on Java SE 8 and later may take advantage of default methods 71 | * in this situation. 72 | * 73 | * @param the return type of this visitor's methods. Use {@link 74 | * Void} for visitors that do not need to return results. 75 | * @param

the type of the additional parameter to this visitor's 76 | * methods. Use {@code Void} for visitors that do not need an 77 | * additional parameter. 78 | * 79 | * @see SimpleTypeVisitor6 80 | * @see SimpleTypeVisitor8 81 | * @since 1.7 82 | */ 83 | @SupportedSourceVersion(RELEASE_7) 84 | public class SimpleTypeVisitor7 extends SimpleTypeVisitor6 { 85 | /** 86 | * Constructor for concrete subclasses; uses {@code null} for the 87 | * default value. 88 | */ 89 | protected SimpleTypeVisitor7(){ 90 | super(null); 91 | } 92 | 93 | /** 94 | * Constructor for concrete subclasses; uses the argument for the 95 | * default value. 96 | * 97 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 98 | */ 99 | protected SimpleTypeVisitor7(R defaultValue){ 100 | super(defaultValue); 101 | } 102 | 103 | /** 104 | * This implementation visits a {@code UnionType} by calling 105 | * {@code defaultAction}. 106 | * 107 | * @param t {@inheritDoc} 108 | * @param p {@inheritDoc} 109 | * @return the result of {@code defaultAction} 110 | */ 111 | @Override 112 | public R visitUnion(UnionType t, P p) { 113 | return defaultAction(t, p); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /library/src/main/java/javax/annotation/processing/RoundEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.annotation.processing; 27 | 28 | import javax.lang.model.element.Element; 29 | import javax.lang.model.element.TypeElement; 30 | import java.util.Set; 31 | import java.lang.annotation.Annotation; 32 | 33 | /** 34 | * An annotation processing tool framework will {@linkplain 35 | * Processor#process provide an annotation processor with an object 36 | * implementing this interface} so that the processor can query for 37 | * information about a round of annotation processing. 38 | * 39 | * @author Joseph D. Darcy 40 | * @author Scott Seligman 41 | * @author Peter von der Ahé 42 | * @since 1.6 43 | */ 44 | public interface RoundEnvironment { 45 | /** 46 | * Returns {@code true} if types generated by this round will not 47 | * be subject to a subsequent round of annotation processing; 48 | * returns {@code false} otherwise. 49 | * 50 | * @return {@code true} if types generated by this round will not 51 | * be subject to a subsequent round of annotation processing; 52 | * returns {@code false} otherwise 53 | */ 54 | boolean processingOver(); 55 | 56 | /** 57 | * Returns {@code true} if an error was raised in the prior round 58 | * of processing; returns {@code false} otherwise. 59 | * 60 | * @return {@code true} if an error was raised in the prior round 61 | * of processing; returns {@code false} otherwise 62 | */ 63 | boolean errorRaised(); 64 | 65 | /** 66 | * Returns the root elements for annotation processing generated 67 | * by the prior round. 68 | * 69 | * @return the root elements for annotation processing generated 70 | * by the prior round, or an empty set if there were none 71 | */ 72 | Set getRootElements(); 73 | 74 | /** 75 | * Returns the elements annotated with the given annotation type. 76 | * The annotation may appear directly or be inherited. Only 77 | * package elements and type elements included in this 78 | * round of annotation processing, or declarations of members, 79 | * constructors, parameters, or type parameters declared within 80 | * those, are returned. Included type elements are {@linkplain 81 | * #getRootElements root types} and any member types nested within 82 | * them. Elements in a package are not considered included simply 83 | * because a {@code package-info} file for that package was 84 | * created. 85 | * 86 | * @param a annotation type being requested 87 | * @return the elements annotated with the given annotation type, 88 | * or an empty set if there are none 89 | * @throws IllegalArgumentException if the argument does not 90 | * represent an annotation type 91 | */ 92 | Set getElementsAnnotatedWith(TypeElement a); 93 | 94 | /** 95 | * Returns the elements annotated with the given annotation type. 96 | * The annotation may appear directly or be inherited. Only 97 | * package elements and type elements included in this 98 | * round of annotation processing, or declarations of members, 99 | * constructors, parameters, or type parameters declared within 100 | * those, are returned. Included type elements are {@linkplain 101 | * #getRootElements root types} and any member types nested within 102 | * them. Elements in a package are not considered included simply 103 | * because a {@code package-info} file for that package was 104 | * created. 105 | * 106 | * @param a annotation type being requested 107 | * @return the elements annotated with the given annotation type, 108 | * or an empty set if there are none 109 | * @throws IllegalArgumentException if the argument does not 110 | * represent an annotation type 111 | */ 112 | Set getElementsAnnotatedWith(Class a); 113 | } 114 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/SimpleTypeVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import javax.lang.model.type.IntersectionType; 31 | import static javax.lang.model.SourceVersion.*; 32 | 33 | /** 34 | * A simple visitor of types with default behavior appropriate for the 35 | * {@link SourceVersion#RELEASE_7 RELEASE_7} source version. 36 | * 37 | * Visit methods corresponding to {@code RELEASE_8} and earlier 38 | * language constructs call {@link #defaultAction defaultAction}, 39 | * passing their arguments to {@code defaultAction}'s corresponding 40 | * parameters. 41 | * 42 | *

Methods in this class may be overridden subject to their 43 | * general contract. Note that annotating methods in concrete 44 | * subclasses with {@link java.lang.Override @Override} will help 45 | * ensure that methods are overridden as intended. 46 | * 47 | *

WARNING: The {@code TypeVisitor} interface implemented 48 | * by this class may have methods added to it in the future to 49 | * accommodate new, currently unknown, language structures added to 50 | * future versions of the Java™ programming language. 51 | * Therefore, methods whose names begin with {@code "visit"} may be 52 | * added to this class in the future; to avoid incompatibilities, 53 | * classes which extend this class should not declare any instance 54 | * methods with names beginning with {@code "visit"}. 55 | * 56 | *

When such a new visit method is added, the default 57 | * implementation in this class will be to call the {@link 58 | * #visitUnknown visitUnknown} method. A new simple type visitor 59 | * class will also be introduced to correspond to the new language 60 | * level; this visitor will have different default behavior for the 61 | * visit method in question. When the new visitor is introduced, all 62 | * or portions of this visitor may be deprecated. 63 | * 64 | *

Note that adding a default implementation of a new visit method 65 | * in a visitor class will occur instead of adding a default 66 | * method directly in the visitor interface since a Java SE 8 67 | * language feature cannot be used to this version of the API since 68 | * this version is required to be runnable on Java SE 7 69 | * implementations. Future versions of the API that are only required 70 | * to run on Java SE 8 and later may take advantage of default methods 71 | * in this situation. 72 | * 73 | * @param the return type of this visitor's methods. Use {@link 74 | * Void} for visitors that do not need to return results. 75 | * @param

the type of the additional parameter to this visitor's 76 | * methods. Use {@code Void} for visitors that do not need an 77 | * additional parameter. 78 | * 79 | * @see SimpleTypeVisitor6 80 | * @see SimpleTypeVisitor7 81 | * @since 1.8 82 | */ 83 | @SupportedSourceVersion(RELEASE_8) 84 | public class SimpleTypeVisitor8 extends SimpleTypeVisitor7 { 85 | /** 86 | * Constructor for concrete subclasses; uses {@code null} for the 87 | * default value. 88 | */ 89 | protected SimpleTypeVisitor8(){ 90 | super(null); 91 | } 92 | 93 | /** 94 | * Constructor for concrete subclasses; uses the argument for the 95 | * default value. 96 | * 97 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 98 | */ 99 | protected SimpleTypeVisitor8(R defaultValue){ 100 | super(defaultValue); 101 | } 102 | 103 | /** 104 | * This implementation visits an {@code IntersectionType} by calling 105 | * {@code defaultAction}. 106 | * 107 | * @param t {@inheritDoc} 108 | * @param p {@inheritDoc} 109 | * @return the result of {@code defaultAction} 110 | */ 111 | @Override 112 | public R visitIntersection(IntersectionType t, P p){ 113 | return defaultAction(t, p); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/element/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | /** 27 | * Interfaces used to model elements of the Java programming language. 28 | * 29 | * The term "element" in this package is used to refer to program 30 | * elements, the declared entities that make up a program. Elements 31 | * include classes, interfaces, methods, constructors, and fields. 32 | * The interfaces in this package do not model the structure of a 33 | * program inside a method body; for example there is no 34 | * representation of a {@code for} loop or {@code try}-{@code finally} 35 | * block. However, the interfaces can model some structures only 36 | * appearing inside method bodies, such as local variables and 37 | * anonymous classes. 38 | * 39 | *

When used in the context of annotation processing, an accurate 40 | * model of the element being represented must be returned. As this 41 | * is a language model, the source code provides the fiducial 42 | * (reference) representation of the construct in question rather than 43 | * a representation in an executable output like a class file. 44 | * Executable output may serve as the basis for creating a modeling 45 | * element. However, the process of translating source code to 46 | * executable output may not permit recovering some aspects of the 47 | * source code representation. For example, annotations with 48 | * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source} 49 | * {@linkplain java.lang.annotation.Retention retention} cannot be 50 | * recovered from class files and class files might not be able to 51 | * provide source position information. 52 | * 53 | * Names of parameters may not be recoverable from class files. 54 | * 55 | * The {@linkplain javax.lang.model.element.Modifier modifiers} on an 56 | * element may differ in some cases including: 57 | * 58 | *

    59 | *
  • {@code strictfp} on a class or interface 60 | *
  • {@code final} on a parameter 61 | *
  • {@code protected}, {@code private}, and {@code static} on classes and interfaces 62 | *
63 | * 64 | * Additionally, synthetic constructs in a class file, such as 65 | * accessor methods used in implementing nested classes and bridge 66 | * methods used in implementing covariant returns, are translation 67 | * artifacts outside of this model. 68 | * 69 | *

During annotation processing, operating on incomplete or 70 | * erroneous programs is necessary; however, there are fewer 71 | * guarantees about the nature of the resulting model. If the source 72 | * code is not syntactically well-formed or has some other 73 | * irrecoverable error that could not be removed by the generation of 74 | * new types, a model may or may not be provided as a quality of 75 | * implementation issue. 76 | * If a program is syntactically valid but erroneous in some other 77 | * fashion, any returned model must have no less information than if 78 | * all the method bodies in the program were replaced by {@code "throw 79 | * new RuntimeException();"}. If a program refers to a missing type XYZ, 80 | * the returned model must contain no less information than if the 81 | * declaration of type XYZ were assumed to be {@code "class XYZ {}"}, 82 | * {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code 83 | * "@interface XYZ {}"}. If a program refers to a missing type {@code 84 | * XYZ}, the returned model must contain no less 85 | * information than if the declaration of XYZ were assumed to be 86 | * {@code "class XYZ {}"} or {@code "interface XYZ {}"} 88 | * 89 | *

Unless otherwise specified in a particular implementation, the 90 | * collections returned by methods in this package should be expected 91 | * to be unmodifiable by the caller and unsafe for concurrent access. 92 | * 93 | *

Unless otherwise specified, methods in this package will throw 94 | * a {@code NullPointerException} if given a {@code null} argument. 95 | * 96 | * @author Joseph D. Darcy 97 | * @author Scott Seligman 98 | * @author Peter von der Ahé 99 | * @since 1.6 100 | */ 101 | package javax.lang.model.element; 102 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/AbstractAnnotationValueVisitor6.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | 29 | import javax.lang.model.element.*; 30 | 31 | import static javax.lang.model.SourceVersion.*; 32 | import javax.lang.model.SourceVersion; 33 | import javax.annotation.processing.SupportedSourceVersion; 34 | 35 | /** 36 | * A skeletal visitor for annotation values with default behavior 37 | * appropriate for the {@link SourceVersion#RELEASE_6 RELEASE_6} 38 | * source version. 39 | * 40 | *

WARNING: The {@code AnnotationValueVisitor} interface 41 | * implemented by this class may have methods added to it in the 42 | * future to accommodate new, currently unknown, language structures 43 | * added to future versions of the Java™ programming language. 44 | * Therefore, methods whose names begin with {@code "visit"} may be 45 | * added to this class in the future; to avoid incompatibilities, 46 | * classes which extend this class should not declare any instance 47 | * methods with names beginning with {@code "visit"}. 48 | * 49 | *

When such a new visit method is added, the default 50 | * implementation in this class will be to call the {@link 51 | * #visitUnknown visitUnknown} method. A new abstract annotation 52 | * value visitor class will also be introduced to correspond to the 53 | * new language level; this visitor will have different default 54 | * behavior for the visit method in question. When the new visitor is 55 | * introduced, all or portions of this visitor may be deprecated. 56 | * 57 | *

Note that adding a default implementation of a new visit method 58 | * in a visitor class will occur instead of adding a default 59 | * method directly in the visitor interface since a Java SE 8 60 | * language feature cannot be used to this version of the API since 61 | * this version is required to be runnable on Java SE 7 62 | * implementations. Future versions of the API that are only required 63 | * to run on Java SE 8 and later may take advantage of default methods 64 | * in this situation. 65 | * 66 | * @param the return type of this visitor's methods 67 | * @param

the type of the additional parameter to this visitor's methods. 68 | * 69 | * @author Joseph D. Darcy 70 | * @author Scott Seligman 71 | * @author Peter von der Ahé 72 | * 73 | * @see AbstractAnnotationValueVisitor7 74 | * @see AbstractAnnotationValueVisitor8 75 | * @since 1.6 76 | */ 77 | @SupportedSourceVersion(RELEASE_6) 78 | public abstract class AbstractAnnotationValueVisitor6 79 | implements AnnotationValueVisitor { 80 | 81 | /** 82 | * Constructor for concrete subclasses to call. 83 | */ 84 | protected AbstractAnnotationValueVisitor6() {} 85 | 86 | /** 87 | * Visits an annotation value as if by passing itself to that 88 | * value's {@link AnnotationValue#accept accept}. The invocation 89 | * {@code v.visit(av)} is equivalent to {@code av.accept(v, p)}. 90 | * @param av {@inheritDoc} 91 | * @param p {@inheritDoc} 92 | */ 93 | public final R visit(AnnotationValue av, P p) { 94 | return av.accept(this, p); 95 | } 96 | 97 | /** 98 | * Visits an annotation value as if by passing itself to that 99 | * value's {@link AnnotationValue#accept accept} method passing 100 | * {@code null} for the additional parameter. The invocation 101 | * {@code v.visit(av)} is equivalent to {@code av.accept(v, 102 | * null)}. 103 | * @param av {@inheritDoc} 104 | */ 105 | public final R visit(AnnotationValue av) { 106 | return av.accept(this, null); 107 | } 108 | 109 | /** 110 | * {@inheritDoc} 111 | * 112 | *

The default implementation of this method in {@code 113 | * AbstractAnnotationValueVisitor6} will always throw {@code 114 | * UnknownAnnotationValueException}. This behavior is not 115 | * required of a subclass. 116 | * 117 | * @param av {@inheritDoc} 118 | * @param p {@inheritDoc} 119 | */ 120 | public R visitUnknown(AnnotationValue av, P p) { 121 | throw new UnknownAnnotationValueException(av, p); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/ElementScanner8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.element.*; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import javax.lang.model.SourceVersion; 31 | import static javax.lang.model.SourceVersion.*; 32 | 33 | 34 | /** 35 | * A scanning visitor of program elements with default behavior 36 | * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8} 37 | * source version. The visitXYZ methods in this 38 | * class scan their component elements by calling {@code scan} on 39 | * their {@linkplain Element#getEnclosedElements enclosed elements}, 40 | * {@linkplain ExecutableElement#getParameters parameters}, etc., as 41 | * indicated in the individual method specifications. A subclass can 42 | * control the order elements are visited by overriding the 43 | * visitXYZ methods. Note that clients of a scanner 44 | * may get the desired behavior be invoking {@code v.scan(e, p)} rather 45 | * than {@code v.visit(e, p)} on the root objects of interest. 46 | * 47 | *

When a subclass overrides a visitXYZ method, the 48 | * new method can cause the enclosed elements to be scanned in the 49 | * default way by calling super.visitXYZ. In this 50 | * fashion, the concrete visitor can control the ordering of traversal 51 | * over the component elements with respect to the additional 52 | * processing; for example, consistently calling 53 | * super.visitXYZ at the start of the overridden 54 | * methods will yield a preorder traversal, etc. If the component 55 | * elements should be traversed in some other order, instead of 56 | * calling super.visitXYZ, an overriding visit method 57 | * should call {@code scan} with the elements in the desired order. 58 | * 59 | *

Methods in this class may be overridden subject to their 60 | * general contract. Note that annotating methods in concrete 61 | * subclasses with {@link java.lang.Override @Override} will help 62 | * ensure that methods are overridden as intended. 63 | * 64 | *

WARNING: The {@code ElementVisitor} interface 65 | * implemented by this class may have methods added to it in the 66 | * future to accommodate new, currently unknown, language structures 67 | * added to future versions of the Java™ programming language. 68 | * Therefore, methods whose names begin with {@code "visit"} may be 69 | * added to this class in the future; to avoid incompatibilities, 70 | * classes which extend this class should not declare any instance 71 | * methods with names beginning with {@code "visit"}. 72 | * 73 | *

When such a new visit method is added, the default 74 | * implementation in this class will be to call the {@link 75 | * #visitUnknown visitUnknown} method. A new element scanner visitor 76 | * class will also be introduced to correspond to the new language 77 | * level; this visitor will have different default behavior for the 78 | * visit method in question. When the new visitor is introduced, all 79 | * or portions of this visitor may be deprecated. 80 | * 81 | * @param the return type of this visitor's methods. Use {@link 82 | * Void} for visitors that do not need to return results. 83 | * @param

the type of the additional parameter to this visitor's 84 | * methods. Use {@code Void} for visitors that do not need an 85 | * additional parameter. 86 | * 87 | * @see ElementScanner6 88 | * @see ElementScanner7 89 | * @since 1.8 90 | */ 91 | @SupportedSourceVersion(RELEASE_8) 92 | public class ElementScanner8 extends ElementScanner7 { 93 | /** 94 | * Constructor for concrete subclasses; uses {@code null} for the 95 | * default value. 96 | */ 97 | protected ElementScanner8(){ 98 | super(null); 99 | } 100 | 101 | /** 102 | * Constructor for concrete subclasses; uses the argument for the 103 | * default value. 104 | * 105 | * @param defaultValue the default value 106 | */ 107 | protected ElementScanner8(R defaultValue){ 108 | super(defaultValue); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/TypeKindVisitor7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.lang.model.type.*; 29 | import javax.annotation.processing.SupportedSourceVersion; 30 | import static javax.lang.model.SourceVersion.*; 31 | import javax.lang.model.SourceVersion; 32 | 33 | /** 34 | * A visitor of types based on their {@linkplain TypeKind kind} with 35 | * default behavior appropriate for the {@link SourceVersion#RELEASE_7 36 | * RELEASE_7} source version. For {@linkplain 37 | * TypeMirror types} XYZ that may have more than one 38 | * kind, the visitXYZ methods in this class delegate 39 | * to the visitXYZKind method corresponding to the 40 | * first argument's kind. The visitXYZKind methods 41 | * call {@link #defaultAction defaultAction}, passing their arguments 42 | * to {@code defaultAction}'s corresponding parameters. 43 | * 44 | *

Methods in this class may be overridden subject to their 45 | * general contract. Note that annotating methods in concrete 46 | * subclasses with {@link java.lang.Override @Override} will help 47 | * ensure that methods are overridden as intended. 48 | * 49 | *

WARNING: The {@code TypeVisitor} interface implemented 50 | * by this class may have methods added to it in the future to 51 | * accommodate new, currently unknown, language structures added to 52 | * future versions of the Java™ programming language. 53 | * Therefore, methods whose names begin with {@code "visit"} may be 54 | * added to this class in the future; to avoid incompatibilities, 55 | * classes which extend this class should not declare any instance 56 | * methods with names beginning with {@code "visit"}. 57 | * 58 | *

When such a new visit method is added, the default 59 | * implementation in this class will be to call the {@link 60 | * #visitUnknown visitUnknown} method. A new type kind visitor class 61 | * will also be introduced to correspond to the new language level; 62 | * this visitor will have different default behavior for the visit 63 | * method in question. When the new visitor is introduced, all or 64 | * portions of this visitor may be deprecated. 65 | * 66 | *

Note that adding a default implementation of a new visit method 67 | * in a visitor class will occur instead of adding a default 68 | * method directly in the visitor interface since a Java SE 8 69 | * language feature cannot be used to this version of the API since 70 | * this version is required to be runnable on Java SE 7 71 | * implementations. Future versions of the API that are only required 72 | * to run on Java SE 8 and later may take advantage of default methods 73 | * in this situation. 74 | * 75 | * @param the return type of this visitor's methods. Use {@link 76 | * Void} for visitors that do not need to return results. 77 | * @param

the type of the additional parameter to this visitor's 78 | * methods. Use {@code Void} for visitors that do not need an 79 | * additional parameter. 80 | * 81 | * @see TypeKindVisitor6 82 | * @see TypeKindVisitor8 83 | * @since 1.7 84 | */ 85 | @SupportedSourceVersion(RELEASE_7) 86 | public class TypeKindVisitor7 extends TypeKindVisitor6 { 87 | /** 88 | * Constructor for concrete subclasses to call; uses {@code null} 89 | * for the default value. 90 | */ 91 | protected TypeKindVisitor7() { 92 | super(null); 93 | } 94 | 95 | /** 96 | * Constructor for concrete subclasses to call; uses the argument 97 | * for the default value. 98 | * 99 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 100 | */ 101 | protected TypeKindVisitor7(R defaultValue) { 102 | super(defaultValue); 103 | } 104 | 105 | /** 106 | * This implementation visits a {@code UnionType} by calling 107 | * {@code defaultAction}. 108 | * 109 | * @param t {@inheritDoc} 110 | * @param p {@inheritDoc} 111 | * @return the result of {@code defaultAction} 112 | */ 113 | @Override 114 | public R visitUnion(UnionType t, P p) { 115 | return defaultAction(t, p); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /library/src/main/java/javax/lang/model/util/TypeKindVisitor8.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | */ 25 | 26 | package javax.lang.model.util; 27 | 28 | import javax.annotation.processing.SupportedSourceVersion; 29 | import javax.lang.model.SourceVersion; 30 | import javax.lang.model.type.*; 31 | import static javax.lang.model.SourceVersion.*; 32 | 33 | /** 34 | * A visitor of types based on their {@linkplain TypeKind kind} with 35 | * default behavior appropriate for the {@link SourceVersion#RELEASE_8 36 | * RELEASE_8} source version. For {@linkplain 37 | * TypeMirror types} XYZ that may have more than one 38 | * kind, the visitXYZ methods in this class delegate 39 | * to the visitXYZKind method corresponding to the 40 | * first argument's kind. The visitXYZKind methods 41 | * call {@link #defaultAction defaultAction}, passing their arguments 42 | * to {@code defaultAction}'s corresponding parameters. 43 | * 44 | *

Methods in this class may be overridden subject to their 45 | * general contract. Note that annotating methods in concrete 46 | * subclasses with {@link java.lang.Override @Override} will help 47 | * ensure that methods are overridden as intended. 48 | * 49 | *

WARNING: The {@code TypeVisitor} interface implemented 50 | * by this class may have methods added to it in the future to 51 | * accommodate new, currently unknown, language structures added to 52 | * future versions of the Java™ programming language. 53 | * Therefore, methods whose names begin with {@code "visit"} may be 54 | * added to this class in the future; to avoid incompatibilities, 55 | * classes which extend this class should not declare any instance 56 | * methods with names beginning with {@code "visit"}. 57 | * 58 | *

When such a new visit method is added, the default 59 | * implementation in this class will be to call the {@link 60 | * #visitUnknown visitUnknown} method. A new type kind visitor class 61 | * will also be introduced to correspond to the new language level; 62 | * this visitor will have different default behavior for the visit 63 | * method in question. When the new visitor is introduced, all or 64 | * portions of this visitor may be deprecated. 65 | * 66 | *

Note that adding a default implementation of a new visit method 67 | * in a visitor class will occur instead of adding a default 68 | * method directly in the visitor interface since a Java SE 8 69 | * language feature cannot be used to this version of the API since 70 | * this version is required to be runnable on Java SE 7 71 | * implementations. Future versions of the API that are only required 72 | * to run on Java SE 8 and later may take advantage of default methods 73 | * in this situation. 74 | * 75 | * @param the return type of this visitor's methods. Use {@link 76 | * Void} for visitors that do not need to return results. 77 | * @param

the type of the additional parameter to this visitor's 78 | * methods. Use {@code Void} for visitors that do not need an 79 | * additional parameter. 80 | * 81 | * @see TypeKindVisitor6 82 | * @see TypeKindVisitor7 83 | * @since 1.8 84 | */ 85 | @SupportedSourceVersion(RELEASE_8) 86 | public class TypeKindVisitor8 extends TypeKindVisitor7 { 87 | /** 88 | * Constructor for concrete subclasses to call; uses {@code null} 89 | * for the default value. 90 | */ 91 | protected TypeKindVisitor8() { 92 | super(null); 93 | } 94 | 95 | /** 96 | * Constructor for concrete subclasses to call; uses the argument 97 | * for the default value. 98 | * 99 | * @param defaultValue the value to assign to {@link #DEFAULT_VALUE} 100 | */ 101 | protected TypeKindVisitor8(R defaultValue) { 102 | super(defaultValue); 103 | } 104 | 105 | /** 106 | * This implementation visits an {@code IntersectionType} by calling 107 | * {@code defaultAction}. 108 | * 109 | * @param t {@inheritDoc} 110 | * @param p {@inheritDoc} 111 | * @return the result of {@code defaultAction} 112 | */ 113 | @Override 114 | public R visitIntersection(IntersectionType t, P p) { 115 | return defaultAction(t, p); 116 | } 117 | } 118 | --------------------------------------------------------------------------------