Skip to content

Commit 362faaf

Browse files
authored
Sort members for consistency (#2087)
* Sort members * Sort by visibility * Sort fields
1 parent e0ea180 commit 362faaf

File tree

278 files changed

+29143
-29149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+29143
-29149
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,20 @@
484484
</includes>
485485

486486
<eclipse>
487+
<version>4.35</version>
487488
<file>${basedir}/src/build/eclipse/formatter.xml</file>
489+
<sortMembersEnabled>true</sortMembersEnabled>
490+
<sortMembersVisibilityOrderEnabled>true</sortMembersVisibilityOrderEnabled>
491+
<sortMembersDoNotSortFields>false</sortMembersDoNotSortFields>
488492
</eclipse>
489493

490494
<importOrder>
491495
<file>${basedir}/src/build/eclipse/eclipse.importorder</file>
492496
</importOrder>
497+
493498
<removeUnusedImports></removeUnusedImports>
494-
499+
<formatAnnotations />
500+
495501
<trimTrailingWhitespace></trimTrailingWhitespace>
496502
<endWithNewline></endWithNewline>
497503

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
*/
4444
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject implements GitHubRequestBuilderDone<R> {
4545

46-
@Nonnull
47-
private final Class<R> returnType;
46+
@CheckForNull
47+
private final R baseInstance;
4848

4949
private final boolean commitChangesImmediately;
5050

51-
@CheckForNull
52-
private final R baseInstance;
51+
@Nonnull
52+
private final Class<R> returnType;
5353

5454
/** The requester. */
5555
@Nonnull
@@ -111,54 +111,54 @@ public R done() throws IOException {
111111
}
112112

113113
/**
114-
* Applies a value to a name for this builder.
114+
* Chooses whether to return a continuing builder or an updated data record
115115
*
116116
* If {@code S} is the same as {@code R}, this method will commit changes after the first value change and return a
117117
* {@code R} from {@link #done()}.
118118
*
119119
* If {@code S} is not the same as {@code R}, this method will return an {@code S} and letting the caller batch
120120
* together multiple changes and call {@link #done()} when they are ready.
121121
*
122-
* @param name
123-
* the name of the field
124-
* @param value
125-
* the value of the field
126122
* @return either a continuing builder or an updated data record
127123
* @throws IOException
128124
* if an I/O error occurs
129125
*/
130126
@Nonnull
131127
@BetaApi
132-
protected S with(@Nonnull String name, Object value) throws IOException {
133-
requester.with(name, value);
134-
return continueOrDone();
128+
protected S continueOrDone() throws IOException {
129+
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
130+
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
131+
// well.
132+
if (commitChangesImmediately) {
133+
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
134+
// being based on the previous comparison of class instances passed to the constructor.
135+
return (S) done();
136+
} else {
137+
return (S) this;
138+
}
135139
}
136140

137141
/**
138-
* Chooses whether to return a continuing builder or an updated data record
142+
* Applies a value to a name for this builder.
139143
*
140144
* If {@code S} is the same as {@code R}, this method will commit changes after the first value change and return a
141145
* {@code R} from {@link #done()}.
142146
*
143147
* If {@code S} is not the same as {@code R}, this method will return an {@code S} and letting the caller batch
144148
* together multiple changes and call {@link #done()} when they are ready.
145149
*
150+
* @param name
151+
* the name of the field
152+
* @param value
153+
* the value of the field
146154
* @return either a continuing builder or an updated data record
147155
* @throws IOException
148156
* if an I/O error occurs
149157
*/
150158
@Nonnull
151159
@BetaApi
152-
protected S continueOrDone() throws IOException {
153-
// This little bit of roughness in this base class means all inheriting builders get to create Updater and
154-
// Setter classes from almost identical code. Creator can often be implemented with significant code reuse as
155-
// well.
156-
if (commitChangesImmediately) {
157-
// These casts look strange and risky, but they they're actually guaranteed safe due to the return path
158-
// being based on the previous comparison of class instances passed to the constructor.
159-
return (S) done();
160-
} else {
161-
return (S) this;
162-
}
160+
protected S with(@Nonnull String name, Object value) throws IOException {
161+
requester.with(name, value);
162+
return continueOrDone();
163163
}
164164
}

src/main/java/org/kohsuke/github/EnterpriseManagedSupport.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,38 @@
1414
*/
1515
class EnterpriseManagedSupport {
1616

17+
private static final Logger LOGGER = Logger.getLogger(EnterpriseManagedSupport.class.getName());
1718
static final String COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS = "Could not retrieve organization external groups";
1819
static final String NOT_PART_OF_EXTERNALLY_MANAGED_ENTERPRISE_ERROR = "This organization is not part of externally managed enterprise.";
20+
1921
static final String TEAM_CANNOT_BE_EXTERNALLY_MANAGED_ERROR = "This team cannot be externally managed since it has explicit members.";
2022

21-
private static final Logger LOGGER = Logger.getLogger(EnterpriseManagedSupport.class.getName());
23+
private static String logUnexpectedFailure(final JsonProcessingException exception, final String payload) {
24+
final StringWriter sw = new StringWriter();
25+
final PrintWriter pw = new PrintWriter(sw);
26+
exception.printStackTrace(pw);
27+
return String.format("Could not parse GitHub error response: '%s'. Full stacktrace follows:%n%s", payload, sw);
28+
}
29+
30+
static EnterpriseManagedSupport forOrganization(final GHOrganization org) {
31+
return new EnterpriseManagedSupport(org);
32+
}
2233

2334
private final GHOrganization organization;
2435

2536
private EnterpriseManagedSupport(GHOrganization organization) {
2637
this.organization = organization;
2738
}
2839

40+
Optional<GHException> filterException(final GHException e) {
41+
if (e.getCause() instanceof HttpException) {
42+
final HttpException he = (HttpException) e.getCause();
43+
return filterException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
44+
.map(translated -> new GHException(COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS, translated));
45+
}
46+
return Optional.empty();
47+
}
48+
2949
Optional<GHIOException> filterException(final HttpException he, final String scenario) {
3050
if (he.getResponseCode() == 400) {
3151
final String responseMessage = he.getMessage();
@@ -46,24 +66,4 @@ Optional<GHIOException> filterException(final HttpException he, final String sce
4666
return Optional.empty();
4767
}
4868

49-
Optional<GHException> filterException(final GHException e) {
50-
if (e.getCause() instanceof HttpException) {
51-
final HttpException he = (HttpException) e.getCause();
52-
return filterException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
53-
.map(translated -> new GHException(COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS, translated));
54-
}
55-
return Optional.empty();
56-
}
57-
58-
static EnterpriseManagedSupport forOrganization(final GHOrganization org) {
59-
return new EnterpriseManagedSupport(org);
60-
}
61-
62-
private static String logUnexpectedFailure(final JsonProcessingException exception, final String payload) {
63-
final StringWriter sw = new StringWriter();
64-
final PrintWriter pw = new PrintWriter(sw);
65-
exception.printStackTrace(pw);
66-
return String.format("Could not parse GitHub error response: '%s'. Full stacktrace follows:%n%s", payload, sw);
67-
}
68-
6969
}

0 commit comments

Comments
 (0)