All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.org.checkerframework.common.returnsreceiver.qual.This Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
package com.hazelcast.org.checkerframework.common.returnsreceiver.qual;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.hazelcast.org.checkerframework.framework.qual.PolymorphicQualifier;
import com.hazelcast.org.checkerframework.framework.qual.TargetLocations;
import com.hazelcast.org.checkerframework.framework.qual.TypeUseLocation;

/**
 * Write {@code @This} on the return type of a method that always returns its receiver ({@code
 * 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 {@code @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. * * @checker_framework.manual #returns-receiver-checker Returns Receiver Checker * @checker_framework.manual #qualifier-polymorphism Qualifier polymorphism */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @PolymorphicQualifier @TargetLocations({TypeUseLocation.RECEIVER, TypeUseLocation.RETURN}) public @interface This {}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy