From 35f6a0a43bf8ac645c8c5d0cb82f2936f172f7f9 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Tue, 9 Jan 2018 15:35:13 -0800 Subject: [PATCH] Ensure all generated classes are fully nullabilitily annotated (#2789) * Ensure all generated classes are fully nullability annotated Signed-off-by: Alex Saveau --- .../compiler/AppModuleGenerator.java | 37 ++++++-- .../compiler/GlideExtensionValidator.java | 9 +- .../annotation/compiler/ProcessorUtil.java | 6 ++ .../compiler/RequestBuilderGenerator.java | 36 ++++++-- .../RequestManagerFactoryGenerator.java | 25 +++++- .../compiler/RequestManagerGenerator.java | 87 ++++++++++--------- .../compiler/RequestOptionsGenerator.java | 24 ++--- .../GeneratedAppGlideModuleImpl.java | 6 +- .../GeneratedAppGlideModuleImpl.java | 6 +- .../GeneratedAppGlideModuleImpl.java | 6 +- .../GeneratedAppGlideModuleImpl.java | 6 +- .../GeneratedRequestManagerFactory.java | 6 +- .../EmptyAppGlideModuleTest/GlideOptions.java | 26 ++++++ .../EmptyAppGlideModuleTest/GlideRequest.java | 6 +- .../GlideRequests.java | 6 +- .../MemoizeStaticMethod/GlideOptions.java | 28 +++++- .../MemoizeStaticMethod/GlideRequest.java | 8 +- .../OverrideExtend/GlideOptions.java | 28 +++++- .../OverrideExtend/GlideRequest.java | 8 +- .../GlideOptions.java | 27 +++++- .../GlideRequest.java | 8 +- .../OverrideReplace/GlideOptions.java | 28 +++++- .../OverrideReplace/GlideRequest.java | 8 +- .../SkipStaticMethod/GlideOptions.java | 28 +++++- .../SkipStaticMethod/GlideRequest.java | 8 +- .../StaticMethodName/GlideOptions.java | 28 +++++- .../StaticMethodName/GlideRequest.java | 8 +- .../GlideOptions.java | 28 +++++- .../GlideRequest.java | 8 +- .../GlideOptions.java | 26 ++++++ .../GlideRequests.java | 6 +- .../MemoizeStaticMethod/GlideOptions.java | 28 +++++- .../MemoizeStaticMethod/GlideRequest.java | 8 +- .../OverrideExtend/GlideOptions.java | 28 +++++- .../OverrideExtend/GlideRequest.java | 8 +- .../OverrideReplace/GlideOptions.java | 28 +++++- .../OverrideReplace/GlideRequest.java | 8 +- .../SkipStaticMethod/GlideOptions.java | 28 +++++- .../SkipStaticMethod/GlideRequest.java | 8 +- .../StaticMethodName/GlideOptions.java | 28 +++++- .../StaticMethodName/GlideRequest.java | 8 +- .../GlideOptions.java | 28 +++++- .../GlideRequest.java | 8 +- .../GlideOptions.java | 26 ++++++ .../GlideRequests.java | 6 +- .../integration/okhttp/OkHttpGlideModule.java | 3 +- .../okhttp3/OkHttpGlideModule.java | 3 +- .../integration/volley/VolleyGlideModule.java | 3 +- .../bumptech/glide/module/AppGlideModule.java | 3 +- .../bumptech/glide/module/AppliesOptions.java | 4 +- .../glide/module/LibraryGlideModule.java | 1 + .../bumptech/glide/module/ManifestParser.java | 1 + .../glide/module/RegistersComponents.java | 1 + .../glide/module/ManifestParserTest.java | 5 +- .../samples/flickr/FlickrGlideModule.java | 2 +- 55 files changed, 682 insertions(+), 167 deletions(-) diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java index e12828b84d..291f594ae7 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/AppModuleGenerator.java @@ -1,9 +1,12 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; + import com.bumptech.glide.annotation.Excludes; import com.squareup.javapoet.AnnotationSpec; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; @@ -78,6 +81,7 @@ final class AppModuleGenerator { private static final String GENERATED_APP_MODULE_IMPL_SIMPLE_NAME = "GeneratedAppGlideModuleImpl"; private static final String GENERATED_ROOT_MODULE_SIMPLE_NAME = "GeneratedAppGlideModule"; + private final ProcessorUtil processorUtil; AppModuleGenerator(ProcessorUtil processorUtil) { @@ -110,8 +114,16 @@ TypeSpec generate(TypeElement appGlideModule, Set libraryGlideModuleClas MethodSpec.methodBuilder("applyOptions") .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) - .addParameter(ClassName.get("android.content", "Context"), "context") - .addParameter(ClassName.get("com.bumptech.glide", "GlideBuilder"), "builder") + .addParameter(ParameterSpec.builder( + ClassName.get("android.content", "Context"), "context") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder( + ClassName.get("com.bumptech.glide", "GlideBuilder"), "builder") + .addAnnotation(nonNull()) + .build() + ) .addStatement("appGlideModule.applyOptions(context, builder)", appGlideModule) .build(); @@ -147,6 +159,7 @@ TypeSpec generate(TypeElement appGlideModule, Set libraryGlideModuleClas builder.addMethod( MethodSpec.methodBuilder("getRequestManagerFactory") .addAnnotation(Override.class) + .addAnnotation(nonNull()) .returns(generatedRequestManagerFactoryClassName) .addStatement("return new $T()", generatedRequestManagerFactoryClassName) .build()); @@ -165,7 +178,7 @@ private MethodSpec generateGetExcludedModuleClasses(Collection excludedC MethodSpec.Builder builder = MethodSpec.methodBuilder("getExcludedModuleClasses") .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) - .addAnnotation(ClassName.get("android.support.annotation", "NonNull")) + .addAnnotation(nonNull()) .returns(setOfClassOfWildcardOfObject); if (excludedClassNames.isEmpty()) { @@ -193,9 +206,21 @@ private MethodSpec generateRegisterComponents( MethodSpec.methodBuilder("registerComponents") .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) - .addParameter(ClassName.get("android.content", "Context"), "context") - .addParameter(ClassName.get("com.bumptech.glide", "Glide"), "glide") - .addParameter(ClassName.get("com.bumptech.glide", "Registry"), "registry"); + .addParameter(ParameterSpec.builder( + ClassName.get("android.content", "Context"), "context") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder( + ClassName.get("com.bumptech.glide", "Glide"), "glide") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder( + ClassName.get("com.bumptech.glide", "Registry"), "registry") + .addAnnotation(nonNull()) + .build() + ); for (String glideModule : libraryGlideModuleClassNames) { if (excludedGlideModuleClassNames.contains(glideModule)) { diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java index 842566324c..24bd13efed 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/GlideExtensionValidator.java @@ -1,5 +1,7 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; + import com.bumptech.glide.annotation.GlideOption; import com.bumptech.glide.annotation.GlideType; import com.google.common.base.Function; @@ -29,9 +31,6 @@ * for an Application. */ final class GlideExtensionValidator { - private static final String FULLY_QUALIFIED_NON_NULL_CLASS_NAME = - "android.support.annotation.NonNull"; - private final ProcessingEnvironment processingEnvironment; private final ProcessorUtil processorUtil; @@ -254,11 +253,11 @@ public String apply(AnnotationMirror input) { } }) .toSet(); - if (!annotationNames.contains(FULLY_QUALIFIED_NON_NULL_CLASS_NAME)) { + if (!annotationNames.contains(nonNull().reflectionName())) { processingEnvironment.getMessager().printMessage( Kind.WARNING, executableElement.getEnclosingElement() + "#" + executableElement.getSimpleName() - + " is missing the " + FULLY_QUALIFIED_NON_NULL_CLASS_NAME + " annotation," + + " is missing the " + nonNull().reflectionName() + " annotation," + " please add it to ensure that your extension methods are always returning non-null" + " values"); } diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java index 3daf58dad8..201dd604a2 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java @@ -63,6 +63,8 @@ final class ProcessorUtil { GLIDE_MODULE_PACKAGE_NAME + "." + LIBRARY_GLIDE_MODULE_SIMPLE_NAME; private static final String COMPILER_PACKAGE_NAME = GlideAnnotationProcessor.class.getPackage().getName(); + private static final ClassName NONNULL_ANNOTATION = + ClassName.get("android.support.annotation", "NonNull"); private final ProcessingEnvironment processingEnv; private final TypeElement appGlideModuleType; @@ -332,6 +334,10 @@ private static List getAnnotations(VariableElement element) { return result; } + static ClassName nonNull() { + return NONNULL_ANNOTATION; + } + List findInstanceMethodsReturning(TypeElement clazz, TypeMirror returnType) { return FluentIterable.from(clazz.getEnclosedElements()) .filter(new FilterPublicMethods(returnType, MethodType.INSTANCE)) diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestBuilderGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestBuilderGenerator.java index 58e5db1306..2486c82261 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestBuilderGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestBuilderGenerator.java @@ -1,5 +1,7 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; + import com.bumptech.glide.annotation.GlideExtension; import com.bumptech.glide.annotation.GlideOption; import com.google.common.base.Function; @@ -108,9 +110,7 @@ final class RequestBuilderGenerator { ImmutableSet.of("clone", "apply", "autoLock", "lock", "autoClone"); private static final ClassName CHECK_RESULT_CLASS_NAME = ClassName.get("android.support.annotation", "CheckResult"); - private static final AnnotationSpec NON_NULL = AnnotationSpec - .builder(ClassName.get("android.support.annotation", "NonNull")) - .build(); + private static final AnnotationSpec NON_NULL = AnnotationSpec.builder(nonNull()).build(); private final ProcessingEnvironment processingEnv; private final ProcessorUtil processorUtil; @@ -402,8 +402,14 @@ private List generateConstructors() { MethodSpec firstConstructor = MethodSpec.constructorBuilder() - .addParameter(classOfTranscodeType, "transcodeClass") - .addParameter(requestBuilderOfWildcardOfObject, "other") + .addParameter(ParameterSpec.builder(classOfTranscodeType, "transcodeClass") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(requestBuilderOfWildcardOfObject, "other") + .addAnnotation(nonNull()) + .build() + ) .addStatement("super($N, $N)", "transcodeClass", "other") .build(); @@ -412,10 +418,22 @@ private List generateConstructors() { ClassName requestManager = ClassName.get("com.bumptech.glide", "RequestManager"); MethodSpec secondConstructor = MethodSpec.constructorBuilder() - .addParameter(glide, "glide") - .addParameter(requestManager, "requestManager") - .addParameter(classOfTranscodeType, "transcodeClass") - .addParameter(context, "context") + .addParameter(ParameterSpec.builder(glide, "glide") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(requestManager, "requestManager") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(classOfTranscodeType, "transcodeClass") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(context, "context") + .addAnnotation(nonNull()) + .build() + ) .addStatement( "super($N, $N ,$N, $N)", "glide", "requestManager", "transcodeClass", "context") .build(); diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerFactoryGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerFactoryGenerator.java index bc059256bf..4aec3c8bb4 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerFactoryGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerFactoryGenerator.java @@ -1,7 +1,10 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; + import com.squareup.javapoet.ClassName; import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.TypeSpec; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Modifier; @@ -77,11 +80,25 @@ TypeSpec generate(String generatedCodePackageName, TypeSpec generatedRequestMana MethodSpec.methodBuilder("build") .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) + .addAnnotation(nonNull()) .returns(requestManagerClassName) - .addParameter(ClassName.get(glideType), "glide") - .addParameter(ClassName.get(lifecycleType), "lifecycle") - .addParameter(ClassName.get(requestManagerTreeNodeType), "treeNode") - .addParameter(CONTEXT_CLASS_NAME, "context") + .addParameter(ParameterSpec.builder(ClassName.get(glideType), "glide") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(ClassName.get(lifecycleType), "lifecycle") + .addAnnotation(nonNull()) + .build() + ) + .addParameter( + ParameterSpec.builder(ClassName.get(requestManagerTreeNodeType), "treeNode") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(CONTEXT_CLASS_NAME, "context") + .addAnnotation(nonNull()) + .build() + ) .addStatement( "return new $T(glide, lifecycle, treeNode, context)", ClassName.get(generatedCodePackageName, generatedRequestManagerSpec.name)) diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerGenerator.java index 4f8b284a99..31e646ddca 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestManagerGenerator.java @@ -1,5 +1,7 @@ package com.bumptech.glide.annotation.compiler; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; + import com.bumptech.glide.annotation.GlideExtension; import com.bumptech.glide.annotation.GlideType; import com.google.common.base.Function; @@ -60,13 +62,8 @@ final class RequestManagerGenerator { "com.bumptech.glide.manager.RequestManagerTreeNode"; private static final ClassName CHECK_RESULT_CLASS_NAME = ClassName.get("android.support.annotation", "CheckResult"); - private static final ClassName NON_NULL_CLASS_NAME = - ClassName.get("android.support.annotation", "NonNull"); private static final ClassName CONTEXT_CLASS_NAME = ClassName.get("android.content", "Context"); - private static final AnnotationSpec NON_NULL = AnnotationSpec - .builder(ClassName.get("android.support.annotation", "NonNull")) - .build(); private static final String GENERATED_REQUEST_MANAGER_SIMPLE_NAME = "GlideRequests"; @@ -105,37 +102,49 @@ TypeSpec generate( Set glideExtensions) { generatedRequestBuilderClassName = ClassName.get(generatedCodePackageName, requestBuilder.name); return TypeSpec.classBuilder(GENERATED_REQUEST_MANAGER_SIMPLE_NAME) - .superclass(requestManagerClassName) - .addJavadoc("Includes all additions from methods in {@link $T}s\n" - + "annotated with {@link $T}\n" - + "\n" - + "

Generated code, do not modify\n", - GlideExtension.class, GlideType.class) + .superclass(requestManagerClassName) + .addJavadoc("Includes all additions from methods in {@link $T}s\n" + + "annotated with {@link $T}\n" + + "\n" + + "

Generated code, do not modify\n", + GlideExtension.class, GlideType.class) .addAnnotation( AnnotationSpec.builder(SuppressWarnings.class) .addMember("value", "$S", "deprecation") .build()) - .addModifiers(Modifier.PUBLIC) - .addMethod(generateAsMethod(generatedCodePackageName, requestBuilder)) - .addMethod(generateCallSuperConstructor()) - .addMethods(generateExtensionRequestManagerMethods(glideExtensions)) - .addMethods(generateRequestManagerRequestManagerMethodOverrides(generatedCodePackageName)) - .addMethods(generateRequestManagerRequestBuilderMethodOverrides()) - .addMethods( - FluentIterable.from( - Collections.singletonList( - generateOverrideSetRequestOptions(generatedCodePackageName, requestOptions))) - .filter(Predicates.notNull())) - .build(); + .addModifiers(Modifier.PUBLIC) + .addMethod(generateAsMethod(generatedCodePackageName, requestBuilder)) + .addMethod(generateCallSuperConstructor()) + .addMethods(generateExtensionRequestManagerMethods(glideExtensions)) + .addMethods(generateRequestManagerRequestManagerMethodOverrides(generatedCodePackageName)) + .addMethods(generateRequestManagerRequestBuilderMethodOverrides()) + .addMethods( + FluentIterable.from( + Collections.singletonList( + generateOverrideSetRequestOptions(generatedCodePackageName, requestOptions))) + .filter(Predicates.notNull())) + .build(); } private MethodSpec generateCallSuperConstructor() { return MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) - .addParameter(ClassName.get(glideType), "glide") - .addParameter(ClassName.get(lifecycleType), "lifecycle") - .addParameter(ClassName.get(requestManagerTreeNodeType), "treeNode") - .addParameter(CONTEXT_CLASS_NAME, "context") + .addParameter(ParameterSpec.builder(ClassName.get(glideType), "glide") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(ClassName.get(lifecycleType), "lifecycle") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(ClassName.get(requestManagerTreeNodeType), "treeNode") + .addAnnotation(nonNull()) + .build() + ) + .addParameter(ParameterSpec.builder(CONTEXT_CLASS_NAME, "context") + .addAnnotation(nonNull()) + .build() + ) .addStatement("super(glide, lifecycle, treeNode, context)") .build(); } @@ -155,10 +164,11 @@ private MethodSpec generateAsMethod(String generatedCodePackageName, TypeSpec re .addModifiers(Modifier.PUBLIC) .addAnnotation(Override.class) .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) - .addAnnotation(NON_NULL) + .addAnnotation(nonNull()) .addTypeVariable(TypeVariableName.get("ResourceType")) .returns(requestBuilderOfResourceType) - .addParameter(classOfResouceType.annotated(NON_NULL), "resourceClass") + .addParameter(classOfResouceType.annotated(AnnotationSpec.builder(nonNull()).build()), + "resourceClass") .addStatement("return new $T<>(glide, this, resourceClass, context)", this.generatedRequestBuilderClassName) .build(); @@ -183,6 +193,7 @@ private MethodSpec generateRequestManagerRequestManagerMethodOverride( ClassName generatedRequestManagerName = ClassName.get(generatedPackageName, GENERATED_REQUEST_MANAGER_SIMPLE_NAME); return ProcessorUtil.overriding(method) + .addAnnotation(nonNull()) .returns(generatedRequestManagerName) .addCode(ProcessorUtil.generateCastingSuperCall(generatedRequestManagerName, method)) .build(); @@ -220,7 +231,7 @@ public MethodSpec apply(ExecutableElement input) { */ private MethodSpec generateRequestManagerRequestBuilderMethodOverride( ExecutableElement methodToOverride) { - // We've already verified that this method returns a RequestBuilder and RequestBuilders have + // We've already verified that this method returns a RequestBuilder and RequestBuilders have // exactly one type argument, so this is safe unless those assumptions change. TypeMirror typeArgument = ((DeclaredType) methodToOverride.getReturnType()).getTypeArguments().get(0); @@ -265,7 +276,7 @@ private MethodSpec generateAdditionalRequestManagerMethod(ExecutableElement exte private MethodSpec generateAdditionalRequestManagerMethodLegacy( ExecutableElement extensionMethod) { - String returnType = processorUtil.findClassValuesFromAnnotationOnClassAsNames(extensionMethod, + String returnType = processorUtil.findClassValuesFromAnnotationOnClassAsNames(extensionMethod, GlideType.class).iterator().next(); ClassName returnTypeClassName = ClassName.bestGuess(returnType); ParameterizedTypeName parameterizedTypeName = @@ -275,7 +286,7 @@ private MethodSpec generateAdditionalRequestManagerMethodLegacy( .addModifiers(Modifier.PUBLIC) .returns(parameterizedTypeName) .addJavadoc(processorUtil.generateSeeMethodJavadoc(extensionMethod)) - .addAnnotation(AnnotationSpec.builder(NON_NULL_CLASS_NAME).build()) + .addAnnotation(nonNull()) .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) .addStatement( "$T requestBuilder = this.as($T.class)", parameterizedTypeName, returnTypeClassName) @@ -287,7 +298,7 @@ private MethodSpec generateAdditionalRequestManagerMethodLegacy( private MethodSpec generateAdditionalRequestManagerMethodNew( ExecutableElement extensionMethod) { - String returnType = processorUtil.findClassValuesFromAnnotationOnClassAsNames(extensionMethod, + String returnType = processorUtil.findClassValuesFromAnnotationOnClassAsNames(extensionMethod, GlideType.class).iterator().next(); ClassName returnTypeClassName = ClassName.bestGuess(returnType); ParameterizedTypeName parameterizedTypeName = @@ -297,7 +308,7 @@ private MethodSpec generateAdditionalRequestManagerMethodNew( .addModifiers(Modifier.PUBLIC) .returns(parameterizedTypeName) .addJavadoc(processorUtil.generateSeeMethodJavadoc(extensionMethod)) - .addAnnotation(AnnotationSpec.builder(NON_NULL_CLASS_NAME).build()) + .addAnnotation(nonNull()) .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) .addStatement( "return ($T) $T.$N(this.as($T.class))", @@ -322,10 +333,8 @@ private MethodSpec generateOverrideSetRequestOptions( Elements elementUtils = processingEnv.getElementUtils(); TypeElement requestOptionsType = - elementUtils.getTypeElement( - RequestOptionsGenerator.REQUEST_OPTIONS_QUALIFIED_NAME); - TypeElement androidNonNullType = - elementUtils.getTypeElement("android.support.annotation.NonNull"); + elementUtils.getTypeElement( + RequestOptionsGenerator.REQUEST_OPTIONS_QUALIFIED_NAME); // This class may have just been generated and therefore may not be found if we try to obtain // it via Elements, so use just the String version instead. @@ -340,7 +349,7 @@ private MethodSpec generateOverrideSetRequestOptions( .addModifiers(Modifier.PROTECTED) .addParameter( ParameterSpec.builder(ClassName.get(requestOptionsType), parameterName) - .addAnnotation(ClassName.get(androidNonNullType)) + .addAnnotation(nonNull()) .build()) .beginControlFlow("if ($N instanceof $L)", parameterName, generatedRequestOptionsQualifiedName) diff --git a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java index 6786022301..852ebc5c08 100644 --- a/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java +++ b/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/RequestOptionsGenerator.java @@ -1,6 +1,7 @@ package com.bumptech.glide.annotation.compiler; import static com.bumptech.glide.annotation.GlideOption.OVERRIDE_EXTEND; +import static com.bumptech.glide.annotation.compiler.ProcessorUtil.nonNull; import com.bumptech.glide.annotation.GlideExtension; import com.bumptech.glide.annotation.GlideOption; @@ -78,8 +79,6 @@ final class RequestOptionsGenerator { REQUEST_OPTIONS_PACKAGE_NAME + "." + REQUEST_OPTIONS_SIMPLE_NAME; private static final ClassName CHECK_RESULT_CLASS_NAME = ClassName.get("android.support.annotation", "CheckResult"); - private static final ClassName NON_NULL_CLASS_NAME = - ClassName.get("android.support.annotation", "NonNull"); private final ProcessingEnvironment processingEnvironment; private final ClassName requestOptionsName; @@ -301,8 +300,9 @@ private List generateMethodsForRequestOptionsExtensionNew( code.append(")"); builder.addStatement(code.toString(), args.toArray(new Object[0])); - builder.addAnnotation(AnnotationSpec.builder(NON_NULL_CLASS_NAME).build()); - builder.addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()); + builder + .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) + .addAnnotation(nonNull()); List result = new ArrayList<>(); result.add(new MethodAndStaticVar(builder.build())); @@ -373,9 +373,9 @@ private List generateMethodsForRequestOptionsExtensionDeprec code.append(")"); builder.addStatement(code.toString(), args.toArray(new Object[0])); - builder.addStatement("return this"); - builder.addAnnotation(AnnotationSpec.builder(NON_NULL_CLASS_NAME).build()); - builder.addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()); + builder.addStatement("return this") + .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) + .addAnnotation(nonNull()); List result = new ArrayList<>(); result.add(new MethodAndStaticVar(builder.build())); @@ -482,7 +482,9 @@ private MethodAndStaticVar generateStaticMethodEquivalentForRequestOptionsStatic TypeVariableName.get(typeParameterElement.getSimpleName().toString())); } - methodSpecBuilder.addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()); + methodSpecBuilder + .addAnnotation(AnnotationSpec.builder(CHECK_RESULT_CLASS_NAME).build()) + .addAnnotation(nonNull()); return new MethodAndStaticVar(methodSpecBuilder.build(), requiredStaticField); } @@ -619,10 +621,8 @@ private static boolean skipStaticMethod(ExecutableElement element) { } private static final class MethodAndStaticVar { - @Nullable - final MethodSpec method; - @Nullable - final FieldSpec staticField; + @Nullable final MethodSpec method; + @Nullable final FieldSpec staticField; MethodAndStaticVar(@Nullable MethodSpec method) { this(method, null /*staticField*/); diff --git a/annotation/compiler/test/src/test/resources/AppGlideModuleWithExcludesTest/GeneratedAppGlideModuleImpl.java b/annotation/compiler/test/src/test/resources/AppGlideModuleWithExcludesTest/GeneratedAppGlideModuleImpl.java index 5d5cb67f58..ecb3b4b05a 100644 --- a/annotation/compiler/test/src/test/resources/AppGlideModuleWithExcludesTest/GeneratedAppGlideModuleImpl.java +++ b/annotation/compiler/test/src/test/resources/AppGlideModuleWithExcludesTest/GeneratedAppGlideModuleImpl.java @@ -23,12 +23,13 @@ final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule { } @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { appGlideModule.applyOptions(context, builder); } @Override - public void registerComponents(Context context, Glide glide, Registry registry) { + public void registerComponents(@NonNull Context context, @NonNull Glide glide, + @NonNull Registry registry) { appGlideModule.registerComponents(context, glide, registry); } @@ -46,6 +47,7 @@ public Set> getExcludedModuleClasses() { } @Override + @NonNull GeneratedRequestManagerFactory getRequestManagerFactory() { return new GeneratedRequestManagerFactory(); } diff --git a/annotation/compiler/test/src/test/resources/AppGlideModuleWithMultipleExcludesTest/GeneratedAppGlideModuleImpl.java b/annotation/compiler/test/src/test/resources/AppGlideModuleWithMultipleExcludesTest/GeneratedAppGlideModuleImpl.java index 8c36f266ae..af059c6b11 100644 --- a/annotation/compiler/test/src/test/resources/AppGlideModuleWithMultipleExcludesTest/GeneratedAppGlideModuleImpl.java +++ b/annotation/compiler/test/src/test/resources/AppGlideModuleWithMultipleExcludesTest/GeneratedAppGlideModuleImpl.java @@ -24,12 +24,13 @@ final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule { } @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { appGlideModule.applyOptions(context, builder); } @Override - public void registerComponents(Context context, Glide glide, Registry registry) { + public void registerComponents(@NonNull Context context, @NonNull Glide glide, + @NonNull Registry registry) { appGlideModule.registerComponents(context, glide, registry); } @@ -48,6 +49,7 @@ public Set> getExcludedModuleClasses() { } @Override + @NonNull GeneratedRequestManagerFactory getRequestManagerFactory() { return new GeneratedRequestManagerFactory(); } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppAndLibraryGlideModulesTest/GeneratedAppGlideModuleImpl.java b/annotation/compiler/test/src/test/resources/EmptyAppAndLibraryGlideModulesTest/GeneratedAppGlideModuleImpl.java index 33030d953b..6e307e0ff3 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppAndLibraryGlideModulesTest/GeneratedAppGlideModuleImpl.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppAndLibraryGlideModulesTest/GeneratedAppGlideModuleImpl.java @@ -24,12 +24,13 @@ final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule { } @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { appGlideModule.applyOptions(context, builder); } @Override - public void registerComponents(Context context, Glide glide, Registry registry) { + public void registerComponents(@NonNull Context context, @NonNull Glide glide, + @NonNull Registry registry) { new EmptyLibraryModule().registerComponents(context, glide, registry); appGlideModule.registerComponents(context, glide, registry); } @@ -46,6 +47,7 @@ public Set> getExcludedModuleClasses() { } @Override + @NonNull GeneratedRequestManagerFactory getRequestManagerFactory() { return new GeneratedRequestManagerFactory(); } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedAppGlideModuleImpl.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedAppGlideModuleImpl.java index d02d0832ea..f960738d94 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedAppGlideModuleImpl.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedAppGlideModuleImpl.java @@ -22,12 +22,13 @@ final class GeneratedAppGlideModuleImpl extends GeneratedAppGlideModule { } @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { appGlideModule.applyOptions(context, builder); } @Override - public void registerComponents(Context context, Glide glide, Registry registry) { + public void registerComponents(@NonNull Context context, @NonNull Glide glide, + @NonNull Registry registry) { appGlideModule.registerComponents(context, glide, registry); } @@ -43,6 +44,7 @@ public Set> getExcludedModuleClasses() { } @Override + @NonNull GeneratedRequestManagerFactory getRequestManagerFactory() { return new GeneratedRequestManagerFactory(); } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedRequestManagerFactory.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedRequestManagerFactory.java index 3b28d30657..2a442b0a52 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedRequestManagerFactory.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GeneratedRequestManagerFactory.java @@ -1,6 +1,7 @@ package com.bumptech.glide; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.manager.Lifecycle; import com.bumptech.glide.manager.RequestManagerRetriever; import com.bumptech.glide.manager.RequestManagerTreeNode; @@ -12,8 +13,9 @@ */ final class GeneratedRequestManagerFactory implements RequestManagerRetriever.RequestManagerFactory { @Override - public RequestManager build(Glide glide, Lifecycle lifecycle, RequestManagerTreeNode treeNode, - Context context) { + @NonNull + public RequestManager build(@NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode treeNode, @NonNull Context context) { return new GlideRequests(glide, lifecycle, treeNode, context); } } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java index cbf4c92475..9b92b8ab49 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideOptions.java @@ -46,6 +46,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -54,6 +55,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -62,6 +64,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -70,6 +73,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -78,6 +82,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -86,6 +91,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -94,6 +100,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -102,6 +109,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -110,6 +118,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -119,6 +128,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -127,6 +137,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -135,6 +146,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -147,6 +159,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -159,6 +172,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -171,6 +185,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -183,6 +198,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -191,6 +207,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -203,6 +220,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -211,6 +229,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -219,6 +238,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -227,6 +247,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -235,6 +256,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -243,6 +265,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -251,6 +274,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -259,6 +283,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -267,6 +292,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java index 877341ff3e..00c6c5d7ad 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } diff --git a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java index 6a5eb55e34..7824b67f92 100644 --- a/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/EmptyAppGlideModuleTest/GlideRequests.java @@ -31,8 +31,8 @@ */ @SuppressWarnings("deprecation") public class GlideRequests extends RequestManager { - public GlideRequests(Glide glide, Lifecycle lifecycle, RequestManagerTreeNode treeNode, - Context context) { + public GlideRequests(@NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode treeNode, @NonNull Context context) { super(glide, lifecycle, treeNode, context); } @@ -44,11 +44,13 @@ public GlideRequest as(@NonNull Class } @Override + @NonNull public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override + @NonNull public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.setDefaultRequestOptions(arg0); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java index a516bf99b8..bd161674ff 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java @@ -49,6 +49,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -57,6 +58,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -65,6 +67,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -73,6 +76,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -81,6 +85,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -89,6 +94,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -97,6 +103,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -105,6 +112,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -113,6 +121,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -122,6 +131,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -130,6 +140,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -138,6 +149,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform1 == null) { GlideOptions.fitCenterTransform1 = @@ -150,6 +162,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform2 == null) { GlideOptions.centerInsideTransform2 = @@ -162,6 +175,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform3 == null) { GlideOptions.centerCropTransform3 = @@ -174,6 +188,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform4 == null) { GlideOptions.circleCropTransform4 = @@ -186,6 +201,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -194,6 +210,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation5 == null) { GlideOptions.noTransformation5 = @@ -206,6 +223,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -214,6 +232,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -222,6 +241,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -230,6 +250,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -238,6 +259,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -246,6 +268,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -254,6 +277,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -262,6 +286,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -270,6 +295,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation6 == null) { GlideOptions.noAnimation6 = @@ -596,8 +622,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { return (GlideOptions) Extension.test(this); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java index c18eb00da3..5043b0d983 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -589,8 +615,8 @@ public final GlideOptions autoClone() { * @see RequestOptions#centerCrop() */ @Override - @NonNull @CheckResult + @NonNull public GlideOptions centerCrop() { return (GlideOptions) Extension.centerCrop(super.centerCrop()); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java index 546fb8ef92..6179c12631 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtend/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -638,8 +638,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#centerCrop() */ - @NonNull @CheckResult + @NonNull public GlideRequest centerCrop() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java index 34d14a62b6..be6e957ad5 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -119,6 +128,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -127,6 +137,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -139,6 +150,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -151,6 +163,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -163,6 +176,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -175,6 +189,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -183,6 +198,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -195,6 +211,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -203,6 +220,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -211,6 +229,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -219,6 +238,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -227,6 +247,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -235,6 +256,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -243,6 +265,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -251,6 +274,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -259,6 +283,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -580,8 +605,8 @@ public final GlideOptions autoClone() { * @see RequestOptions#override(int, int) */ @Override - @NonNull @CheckResult + @NonNull public GlideOptions override(int width, int height) { return (GlideOptions) Extension.override(super.override(width, height), width, height); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java index ec25968af8..ff1366641c 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideExtendMultipleArguments/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -638,8 +638,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#override(int, int) */ - @NonNull @CheckResult + @NonNull public GlideRequest override(int width, int height) { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).override(width, height); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java index 8c4ead00e8..8d0696027d 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -587,8 +613,8 @@ public final GlideOptions autoClone() { /** * @see Extension#centerCrop(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions centerCrop() { return (GlideOptions) Extension.centerCrop(this); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java index 546fb8ef92..6179c12631 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/OverrideReplace/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -638,8 +638,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#centerCrop() */ - @NonNull @CheckResult + @NonNull public GlideRequest centerCrop() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java index a15e5a13e0..74b45424d8 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { return (GlideOptions) Extension.test(this); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java index 5fb88e94fe..14f17549b6 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { return (GlideOptions) Extension.test(this); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionOptionsTest/StaticMethodName/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java index a801496a47..377c83922c 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see ExtensionWithOption#squareThumb(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions squareThumb() { return (GlideOptions) ExtensionWithOption.squareThumb(this); } diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java index 449e8f958a..fb9e7f7c3f 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithOptionTest/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#squareThumb() */ - @NonNull @CheckResult + @NonNull public GlideRequest squareThumb() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).squareThumb(); diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java index 0e6db8dba8..0b3fbfea02 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = diff --git a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java index d29ff687c5..87d7400996 100644 --- a/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/GlideExtensionWithTypeTest/GlideRequests.java @@ -32,8 +32,8 @@ */ @SuppressWarnings("deprecation") public class GlideRequests extends RequestManager { - public GlideRequests(Glide glide, Lifecycle lifecycle, RequestManagerTreeNode treeNode, - Context context) { + public GlideRequests(@NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode treeNode, @NonNull Context context) { super(glide, lifecycle, treeNode, context); } @@ -54,11 +54,13 @@ public GlideRequest asNumber() { } @Override + @NonNull public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override + @NonNull public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.setDefaultRequestOptions(arg0); } diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java index e217989a06..6c01001613 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideOptions.java @@ -49,6 +49,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -57,6 +58,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -65,6 +67,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -73,6 +76,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -81,6 +85,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -89,6 +94,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -97,6 +103,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -105,6 +112,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -113,6 +121,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -122,6 +131,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -130,6 +140,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -138,6 +149,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform1 == null) { GlideOptions.fitCenterTransform1 = @@ -150,6 +162,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform2 == null) { GlideOptions.centerInsideTransform2 = @@ -162,6 +175,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform3 == null) { GlideOptions.centerCropTransform3 = @@ -174,6 +188,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform4 == null) { GlideOptions.circleCropTransform4 = @@ -186,6 +201,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -194,6 +210,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation5 == null) { GlideOptions.noTransformation5 = @@ -206,6 +223,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -214,6 +232,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -222,6 +241,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -230,6 +250,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -238,6 +259,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -246,6 +268,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -254,6 +277,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -262,6 +286,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -270,6 +295,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation6 == null) { GlideOptions.noAnimation6 = @@ -596,8 +622,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { if (isAutoCloneEnabled()) { return clone().test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/MemoizeStaticMethod/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideOptions.java index 7e59eb54f6..ebeb081756 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -589,8 +615,8 @@ public final GlideOptions autoClone() { * @see RequestOptions#centerCrop() */ @Override - @NonNull @CheckResult + @NonNull public GlideOptions centerCrop() { if (isAutoCloneEnabled()) { return clone().centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java index 546fb8ef92..6179c12631 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideExtend/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -638,8 +638,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#centerCrop() */ - @NonNull @CheckResult + @NonNull public GlideRequest centerCrop() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideOptions.java index 83af4bee97..8604712bad 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -587,8 +613,8 @@ public final GlideOptions autoClone() { /** * @see Extension#centerCrop(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions centerCrop() { if (isAutoCloneEnabled()) { return clone().centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java index 546fb8ef92..6179c12631 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/OverrideReplace/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -638,8 +638,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#centerCrop() */ - @NonNull @CheckResult + @NonNull public GlideRequest centerCrop() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).centerCrop(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java index b639413697..58fb322a4e 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { if (isAutoCloneEnabled()) { return clone().test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/SkipStaticMethod/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideOptions.java index 79b4838ecc..970b5fb0a6 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see Extension#test(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions test() { if (isAutoCloneEnabled()) { return clone().test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java index 029481604c..ca9ea88137 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionOptionsTest/StaticMethodName/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#test() */ - @NonNull @CheckResult + @NonNull public GlideRequest test() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).test(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideOptions.java index 7caa63811b..a7f63dd7c6 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = @@ -594,8 +620,8 @@ public final GlideOptions autoClone() { /** * @see ExtensionWithOption#squareThumb(RequestOptions) */ - @NonNull @CheckResult + @NonNull public GlideOptions squareThumb() { if (isAutoCloneEnabled()) { return clone().squareThumb(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java index 449e8f958a..fb9e7f7c3f 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithOptionTest/GlideRequest.java @@ -53,12 +53,12 @@ "deprecation" }) public class GlideRequest extends RequestBuilder implements Cloneable { - GlideRequest(Class transcodeClass, RequestBuilder other) { + GlideRequest(@NonNull Class transcodeClass, @NonNull RequestBuilder other) { super(transcodeClass, other); } - GlideRequest(Glide glide, RequestManager requestManager, Class transcodeClass, - Context context) { + GlideRequest(@NonNull Glide glide, @NonNull RequestManager requestManager, + @NonNull Class transcodeClass, @NonNull Context context) { super(glide, requestManager ,transcodeClass, context); } @@ -652,8 +652,8 @@ public GlideRequest dontAnimate() { /** * @see GlideOptions#squareThumb() */ - @NonNull @CheckResult + @NonNull public GlideRequest squareThumb() { if (getMutableOptions() instanceof GlideOptions) { this.requestOptions = ((GlideOptions) getMutableOptions()).squareThumb(); diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideOptions.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideOptions.java index 0e6db8dba8..0b3fbfea02 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideOptions.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideOptions.java @@ -47,6 +47,7 @@ public final class GlideOptions extends RequestOptions implements Cloneable { * @see RequestOptions#sizeMultiplierOf(float) */ @CheckResult + @NonNull public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) float arg0) { return new GlideOptions().sizeMultiplier(arg0); } @@ -55,6 +56,7 @@ public static GlideOptions sizeMultiplierOf(@FloatRange(from = 0.0, to = 1.0) fl * @see RequestOptions#diskCacheStrategyOf(DiskCacheStrategy) */ @CheckResult + @NonNull public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) { return new GlideOptions().diskCacheStrategy(arg0); } @@ -63,6 +65,7 @@ public static GlideOptions diskCacheStrategyOf(@NonNull DiskCacheStrategy arg0) * @see RequestOptions#priorityOf(Priority) */ @CheckResult + @NonNull public static GlideOptions priorityOf(@NonNull Priority arg0) { return new GlideOptions().priority(arg0); } @@ -71,6 +74,7 @@ public static GlideOptions priorityOf(@NonNull Priority arg0) { * @see RequestOptions#placeholderOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@Nullable Drawable arg0) { return new GlideOptions().placeholder(arg0); } @@ -79,6 +83,7 @@ public static GlideOptions placeholderOf(@Nullable Drawable arg0) { * @see RequestOptions#placeholderOf(int) */ @CheckResult + @NonNull public static GlideOptions placeholderOf(@DrawableRes int arg0) { return new GlideOptions().placeholder(arg0); } @@ -87,6 +92,7 @@ public static GlideOptions placeholderOf(@DrawableRes int arg0) { * @see RequestOptions#errorOf(Drawable) */ @CheckResult + @NonNull public static GlideOptions errorOf(@Nullable Drawable arg0) { return new GlideOptions().error(arg0); } @@ -95,6 +101,7 @@ public static GlideOptions errorOf(@Nullable Drawable arg0) { * @see RequestOptions#errorOf(int) */ @CheckResult + @NonNull public static GlideOptions errorOf(@DrawableRes int arg0) { return new GlideOptions().error(arg0); } @@ -103,6 +110,7 @@ public static GlideOptions errorOf(@DrawableRes int arg0) { * @see RequestOptions#skipMemoryCacheOf(boolean) */ @CheckResult + @NonNull public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { return new GlideOptions().skipMemoryCache(skipMemoryCache); } @@ -111,6 +119,7 @@ public static GlideOptions skipMemoryCacheOf(boolean skipMemoryCache) { * @see RequestOptions#overrideOf(int, int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, @IntRange(from = 0) int arg1) { return new GlideOptions().override(arg0, arg1); @@ -120,6 +129,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0, * @see RequestOptions#overrideOf(int) */ @CheckResult + @NonNull public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { return new GlideOptions().override(arg0); } @@ -128,6 +138,7 @@ public static GlideOptions overrideOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#signatureOf(Key) */ @CheckResult + @NonNull public static GlideOptions signatureOf(@NonNull Key arg0) { return new GlideOptions().signature(arg0); } @@ -136,6 +147,7 @@ public static GlideOptions signatureOf(@NonNull Key arg0) { * @see RequestOptions#fitCenterTransform() */ @CheckResult + @NonNull public static GlideOptions fitCenterTransform() { if (GlideOptions.fitCenterTransform0 == null) { GlideOptions.fitCenterTransform0 = @@ -148,6 +160,7 @@ public static GlideOptions fitCenterTransform() { * @see RequestOptions#centerInsideTransform() */ @CheckResult + @NonNull public static GlideOptions centerInsideTransform() { if (GlideOptions.centerInsideTransform1 == null) { GlideOptions.centerInsideTransform1 = @@ -160,6 +173,7 @@ public static GlideOptions centerInsideTransform() { * @see RequestOptions#centerCropTransform() */ @CheckResult + @NonNull public static GlideOptions centerCropTransform() { if (GlideOptions.centerCropTransform2 == null) { GlideOptions.centerCropTransform2 = @@ -172,6 +186,7 @@ public static GlideOptions centerCropTransform() { * @see RequestOptions#circleCropTransform() */ @CheckResult + @NonNull public static GlideOptions circleCropTransform() { if (GlideOptions.circleCropTransform3 == null) { GlideOptions.circleCropTransform3 = @@ -184,6 +199,7 @@ public static GlideOptions circleCropTransform() { * @see RequestOptions#bitmapTransform(Transformation) */ @CheckResult + @NonNull public static GlideOptions bitmapTransform(@NonNull Transformation arg0) { return new GlideOptions().transform(arg0); } @@ -192,6 +208,7 @@ public static GlideOptions bitmapTransform(@NonNull Transformation arg0) * @see RequestOptions#noTransformation() */ @CheckResult + @NonNull public static GlideOptions noTransformation() { if (GlideOptions.noTransformation4 == null) { GlideOptions.noTransformation4 = @@ -204,6 +221,7 @@ public static GlideOptions noTransformation() { * @see RequestOptions#option(Option, T) */ @CheckResult + @NonNull public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) { return new GlideOptions().set(arg0, arg1); } @@ -212,6 +230,7 @@ public static GlideOptions option(@NonNull Option arg0, @NonNull T arg1) * @see RequestOptions#decodeTypeOf(Class) */ @CheckResult + @NonNull public static GlideOptions decodeTypeOf(@NonNull Class arg0) { return new GlideOptions().decode(arg0); } @@ -220,6 +239,7 @@ public static GlideOptions decodeTypeOf(@NonNull Class arg0) { * @see RequestOptions#formatOf(DecodeFormat) */ @CheckResult + @NonNull public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { return new GlideOptions().format(arg0); } @@ -228,6 +248,7 @@ public static GlideOptions formatOf(@NonNull DecodeFormat arg0) { * @see RequestOptions#frameOf(long) */ @CheckResult + @NonNull public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { return new GlideOptions().frame(arg0); } @@ -236,6 +257,7 @@ public static GlideOptions frameOf(@IntRange(from = 0) long arg0) { * @see RequestOptions#downsampleOf(DownsampleStrategy) */ @CheckResult + @NonNull public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { return new GlideOptions().downsample(arg0); } @@ -244,6 +266,7 @@ public static GlideOptions downsampleOf(@NonNull DownsampleStrategy arg0) { * @see RequestOptions#timeoutOf(int) */ @CheckResult + @NonNull public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { return new GlideOptions().timeout(arg0); } @@ -252,6 +275,7 @@ public static GlideOptions timeoutOf(@IntRange(from = 0) int arg0) { * @see RequestOptions#encodeQualityOf(int) */ @CheckResult + @NonNull public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg0) { return new GlideOptions().encodeQuality(arg0); } @@ -260,6 +284,7 @@ public static GlideOptions encodeQualityOf(@IntRange(from = 0, to = 100) int arg * @see RequestOptions#encodeFormatOf(CompressFormat) */ @CheckResult + @NonNull public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { return new GlideOptions().encodeFormat(arg0); } @@ -268,6 +293,7 @@ public static GlideOptions encodeFormatOf(@NonNull Bitmap.CompressFormat arg0) { * @see RequestOptions#noAnimation() */ @CheckResult + @NonNull public static GlideOptions noAnimation() { if (GlideOptions.noAnimation5 == null) { GlideOptions.noAnimation5 = diff --git a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java index 6d535ad155..be9b074e69 100644 --- a/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java +++ b/annotation/compiler/test/src/test/resources/LegacyGlideExtensionWithTypeTest/GlideRequests.java @@ -32,8 +32,8 @@ */ @SuppressWarnings("deprecation") public class GlideRequests extends RequestManager { - public GlideRequests(Glide glide, Lifecycle lifecycle, RequestManagerTreeNode treeNode, - Context context) { + public GlideRequests(@NonNull Glide glide, @NonNull Lifecycle lifecycle, + @NonNull RequestManagerTreeNode treeNode, @NonNull Context context) { super(glide, lifecycle, treeNode, context); } @@ -56,11 +56,13 @@ public GlideRequest asInteger() { } @Override + @NonNull public GlideRequests applyDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.applyDefaultRequestOptions(arg0); } @Override + @NonNull public GlideRequests setDefaultRequestOptions(@NonNull RequestOptions arg0) { return (GlideRequests) super.setDefaultRequestOptions(arg0); } diff --git a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpGlideModule.java b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpGlideModule.java index 36a47491fc..1bc1047a9d 100644 --- a/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpGlideModule.java +++ b/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpGlideModule.java @@ -1,6 +1,7 @@ package com.bumptech.glide.integration.okhttp; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.Registry; @@ -21,7 +22,7 @@ @Deprecated public class OkHttpGlideModule implements com.bumptech.glide.module.GlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { // Do nothing. } diff --git a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpGlideModule.java b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpGlideModule.java index 60517251fd..e58b041dd1 100644 --- a/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpGlideModule.java +++ b/integration/okhttp3/src/main/java/com/bumptech/glide/integration/okhttp3/OkHttpGlideModule.java @@ -1,6 +1,7 @@ package com.bumptech.glide.integration.okhttp3; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.Registry; @@ -22,7 +23,7 @@ @Deprecated public class OkHttpGlideModule implements com.bumptech.glide.module.GlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { // Do nothing. } diff --git a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyGlideModule.java b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyGlideModule.java index 52899e89a7..5756c6172e 100644 --- a/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyGlideModule.java +++ b/integration/volley/src/main/java/com/bumptech/glide/integration/volley/VolleyGlideModule.java @@ -1,6 +1,7 @@ package com.bumptech.glide.integration.volley; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.Registry; @@ -22,7 +23,7 @@ @SuppressWarnings("deprecation") public class VolleyGlideModule implements com.bumptech.glide.module.GlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { // Do nothing. } diff --git a/library/src/main/java/com/bumptech/glide/module/AppGlideModule.java b/library/src/main/java/com/bumptech/glide/module/AppGlideModule.java index 5b590ac362..77f1246705 100644 --- a/library/src/main/java/com/bumptech/glide/module/AppGlideModule.java +++ b/library/src/main/java/com/bumptech/glide/module/AppGlideModule.java @@ -1,6 +1,7 @@ package com.bumptech.glide.module; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.GlideBuilder; /** @@ -36,7 +37,7 @@ public boolean isManifestParsingEnabled() { } @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { // Default empty impl. } } diff --git a/library/src/main/java/com/bumptech/glide/module/AppliesOptions.java b/library/src/main/java/com/bumptech/glide/module/AppliesOptions.java index 923d364f73..c92e0da64f 100644 --- a/library/src/main/java/com/bumptech/glide/module/AppliesOptions.java +++ b/library/src/main/java/com/bumptech/glide/module/AppliesOptions.java @@ -1,11 +1,13 @@ package com.bumptech.glide.module; import android.content.Context; +import android.support.annotation.NonNull; import com.bumptech.glide.GlideBuilder; /** * An internal interface, to be removed when {@link GlideModule}s are removed. */ +@Deprecated interface AppliesOptions { /** * Lazily apply options to a {@link com.bumptech.glide.GlideBuilder} immediately before the Glide @@ -16,5 +18,5 @@ interface AppliesOptions { * @param context An Application {@link android.content.Context}. * @param builder The {@link com.bumptech.glide.GlideBuilder} that will be used to create Glide. */ - void applyOptions(Context context, GlideBuilder builder); + void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder); } diff --git a/library/src/main/java/com/bumptech/glide/module/LibraryGlideModule.java b/library/src/main/java/com/bumptech/glide/module/LibraryGlideModule.java index 647945aec8..612dc8c135 100644 --- a/library/src/main/java/com/bumptech/glide/module/LibraryGlideModule.java +++ b/library/src/main/java/com/bumptech/glide/module/LibraryGlideModule.java @@ -16,6 +16,7 @@ * {@link com.bumptech.glide.annotation.Excludes} annotation to selectively remove one or more of * the conflicting modules. */ +@SuppressWarnings("deprecation") public abstract class LibraryGlideModule implements RegistersComponents { @Override public void registerComponents(@NonNull Context context, @NonNull Glide glide, diff --git a/library/src/main/java/com/bumptech/glide/module/ManifestParser.java b/library/src/main/java/com/bumptech/glide/module/ManifestParser.java index 92431dd206..6304f179a2 100644 --- a/library/src/main/java/com/bumptech/glide/module/ManifestParser.java +++ b/library/src/main/java/com/bumptech/glide/module/ManifestParser.java @@ -13,6 +13,7 @@ */ // Used only in javadoc. @SuppressWarnings("deprecation") +@Deprecated public final class ManifestParser { private static final String TAG = "ManifestParser"; private static final String GLIDE_MODULE_VALUE = "GlideModule"; diff --git a/library/src/main/java/com/bumptech/glide/module/RegistersComponents.java b/library/src/main/java/com/bumptech/glide/module/RegistersComponents.java index 46c9c1ce7a..9461ee341c 100644 --- a/library/src/main/java/com/bumptech/glide/module/RegistersComponents.java +++ b/library/src/main/java/com/bumptech/glide/module/RegistersComponents.java @@ -10,6 +10,7 @@ */ // Used only in javadocs. @SuppressWarnings("deprecation") +@Deprecated interface RegistersComponents { /** diff --git a/library/test/src/test/java/com/bumptech/glide/module/ManifestParserTest.java b/library/test/src/test/java/com/bumptech/glide/module/ManifestParserTest.java index dca2113e91..698425e220 100644 --- a/library/test/src/test/java/com/bumptech/glide/module/ManifestParserTest.java +++ b/library/test/src/test/java/com/bumptech/glide/module/ManifestParserTest.java @@ -9,6 +9,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; +import android.support.annotation.NonNull; import com.bumptech.glide.Glide; import com.bumptech.glide.GlideBuilder; import com.bumptech.glide.Registry; @@ -114,7 +115,7 @@ private static class InvalidClass { } public static class TestModule1 implements GlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { } @Override @@ -135,7 +136,7 @@ public int hashCode() { public static class TestModule2 implements GlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { } @Override diff --git a/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrGlideModule.java b/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrGlideModule.java index 83f7cc59dd..c0a1bce181 100644 --- a/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrGlideModule.java +++ b/samples/flickr/src/main/java/com/bumptech/glide/samples/flickr/FlickrGlideModule.java @@ -19,7 +19,7 @@ public class FlickrGlideModule extends AppGlideModule { @Override - public void applyOptions(Context context, GlideBuilder builder) { + public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) { super.applyOptions(context, builder); builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888)); }