Debian Codegraph @

src/com/google/errorprone/annotations/ForOverride.java

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
•1 /*
2 * Copyright 2015 The Error Prone Authors.
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.google.errorprone.annotations;
18
19 import static java.lang.annotation.ElementType.METHOD;
20 import static java.lang.annotation.RetentionPolicy.CLASS;
21
22 import java.lang.annotation.Documented;
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.Target;
25
26 /**
27 * Indicates that the annotated method is provided only to be overridden: it should not be
28 * <i>invoked</i> from outside its declaring source file (as if it is {@code private}), and
29 * overriding methods should not be directly invoked at all. Such a method represents a contract
30 * between a class and its <i>subclasses</i> only, and is not to be considered part of the
31 * <i>caller</i>-facing API of either class.
32 *
33 * <p>The annotated method must have protected or package-private visibility, and must not be {@code
34 * static}, {@code final} or declared in a {@code final} class. Overriding methods must have either
35 * protected or package-private visibility, although their effective visibility is actually "none".
36 */
37 @Documented
38 @IncompatibleModifiers(
39 modifier = {Modifier.PUBLIC, Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL})
40 @Retention(CLASS) // Parent source might not be available while compiling subclass
41 @Target(METHOD)
42 public @interface ForOverride {}