001/*
002 * Copyright 2015 The Error Prone Authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.errorprone.annotations;
018
019import static java.lang.annotation.ElementType.METHOD;
020import static java.lang.annotation.RetentionPolicy.SOURCE;
021import static javax.lang.model.element.Modifier.FINAL;
022import static javax.lang.model.element.Modifier.PRIVATE;
023import static javax.lang.model.element.Modifier.PUBLIC;
024import static javax.lang.model.element.Modifier.STATIC;
025
026import java.lang.annotation.Documented;
027import java.lang.annotation.Retention;
028import java.lang.annotation.Target;
029
030/**
031 * Indicates that the annotated method is provided only to be overridden: it should not be
032 * <i>invoked</i> from outside its declaring source file (as if it is {@code private}), and
033 * overriding methods should not be directly invoked at all. Such a method represents a contract
034 * between a class and its <i>subclasses</i> only, and is not to be considered part of the
035 * <i>caller</i>-facing API of either class.
036 *
037 * <p>The annotated method must have protected or package-private visibility, and must not be {@code
038 * static}, {@code final} or declared in a {@code final} class. Overriding methods must have either
039 * protected or package-private visibility, although their effective visibility is actually "none".
040 */
041@Documented
042@Retention(SOURCE) // Parent source might not be available while compiling subclass
043@Target(METHOD)
044public @interface ForOverride {}