GuardedBy


@Target(allowedTargets = [AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
@Retention(value = AnnotationRetention.BINARY)
public annotation GuardedBy


Denotes that the annotated method or field can only be accessed when holding the referenced lock.

Example:

final Object objectLock = new Object();

@GuardedBy("objectL
ock"
)volatile Obje

ct
object;Object get
Object
() { synchronized (obj
ectLock
) { if (object
== null) { object = new
Object()
;

} } retu
rn
object;}

Summary

Public constructors

Public methods

final @NonNull String

Public constructors

GuardedBy

Added in 1.10.0
public GuardedBy(@NonNull String value)

Public methods

getValue

public final @NonNull String getValue()