Skip to content

Commit

Permalink
Add @checkresult to intermediate builder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob authored and sjudd committed Oct 5, 2017
1 parent 56a4275 commit 739cb35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,7 @@ public boolean apply(AnnotationSpec input) {
return !input.type.equals(TypeName.get(Override.class))
// SafeVarargs can only be applied to final methods. GlideRequest is
// non-final to allow for mocking.
&& !input.type.equals(TypeName.get(SafeVarargs.class))
// @CheckResult isn't applicable for RequestBuilder because there is no
// autoClone() in RequestBuilder.
&& !input.type.equals(CHECK_RESULT_CLASS_NAME);
&& !input.type.equals(TypeName.get(SafeVarargs.class));
}
})
.toList()
Expand Down
12 changes: 12 additions & 0 deletions library/src/main/java/com/bumptech/glide/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected RequestBuilder(Class<TranscodeType> transcodeClass, RequestBuilder<?>
* @see RequestOptions#apply(RequestOptions)
* @return This request builder.
*/
@CheckResult
public RequestBuilder<TranscodeType> apply(@NonNull RequestOptions requestOptions) {
Preconditions.checkNotNull(requestOptions);
this.requestOptions = getMutableOptions().apply(requestOptions);
Expand All @@ -105,6 +106,7 @@ protected RequestOptions getMutableOptions() {
*
* @return This request builder.
*/
@CheckResult
public RequestBuilder<TranscodeType> transition(
@NonNull TransitionOptions<?, ? super TranscodeType> transitionOptions) {
this.transitionOptions = Preconditions.checkNotNull(transitionOptions);
Expand All @@ -120,6 +122,7 @@ public RequestBuilder<TranscodeType> transition(
* @param requestListener The request listener to use.
* @return This request builder.
*/
@CheckResult
@SuppressWarnings("unchecked")
public RequestBuilder<TranscodeType> listener(
@Nullable RequestListener<TranscodeType> requestListener) {
Expand All @@ -141,6 +144,7 @@ public RequestBuilder<TranscodeType> listener(
*
* <p> Recursive calls to thumbnail are supported. </p>
*/
@CheckResult
@SuppressWarnings("unchecked")
public RequestBuilder<TranscodeType> thumbnail(
@Nullable RequestBuilder<TranscodeType> thumbnailRequest) {
Expand Down Expand Up @@ -173,6 +177,7 @@ public RequestBuilder<TranscodeType> thumbnail(
* the thumbnail.
* @return This request builder.
*/
@CheckResult
@SuppressWarnings("unchecked")
public RequestBuilder<TranscodeType> thumbnail(float sizeMultiplier) {
if (sizeMultiplier < 0f || sizeMultiplier > 1f) {
Expand All @@ -192,6 +197,7 @@ public RequestBuilder<TranscodeType> thumbnail(float sizeMultiplier) {
* @param model The model to load data for, or null.
* @return This request builder.
*/
@CheckResult
@SuppressWarnings("unchecked")
public RequestBuilder<TranscodeType> load(@Nullable Object model) {
return loadGeneric(model);
Expand Down Expand Up @@ -222,6 +228,7 @@ private RequestBuilder<TranscodeType> loadGeneric(@Nullable Object model) {
* @param string A file path, or a uri or url handled by
* {@link com.bumptech.glide.load.model.UriLoader}.
*/
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable String string) {
return loadGeneric(string);
}
Expand All @@ -244,6 +251,7 @@ public RequestBuilder<TranscodeType> load(@Nullable String string) {
* @param uri The Uri representing the image. Must be of a type handled by
* {@link com.bumptech.glide.load.model.UriLoader}.
*/
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable Uri uri) {
return loadGeneric(uri);
}
Expand All @@ -266,6 +274,7 @@ public RequestBuilder<TranscodeType> load(@Nullable Uri uri) {
*
* @param file The File containing the image
*/
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable File file) {
return loadGeneric(file);
}
Expand All @@ -289,6 +298,7 @@ public RequestBuilder<TranscodeType> load(@Nullable File file) {
* @see #load(Integer)
* @see com.bumptech.glide.signature.ApplicationVersionSignature
*/
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable Integer resourceId) {
return loadGeneric(resourceId).apply(signatureOf(ApplicationVersionSignature.obtain(context)));
}
Expand All @@ -303,6 +313,7 @@ public RequestBuilder<TranscodeType> load(@Nullable Integer resourceId) {
* {@link #load(android.net.Uri)} or {@link #load(String)}.
*/
@Deprecated
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable URL url) {
return loadGeneric(url);
}
Expand All @@ -316,6 +327,7 @@ public RequestBuilder<TranscodeType> load(@Nullable URL url) {
* @param model the data to load.
* @see #load(Object)
*/
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable byte[] model) {
return loadGeneric(model).apply(signatureOf(new ObjectKey(UUID.randomUUID().toString()))
.diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true /*skipMemoryCache*/));
Expand Down

1 comment on commit 739cb35

@paulsowden
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has RequestBuilder API changed since this change? All methods are marked @CheckResult but they return selfOrThrowIfLocked() which returns self() which returns this, so these annotations seem incorrect, the results can safely be ignored?

Please sign in to comment.