Skip to content

Commit

Permalink
Simplify object comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
darxriggs committed Feb 4, 2020
1 parent a39b9d0 commit 42a2234
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -612,7 +613,7 @@ public boolean equals(Object o) {

Details details = (Details) o;

if (apiUrl == null ? details.apiUrl != null : !apiUrl.equals(details.apiUrl)) {
if (!Objects.equals(apiUrl, details.apiUrl)) {
return false;
}
return StringUtils.equals(credentialsHash, details.credentialsHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.ObjectStreamException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
import java.util.logging.Logger;
import java.util.logging.Level;

Expand Down Expand Up @@ -116,7 +117,7 @@ public boolean equals(Object o) {

Endpoint endpoint = (Endpoint) o;

if (apiUri != null ? !apiUri.equals(endpoint.apiUri) : endpoint.apiUri != null) {
if (!Objects.equals(apiUri, endpoint.apiUri)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.TaskListener;
import java.util.Objects;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMSource;
import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider;
Expand Down Expand Up @@ -120,10 +121,10 @@ public boolean equals(Object o) {

GitHubNotificationContext that = (GitHubNotificationContext) o;

if (job != null ? !job.equals(that.job) : that.job != null) return false;
if (build != null ? !build.equals(that.build) : that.build != null) return false;
if (source != null ? !source.equals(that.source) : that.source != null) return false;
return head != null ? head.equals(that.head) : that.head == null;
if (!Objects.equals(job, that.job)) return false;
if (!Objects.equals(build, that.build)) return false;
if (!Objects.equals(source, that.source)) return false;
return Objects.equals(head, that.head);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.github_branch_source;

import java.util.Objects;
import org.kohsuke.github.GHCommitState;

/**
Expand Down Expand Up @@ -128,9 +129,9 @@ public boolean equals(Object o) {
GitHubNotificationRequest that = (GitHubNotificationRequest) o;

if (ignoreError != that.ignoreError) return false;
if (context != null ? !context.equals(that.context) : that.context != null) return false;
if (url != null ? !url.equals(that.url) : that.url != null) return false;
if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (!Objects.equals(context, that.context)) return false;
if (!Objects.equals(url, that.url)) return false;
if (!Objects.equals(message, that.message)) return false;
return state == that.state;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import hudson.model.Hudson;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.util.Objects;
import jenkins.scm.api.metadata.AvatarMetadataAction;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.github.GHUser;
Expand Down Expand Up @@ -117,8 +118,7 @@ public boolean equals(Object o) {

GitHubOrgMetadataAction that = (GitHubOrgMetadataAction) o;

return avatar != null ? avatar.equals(that.avatar) : that.avatar == null;

return Objects.equals(avatar, that.avatar);
}

/**
Expand Down

0 comments on commit 42a2234

Please sign in to comment.