Skip to content

Commit 5df1aa3

Browse files
authored
feat: Introduce @ObsoleteApi (#1887)
1 parent 65f73d7 commit 5df1aa3

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2023, Google Inc.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are
6+
* met:
7+
*
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above
11+
* copyright notice, this list of conditions and the following disclaimer
12+
* in the documentation and/or other materials provided with the
13+
* distribution.
14+
* * Neither the name of Google Inc. nor the names of its
15+
* contributors may be used to endorse or promote products derived from
16+
* this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
package com.google.api.core;
31+
32+
import java.lang.annotation.Documented;
33+
import java.lang.annotation.ElementType;
34+
import java.lang.annotation.Retention;
35+
import java.lang.annotation.RetentionPolicy;
36+
import java.lang.annotation.Target;
37+
38+
/**
39+
* Indicates a public API is obsolete, and will be deprecated in a future version.
40+
*
41+
* <p>Usage guidelines:
42+
*
43+
* <ol>
44+
* <li>This annotation must be used only on APIs with non-private visibility.
45+
* <li>This annotation should only be added if either an alternative API is provided and/or we
46+
* plan to stop supporting the API in a future version.
47+
* <li>This annotation must be used with a description.
48+
* <li>Alternative APIs must be referenced in Javadoc and/or description if possible.
49+
* </ol>
50+
*/
51+
@BetaApi
52+
@Retention(RetentionPolicy.RUNTIME)
53+
@Target({
54+
ElementType.ANNOTATION_TYPE,
55+
ElementType.CONSTRUCTOR,
56+
ElementType.FIELD,
57+
ElementType.METHOD,
58+
ElementType.PACKAGE,
59+
ElementType.TYPE
60+
})
61+
@Documented
62+
public @interface ObsoleteApi {
63+
/** Context information such as links to a discussion thread, tracking issue, etc. */
64+
String value();
65+
}

gax-java/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ additional qualifications:
109109
with this annotation, but methods can be added, thus breaking any
110110
code implementing the interface. See the javadocs for more details on other
111111
consequences of this annotation.
112+
1. Components marked with `@ObsoleteApi` are stable for usage in the current major version,
113+
but will be marked with `@Deprecated` in a future major version.
112114

113115
### Submodule notes
114116

0 commit comments

Comments
 (0)