Top Description Methods
org.checkerframework.common.returnsreceiver.qual

public @Interface This

extends Annotation
Annotations
@Retention:RUNTIME
@Target:TYPE_USE, TYPE_PARAMETER
@PolymorphicQualifier
@TargetLocations:RECEIVER, RETURN
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, org.checkerframework.framework.qual.PolymorphicQualifier, .TargetLocations, .TypeUseLocation

Write @This on the return type of a method that always returns its receiver (this). For example:

class MyBuilder {
  @This MyBuilder setName(String name) {
    this.name = name;
    return this;
  }
}

Strictly speaking, this is a polymorphic annotation, but when you write it on a return type, the Returns Receiver Checker automatically adds it to the receiver, so the above method is equivalent to:


@This MyBuilder setName(@This MyBuilder this, String name) {
  this.name = name;
  return this;
}

While it would be natural to make @This the default annotation for receivers, it leads to false positives warnings due to https://github.com/typetools/checker-framework/issues/2931, so this defaulting is currently elided.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString