1 Debian patch touch this file
-
Fix ivy dependencies.
- Author
- Bas Couwenberg <[email protected]>
- Bug
- https://josm.openstreetmap.de/ticket/24839
- Forwarded
- not-needed
| •1 | /* |
| 2 | * Copyright 2017 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.Retention; |
| 23 | import java.lang.annotation.Target; |
| 24 | import java.util.List; |
| 25 | |
| 26 | /** |
| 27 | * Indicates that the annotated method should not be called under any normal circumstances, yet is |
| 28 | * either <i>impossible</i> to remove, or <i>should not</i> ever be removed. Example: |
| 29 | * |
| 30 | * <pre>{@code |
| 31 | * public class ImmutableList<E> implements List<E> { |
| 32 | * @DoNotCall("guaranteed to throw an exception") |
| 33 | * @Override public add(E e) { |
| 34 | * throw new UnsupportedOperationException(); |
| 35 | * } |
| 36 | * } |
| 37 | * }</pre> |
| 38 | * |
| 39 | * By the demands of the {@code List} interface, this method can never be removed. However, since it |
| 40 | * should always throw an exception, there can be no valid reason to call it except in the rarest of |
| 41 | * circumstances. Although this information can only benefit users who have a reference of type |
| 42 | * {@code ImmutableList} (not {@link List}), it's a good start. |
| 43 | * |
| 44 | * <p>If the typical caller's best remedy is to "inline" the method, {@link InlineMe} is probably a |
| 45 | * better option; read there for more information. Using both annotations together is probably |
| 46 | * unnecessary. |
| 47 | * |
| 48 | * <p><b>Note on testing:</b> A {@code @DoNotCall} method should still have unit tests. |
| 49 | * |
| 50 | * <h2>{@code @DoNotCall} and deprecation</h2> |
| 51 | * |
| 52 | * <p>Deprecation may feel inappropriate or misleading in cases where there is no intention to ever |
| 53 | * remove the method. It might create the impression of a "blemish" on your API; something that |
| 54 | * should be fixed. Moreover, it's generally hard to enforce deprecation warnings as strongly as a |
| 55 | * {@code @DoNotCall} violation should be. |
| 56 | * |
| 57 | * <p>But, when choosing the {@code @DoNotCall} option, consider adding {@link Deprecated} as well |
| 58 | * anyway, so that any tools that don't support {@code @DoNotCall} can still do something reasonable |
| 59 | * to discourage usage. This practice does have some cost; for example, suppression would require |
| 60 | * {@code @SuppressWarnings({"DoNotCall", "deprecation"})}. |
| 61 | * |
| 62 | * <h2>Tool support</h2> |
| 63 | * |
| 64 | * Error Prone supports this annotation via its <a |
| 65 | * href="https://errorprone.info/bugpattern/DoNotCall">DoNotCall</a> pattern. |
| 66 | */ |
| 67 | @Retention(CLASS) |
| 68 | @Target(METHOD) |
| 69 | public @interface DoNotCall { |
| 70 | |
| 71 | /** An optional explanation of why the method should not be called. */ |
| 72 | String value() default ""; |
| 73 | } |