Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-43507] More javadoc documentation (and more compliance too)
  • Loading branch information
stephenc committed Jun 12, 2017
1 parent c5c4116 commit 72cab2a
Show file tree
Hide file tree
Showing 32 changed files with 978 additions and 28 deletions.
Expand Up @@ -22,6 +22,27 @@ public boolean requiresWorkspaceForPolling() {
return true;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return o instanceof AuthorInChangelog;
}

@Override
public int hashCode() {
return AuthorInChangelog.class.hashCode();
}

@Override
public String toString() {
return "AuthorInChangelog{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
Expand Up @@ -48,6 +48,32 @@ public void decorateCheckoutCommand(GitSCM scm, AbstractBuild<?, ?> build, GitCl
cmd.timeout(timeout);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

CheckoutOption that = (CheckoutOption) o;

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

@Override
public int hashCode() {
return 0;
}

@Override
public String toString() {
return "CheckoutOption{" +
"timeout=" + timeout +
'}';
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {

Expand Down
47 changes: 47 additions & 0 deletions src/main/java/hudson/plugins/git/extensions/impl/CloneOption.java
Expand Up @@ -162,6 +162,53 @@ public GitClientType getRequiredClient() {
return GitClientType.GITCLI;
}


@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

CloneOption that = (CloneOption) o;

if (shallow != that.shallow) {
return false;
}
if (noTags != that.noTags) {
return false;
}
if (depth != that.depth) {
return false;
}
if (honorRefspec != that.honorRefspec) {
return false;
}
if (reference != null ? !reference.equals(that.reference) : that.reference != null) {
return false;
}
return timeout != null ? timeout.equals(that.timeout) : that.timeout == null;
}

@Override
public int hashCode() {
return CloneOption.class.hashCode();
}

@Override
public String toString() {
return "CloneOption{" +
"shallow=" + shallow +
", noTags=" + noTags +
", reference='" + reference + '\'' +
", timeout=" + timeout +
", depth=" + depth +
", honorRefspec=" + honorRefspec +
'}';
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/hudson/plugins/git/extensions/impl/GitLFSPull.java
Expand Up @@ -43,6 +43,27 @@ public void decorateCheckoutCommand(GitSCM scm, Run<?, ?> build, GitClient git,
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return o instanceof GitLFSPull;
}

@Override
public int hashCode() {
return GitLFSPull.class.hashCode();
}

@Override
public String toString() {
return "GitLFSPull{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
Expand Up @@ -46,7 +46,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return localBranch != null ? localBranch.hashCode() : 0;
return LocalBranch.class.hashCode();
}

@Override
Expand Down
Expand Up @@ -29,6 +29,27 @@ public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listene
cmd.prune();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return o instanceof PruneStaleBranch;
}

@Override
public int hashCode() {
return PruneStaleBranch.class.hashCode();
}

@Override
public String toString() {
return "PruneStaleBranch{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
Expand Up @@ -119,6 +119,52 @@ public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, Task
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

SubmoduleOption that = (SubmoduleOption) o;

if (disableSubmodules != that.disableSubmodules) {
return false;
}
if (recursiveSubmodules != that.recursiveSubmodules) {
return false;
}
if (trackingSubmodules != that.trackingSubmodules) {
return false;
}
if (parentCredentials != that.parentCredentials) {
return false;
}
if (reference != null ? !reference.equals(that.reference) : that.reference != null) {
return false;
}
return timeout != null ? timeout.equals(that.timeout) : that.timeout == null;
}

@Override
public int hashCode() {
return SubmoduleOption.class.hashCode();
}

@Override
public String toString() {
return "SubmoduleOption{" +
"disableSubmodules=" + disableSubmodules +
", recursiveSubmodules=" + recursiveSubmodules +
", trackingSubmodules=" + trackingSubmodules +
", reference='" + reference + '\'' +
", parentCredentials=" + parentCredentials +
", timeout=" + timeout +
'}';
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/hudson/plugins/git/extensions/impl/UserIdentity.java
Expand Up @@ -50,6 +50,36 @@ public void populateEnvironmentVariables(GitSCM scm, Map<String, String> env) {
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

UserIdentity that = (UserIdentity) o;

if (name != null ? !name.equals(that.name) : that.name != null) {
return false;
}
return email != null ? email.equals(that.email) : that.email == null;
}

@Override
public int hashCode() {
return UserIdentity.class.hashCode();
}

@Override
public String toString() {
return "UserIdentity{" +
"name='" + name + '\'' +
", email='" + email + '\'' +
'}';
}

@Override
public GitClient decorate(GitSCM scm, GitClient git) throws IOException, InterruptedException, GitException {
GitSCM.DescriptorImpl d = scm.getDescriptor();
Expand Down
Expand Up @@ -28,6 +28,27 @@ public void beforeCheckout(GitSCM scm, Run<?, ?> build, GitClient git, TaskListe
git.getWorkTree().deleteContents();
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return o instanceof WipeWorkspace;
}

@Override
public int hashCode() {
return WipeWorkspace.class.hashCode();
}

@Override
public String toString() {
return "WipeWorkspace{}";
}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java
Expand Up @@ -348,15 +348,15 @@ public Void run(GitClient client, String remoteName) throws IOException, Interru
count++;
final String branchName = StringUtils.removeStart(b.getName(), remoteName + "/");
if (request.process(new SCMHead(branchName),
new SCMSourceRequest.IntermediateFactory<ObjectId>() {
new SCMSourceRequest.IntermediateLambda<ObjectId>() {
@Nullable
@Override
public ObjectId create() throws IOException, InterruptedException {
listener.getLogger().println(" Checking branch " + branchName);
return b.getSHA1();
}
},
new SCMSourceRequest.ProbeFactory<SCMHead, ObjectId>() {
new SCMSourceRequest.ProbeLambda<SCMHead, ObjectId>() {
@NonNull
@Override
public SCMSourceCriteria.Probe create(@NonNull SCMHead head,
Expand Down Expand Up @@ -413,7 +413,7 @@ public SCMProbeStat stat(@NonNull String path) throws IOException {
}
};
}
}, new SCMSourceRequest.LazyRevisionFactory<SCMHead, SCMRevision, ObjectId>() {
}, new SCMSourceRequest.LazyRevisionLambda<SCMHead, SCMRevision, ObjectId>() {
@NonNull
@Override
public SCMRevision create(@NonNull SCMHead head, @Nullable ObjectId intermediate)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jenkins/plugins/git/GitSCMSource.java
Expand Up @@ -141,7 +141,7 @@ public class GitSCMSource extends AbstractGitSCMSource {
*
* @since 3.4.0
*/
private List<SCMSourceTrait> traits;
private List<SCMSourceTrait> traits = new ArrayList<>();

@DataBoundConstructor
public GitSCMSource(String id, String remote, String credentialsId) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/jenkins/plugins/git/GitSCMSourceContext.java
Expand Up @@ -170,7 +170,8 @@ public final C withRefSpec(@NonNull String refSpec) {
/**
* Adds the specified ref specs. If no ref specs were previously defined then the supplied ref specs will replace
* {@link AbstractGitSCMSource#REF_SPEC_DEFAULT}. The ref spec is expected to be processed for substitution of
* {@link AbstractGitSCMSource#REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR} by {@link #remote()} before use.
* {@link AbstractGitSCMSource#REF_SPEC_REMOTE_NAME_PLACEHOLDER_STR} by {@link AbstractGitSCMSource#getRemote()}
* before use.
*
* @param refSpecs the ref spec templates to add.
* @return {@code this} for method chaining.
Expand Down

0 comments on commit 72cab2a

Please sign in to comment.