Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make root field transient in all classes #1004

Merged
merged 6 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/org/kohsuke/github/AbstractBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
* the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}.
*/
abstract class AbstractBuilder<R, S> {
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject {

@Nonnull
private final Class<R> returnType;
Expand Down Expand Up @@ -75,6 +75,7 @@ protected AbstractBuilder(@Nonnull Class<R> finalReturnType,
@Nonnull Class<S> intermediateReturnType,
@Nonnull GitHub root,
@CheckForNull R baseInstance) {
super(root);
this.requester = root.createRequest();
this.returnType = finalReturnType;
this.commitChangesImmediately = returnType.equals(intermediateReturnType);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
public class GHApp extends GHObject {

private GitHub root;
private GHUser owner;
private String name;
private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
* @see GHAppInstallation#createToken() GHAppInstallation#createToken()
*/
public class GHAppCreateTokenBuilder {
private final GitHub root;
public class GHAppCreateTokenBuilder extends GitHubInteractiveObject {
protected final Requester builder;
private final String apiUrlTail;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHAppInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @see GHApp#getInstallationByUser(String) GHApp#getInstallationByUser(String)
*/
public class GHAppInstallation extends GHObject {
private GitHub root;
private GHUser account;

@JsonProperty("access_tokens_url")
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHAppInstallationToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* @author Paulo Miguel Almeida
* @see GHAppInstallation#createToken(Map) GHAppInstallation#createToken(Map)
*/
public class GHAppInstallationToken {
private GitHub root;

public class GHAppInstallationToken extends GitHubInteractiveObject {
private String token;
protected String expires_at;
private Map<String, String> permissions;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @see GHRelease#getAssets() GHRelease#getAssets()
*/
public class GHAsset extends GHObject {
GitHub root;
GHRepository owner;
private String name;
private String label;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class GHAuthorization extends GHObject {
public static final String WRITE_KEY = "write:public_key";
public static final String ADMIN_KEY = "admin:public_key";

private GitHub root;
private List<String> scopes;
private String token;
private String token_last_eight;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/kohsuke/github/GHBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranch {
private GitHub root;
public class GHBranch extends GitHubInteractiveObject {
private GHRepository owner;

private String name;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHBranchProtection.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD",
"URF_UNREAD_FIELD" },
justification = "JSON API")
public class GHBranchProtection {
public class GHBranchProtection extends GitHubInteractiveObject {
private static final String REQUIRE_SIGNATURES_URI = "/required_signatures";

@JsonProperty
private EnforceAdmins enforceAdmins;

private GitHub root;

@JsonProperty("required_pull_request_reviews")
private RequiredReviews requiredReviews;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHCheckRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class GHCheckRun extends GHObject {

@JsonProperty("repository")
GHRepository owner;
GitHub root;

private String status;
private String conclusion;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHCheckRunsIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Iterable for check-runs listing.
*/
class GHCheckRunsIterable extends PagedIterable<GHCheckRun> {
private GitHub root;
private final transient GitHub root;
private final GitHubRequest request;

private GHCheckRunsPage result;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHCheckSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class GHCheckSuite extends GHObject {

@JsonProperty("repository")
GHRepository owner;
GitHub root;

private String nodeId;
private String headBranch;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/kohsuke/github/GHCommitStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class GHCommitStatus extends GHObject {
String context;
GHUser creator;

private GitHub root;

GHCommitStatus wrapUp(GitHub root) {
if (creator != null)
creator.wrapUp(root);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
* @see GHRepository#getFileContent(String) GHRepository#getFileContent(String)
*/
@SuppressWarnings({ "UnusedDeclaration" })
public class GHContent implements Refreshable {
public class GHContent extends GitHubInteractiveObject implements Refreshable {
/*
* In normal use of this class, repository field is set via wrap(), but in the code search API, there's a nested
* 'repository' field that gets populated from JSON.
*/
private GHRepository repository;

private GitHub root;

private String type;
private String encoding;
private long size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*
* @author Kohsuke Kawaguchi
*/
public class GHCreateRepositoryBuilder {
private final GitHub root;
public class GHCreateRepositoryBuilder extends GitHubInteractiveObject {
protected final Requester builder;
private String apiUrlTail;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHDeployment.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
public class GHDeployment extends GHObject {
private GHRepository owner;
private GitHub root;
protected String sha;
protected String ref;
protected String task;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHDeploymentStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
public class GHDeploymentStatus extends GHObject {
private GHRepository owner;
private GitHub root;
protected GHUser creator;
protected String state;
protected String description;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/kohsuke/github/GHDiscussion.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.kohsuke.github;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.IOException;
Expand All @@ -18,8 +17,6 @@
*/
public class GHDiscussion extends GHObject {

@JacksonInject
private GitHub root;
private GHTeam team;
private long number;
private String body, title, htmlUrl;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHEventInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHEventInfo {
private GitHub root;

public class GHEventInfo extends GitHubInteractiveObject {
// we don't want to expose Jackson dependency to the user. This needs databinding
private ObjectNode payload;

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHEventPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
*/
@SuppressWarnings("UnusedDeclaration")
@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public class GHEventPayload {
protected GitHub root;

public class GHEventPayload extends GitHubInteractiveObject {
// https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-object-common-properties
// Webhook payload object common properties: action, sender, repository, organization, installation
private String action;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHGist.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
public class GHGist extends GHObject {

final GHUser owner;
final GitHub root;

private String forks_url, commits_url, id, git_pull_url, git_push_url, html_url;

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/kohsuke/github/GHGistBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @see GitHub#createGist() GitHub#createGist()
*/
public class GHGistBuilder {
private final GitHub root;
private final Requester req;
private final LinkedHashMap<String, Object> files = new LinkedHashMap<String, Object>();

Expand All @@ -24,7 +23,6 @@ public class GHGistBuilder {
* the root
*/
public GHGistBuilder(GitHub root) {
this.root = root;
req = root.createRequest().method("POST");
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/kohsuke/github/GHHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
* functionality
*/
class GHHooks {
static abstract class Context {
private final GitHub root;
static abstract class Context extends GitHubInteractiveObject {

private Context(GitHub root) {
this.root = root;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHInvitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"UUF_UNUSED_FIELD" },
justification = "JSON API")
public class GHInvitation extends GHObject {
/* package almost final */ GitHub root;

private int id;
private GHRepository repository;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
public class GHIssue extends GHObject implements Reactable {
private static final String ASSIGNEES = "assignees";

GitHub root;
GHRepository owner;

// API v3
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHIssueEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
*
* @author Martin van Zijl
*/
public class GHIssueEvent {
private GitHub root;

public class GHIssueEvent extends GitHubInteractiveObject {
private long id;
private String node_id;
private String url;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
* @author Kohsuke Kawaguchi
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON API")
public class GHKey {
/* package almost final */ GitHub root;

public class GHKey extends GitHubInteractiveObject {
protected String url, key, title;
protected boolean verified;
protected int id;
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/kohsuke/github/GHLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
* @see GHIssue#getLabels() GHIssue#getLabels()
* @see GHRepository#listLabels() GHRepository#listLabels()
*/
public class GHLabel {
public class GHLabel extends GitHubInteractiveObject {

@Nonnull
private String url, name, color;

@CheckForNull
private String description;

@Nonnull
private final GitHub root;

@JsonCreator
private GHLabel(@JacksonInject @Nonnull GitHub root) {
this.root = root;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/kohsuke/github/GHLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHLicense extends GHObject {
@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
// root is set before the object is returned to the app
/* package almost final */ GitHub root;

// these fields are always present, even in the short form
protected String key, name;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHMarketplaceAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
* @see GitHub#getMyMarketplacePurchases()
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplaceAccount {

protected GitHub root;
public class GHMarketplaceAccount extends GitHubInteractiveObject {
private String url;
private long id;
private String login;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* @author Paulo Miguel Almeida
* @see GHMarketplacePlan#listAccounts()
*/
public class GHMarketplaceListAccountBuilder {
private final GitHub root;
public class GHMarketplaceListAccountBuilder extends GitHubInteractiveObject {
private final Requester builder;
private final long planId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePendingChange {
private GitHub root;
public class GHMarketplacePendingChange extends GitHubInteractiveObject {
private long id;
@SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "Field comes from JSON deserialization")
private Long unitCount;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHMarketplacePlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
* @author Paulo Miguel Almeida
* @see GitHub#listMarketplacePlans()
*/
public class GHMarketplacePlan {

private GitHub root;
public class GHMarketplacePlan extends GitHubInteractiveObject {
private String url;
private String accountsUrl;
private long id;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/kohsuke/github/GHMarketplacePurchase.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
* @author Paulo Miguel Almeida
* @see GHMarketplaceListAccountBuilder#createRequest() GHMarketplaceListAccountBuilder#createRequest()
*/
public class GHMarketplacePurchase {
public class GHMarketplacePurchase extends GitHubInteractiveObject {

private GitHub root;
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* @author Paulo Miguel Almeida
* @see GitHub#getMyMarketplacePurchases()
*/
public class GHMarketplaceUserPurchase {
protected GitHub root;
public class GHMarketplaceUserPurchase extends GitHubInteractiveObject {
private String billingCycle;
private String nextBillingDate;
private boolean onFreeTrial;
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/kohsuke/github/GHMembership.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
* @author Kohsuke Kawaguchi
* @see GHMyself#listOrgMemberships() GHMyself#listOrgMemberships()
*/
public class GHMembership /* extends GHObject --- but it doesn't have id, created_at, etc. */ {
GitHub root;

public class GHMembership extends GitHubInteractiveObject {
String url;
String state;
String role;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kohsuke/github/GHMilestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @author Yusuke Kokubo
*/
public class GHMilestone extends GHObject {
GitHub root;
GHRepository owner;

GHUser creator;
Expand Down
Loading