1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.internal.annotations;
18 
19 import static java.lang.annotation.ElementType.FIELD;
20 import static java.lang.annotation.ElementType.METHOD;
21 
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 import java.lang.annotation.Target;
25 
26 /**
27  * Annotation type used to mark a method or field that can only be accessed when
28  * holding the referenced locks.
29  */
30 @Target({FIELD, METHOD})
31 @Retention(RetentionPolicy.CLASS)
32 public @interface GuardedBy {
33     /**
34      * Specifies a list of locks to be held in order to access the field/method
35      * annotated with this; when used in conjunction with the {@link CompositeRWLock}, locks
36      * should be acquired in the order of the appearance in the {@link #value} here.
37      *
38      * <p>
39      * If specified, {@link #anyOf()} must be null.
40      * </p>
41      *
42      * @see CompositeRWLock
43      */
value()44     String[] value() default {};
45 
46     /**
47      * Specifies a list of locks where at least one of them must be held in order to access
48      * the field/method annotated with this; it should be <em>only</em> used in the conjunction
49      * with the {@link CompositeRWLock}.
50      *
51      * <p>
52      * If specified, {@link #allOf()} must be null.
53      * </p>
54      *
55      * @see CompositeRWLock
56      */
anyOf()57     String[] anyOf() default {};
58 }
59