Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e7ac70

Browse filesBrowse files
committed
Add beta api annotation to project
1 parent e3e495b commit 4e7ac70
Copy full SHA for 4e7ac70

File tree

Expand file treeCollapse file tree

13 files changed

+90
-25
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+90
-25
lines changed

‎src/main/java/org/kohsuke/github/AbstractBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/AbstractBuilder.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
9797
* if there is an I/O Exception
9898
*/
9999
@Nonnull
100-
@Preview
100+
@BetaApi
101101
@Deprecated
102102
public R done() throws IOException {
103103
R result;
@@ -127,7 +127,7 @@ public R done() throws IOException {
127127
* if an I/O error occurs
128128
*/
129129
@Nonnull
130-
@Preview
130+
@BetaApi
131131
@Deprecated
132132
protected S with(@Nonnull String name, Object value) throws IOException {
133133
requester.with(name, value);
@@ -148,7 +148,7 @@ protected S with(@Nonnull String name, Object value) throws IOException {
148148
* if an I/O error occurs
149149
*/
150150
@Nonnull
151-
@Preview
151+
@BetaApi
152152
@Deprecated
153153
protected S continueOrDone() throws IOException {
154154
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.kohsuke.github;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
7+
/**
8+
* Indicates that the method/class/etc marked is a beta implementation of an sdk feature.
9+
* <p>
10+
* These APIs are subject to change and not a part of the backward compatibility commitment. Always used in conjunction
11+
* with 'deprecated' to raise awareness to clients.
12+
* </p>
13+
*
14+
*/
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Documented
17+
public @interface BetaApi {
18+
}

‎src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppCreateTokenBuilder.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ public class GHAppCreateTokenBuilder {
1919
protected final Requester builder;
2020
private final String apiUrlTail;
2121

22-
@Preview
22+
@BetaApi
2323
@Deprecated
2424
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail) {
2525
this.root = root;
2626
this.apiUrlTail = apiUrlTail;
2727
this.builder = root.createRequest();
2828
}
2929

30-
@Preview
30+
@BetaApi
3131
@Deprecated
3232
GHAppCreateTokenBuilder(GitHub root, String apiUrlTail, Map<String, GHPermissionType> permissions) {
3333
this(root, apiUrlTail);
@@ -43,7 +43,7 @@ public class GHAppCreateTokenBuilder {
4343
* Array containing the repositories Ids
4444
* @return a GHAppCreateTokenBuilder
4545
*/
46-
@Preview
46+
@BetaApi
4747
@Deprecated
4848
public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
4949
this.builder.with("repository_ids", repositoryIds);
@@ -58,7 +58,7 @@ public GHAppCreateTokenBuilder repositoryIds(List<Long> repositoryIds) {
5858
* Map containing the permission names and types.
5959
* @return a GHAppCreateTokenBuilder
6060
*/
61-
@Preview
61+
@BetaApi
6262
@Deprecated
6363
public GHAppCreateTokenBuilder permissions(Map<String, GHPermissionType> permissions) {
6464
Map<String, String> retMap = new HashMap<>();

‎src/main/java/org/kohsuke/github/GHAppInstallation.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppInstallation.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public void deleteInstallation() throws IOException {
344344
* @return a GHAppCreateTokenBuilder instance
345345
* @deprecated Use {@link GHAppInstallation#createToken()} instead.
346346
*/
347-
@Preview
347+
@BetaApi
348348
@Deprecated
349349
public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permissions) {
350350
return new GHAppCreateTokenBuilder(root,
@@ -361,7 +361,7 @@ public GHAppCreateTokenBuilder createToken(Map<String, GHPermissionType> permiss
361361
*
362362
* @return a GHAppCreateTokenBuilder instance
363363
*/
364-
@Preview
364+
@BetaApi
365365
@Deprecated
366366
public GHAppCreateTokenBuilder createToken() {
367367
return new GHAppCreateTokenBuilder(root, String.format("/app/installations/%d/access_tokens", getId()));

‎src/main/java/org/kohsuke/github/GHBranch.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHBranch.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public String getName() {
7878
*
7979
* @return true if the push to this branch is restricted via branch protection.
8080
*/
81-
@Preview
81+
@Preview(Previews.LUKE_CAGE)
8282
@Deprecated
8383
public boolean isProtected() {
8484
return protection;

‎src/main/java/org/kohsuke/github/GHCommitComment.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCommitComment.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void update(String body) throws IOException {
121121
this.body = body;
122122
}
123123

124-
@Preview
124+
@Preview(SQUIRREL_GIRL)
125125
@Deprecated
126126
public GHReaction createReaction(ReactionContent content) throws IOException {
127127
return owner.root.createRequest()

‎src/main/java/org/kohsuke/github/GHLabel.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHLabel.java
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static Collection<String> toNames(Collection<GHLabel> labels) {
132132
* @throws IOException
133133
* the io exception
134134
*/
135-
@Preview
135+
@BetaApi
136136
@Deprecated
137137
static Creator create(GHRepository repository) throws IOException {
138138
return new Creator(repository);
@@ -179,7 +179,7 @@ static PagedIterable<GHLabel> readAll(@Nonnull final GHRepository repository) th
179179
*
180180
* @return a {@link Updater}
181181
*/
182-
@Preview
182+
@BetaApi
183183
@Deprecated
184184
public Updater update() {
185185
return new Updater(this);
@@ -190,7 +190,7 @@ public Updater update() {
190190
*
191191
* @return a {@link Setter}
192192
*/
193-
@Preview
193+
@BetaApi
194194
@Deprecated
195195
public Setter set() {
196196
return new Setter(this);
@@ -227,7 +227,7 @@ public int hashCode() {
227227
*
228228
* {@link #done()} is called automatically after the property is set.
229229
*/
230-
@Preview
230+
@BetaApi
231231
@Deprecated
232232
public static class Setter extends GHLabelBuilder<GHLabel> {
233233
private Setter(@Nonnull GHLabel base) {
@@ -241,7 +241,7 @@ private Setter(@Nonnull GHLabel base) {
241241
*
242242
* Consumer must call {@link #done()} to commit changes.
243243
*/
244-
@Preview
244+
@BetaApi
245245
@Deprecated
246246
public static class Updater extends GHLabelBuilder<Updater> {
247247
private Updater(@Nonnull GHLabel base) {
@@ -255,7 +255,7 @@ private Updater(@Nonnull GHLabel base) {
255255
*
256256
* Consumer must call {@link #done()} to create the new instance.
257257
*/
258-
@Preview
258+
@BetaApi
259259
@Deprecated
260260
public static class Creator extends GHLabelBuilder<Creator> {
261261
private Creator(@Nonnull GHRepository repository) {

‎src/main/java/org/kohsuke/github/GHLabelBuilder.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHLabelBuilder.java
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ protected GHLabelBuilder(@Nonnull Class<S> intermediateReturnType,
3838
}
3939

4040
@Nonnull
41-
@Preview
41+
@BetaApi
4242
@Deprecated
4343
public S name(String value) throws IOException {
4444
return with("name", value);
4545
}
4646

4747
@Nonnull
48-
@Preview
48+
@BetaApi
4949
@Deprecated
5050
public S color(String value) throws IOException {
5151
return with("color", value);
5252
}
5353

5454
@Nonnull
55-
@Preview
55+
@BetaApi
5656
@Deprecated
5757
public S description(String value) throws IOException {
5858
return with("description", value);

‎src/main/java/org/kohsuke/github/GHRelease.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRelease.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public GHAsset uploadAsset(String filename, InputStream stream, String contentTy
260260
* existing logic in place for backwards compatibility.
261261
*/
262262
@Deprecated
263-
@Preview
264263
public List<GHAsset> assets() {
265264
return assets;
266265
}

‎src/main/java/org/kohsuke/github/GHRepositoryStatistics.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepositoryStatistics.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public PagedIterable<ContributorStats> getContributorStats() throws IOException,
6060
* @throws InterruptedException
6161
* the interrupted exception
6262
*/
63-
@Preview
63+
@BetaApi
6464
@Deprecated
6565
@SuppressWarnings("SleepWhileInLoop")
6666
@SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" }, justification = "JSON API")

‎src/main/java/org/kohsuke/github/GitUser.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitUser.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public String getEmail() {
4242
*
4343
* @return GitHub username
4444
*/
45-
@Preview
46-
@Deprecated
4745
@CheckForNull
4846
public String getUsername() {
4947
return username;

‎src/main/java/org/kohsuke/github/Preview.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/Preview.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
*
2626
* @return The API preview media type.
2727
*/
28-
public Previews[] value() default {};
28+
public Previews[] value();
2929

3030
}

‎src/test/java/org/kohsuke/github/ArchTests.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/ArchTests.java
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package org.kohsuke.github;
22

3+
import com.tngtech.archunit.base.DescribedPredicate;
4+
import com.tngtech.archunit.core.domain.JavaAnnotation;
35
import com.tngtech.archunit.core.domain.JavaClasses;
46
import com.tngtech.archunit.core.importer.ClassFileImporter;
57
import com.tngtech.archunit.core.importer.ImportOption;
68
import com.tngtech.archunit.lang.ArchRule;
79
import org.junit.BeforeClass;
810
import org.junit.Test;
911

12+
import static com.tngtech.archunit.lang.conditions.ArchConditions.beAnnotatedWith;
13+
import static com.tngtech.archunit.lang.conditions.ArchConditions.not;
1014
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
1115
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields;
1216
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods;
@@ -19,6 +23,17 @@ public class ArchTests {
1923
.withImportOption(new ImportOption.DoNotIncludeJars())
2024
.importPackages("org.kohsuke.github");
2125

26+
private static final DescribedPredicate<JavaAnnotation<?>> previewAnnotationWithNoMediaType = new DescribedPredicate<JavaAnnotation<?>>(
27+
"preview has no required media types defined") {
28+
29+
@Override
30+
public boolean apply(JavaAnnotation<?> javaAnnotation) {
31+
boolean isPreview = javaAnnotation.getRawType().isEquivalentTo(Preview.class);
32+
Object[] values = (Object[]) javaAnnotation.getProperties().get("value");
33+
return isPreview && values != null && values.length < 1;
34+
}
35+
};
36+
2237
@BeforeClass
2338
public static void beforeClass() {
2439
assertTrue(classFiles.size() > 0);
@@ -33,12 +48,14 @@ public void testPreviewsAreFlaggedAsDeprecated() {
3348
.areAnnotatedWith(Preview.class)
3449
.should()
3550
.beAnnotatedWith(Deprecated.class)
51+
.andShould(not(beAnnotatedWith(previewAnnotationWithNoMediaType)))
3652
.because(reason);
3753

3854
ArchRule methodRule = methods().that()
3955
.areAnnotatedWith(Preview.class)
4056
.should()
4157
.beAnnotatedWith(Deprecated.class)
58+
.andShould(not(beAnnotatedWith(previewAnnotationWithNoMediaType)))
4259
.because(reason);
4360

4461
ArchRule enumFieldsRule = fields().that()
@@ -48,6 +65,39 @@ public void testPreviewsAreFlaggedAsDeprecated() {
4865
.areAnnotatedWith(Preview.class)
4966
.should()
5067
.beAnnotatedWith(Deprecated.class)
68+
.andShould(not(beAnnotatedWith(previewAnnotationWithNoMediaType)))
69+
.because(reason);
70+
71+
classRule.check(classFiles);
72+
enumFieldsRule.check(classFiles);
73+
methodRule.check(classFiles);
74+
75+
}
76+
77+
@Test
78+
public void testBetaApisAreFlaggedAsDeprecated() {
79+
80+
String reason = "all beta APIs must be annotated as @Deprecated until they are promoted to stable";
81+
82+
ArchRule classRule = classes().that()
83+
.areAnnotatedWith(BetaApi.class)
84+
.should()
85+
.beAnnotatedWith(Deprecated.class)
86+
.because(reason);
87+
88+
ArchRule methodRule = methods().that()
89+
.areAnnotatedWith(BetaApi.class)
90+
.should()
91+
.beAnnotatedWith(Deprecated.class)
92+
.because(reason);
93+
94+
ArchRule enumFieldsRule = fields().that()
95+
.areDeclaredInClassesThat()
96+
.areEnums()
97+
.and()
98+
.areAnnotatedWith(BetaApi.class)
99+
.should()
100+
.beAnnotatedWith(Deprecated.class)
51101
.because(reason);
52102

53103
classRule.check(classFiles);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.