Skip to content
Permalink
Browse files

[JENKINS-43507] Code review comments

  • Loading branch information...
stephenc committed Jun 20, 2017
1 parent 710f0f7 commit 900cbd038e4e6c24b1590c62edaa0f69fd7a3b49
@@ -29,11 +29,10 @@
/**
* The repository to track. This can be URL or a local file path.
*/
private @Nonnull
String source;
private @Nonnull String source;

public MercurialSCMBuilder(@Nonnull SCMHead head, @CheckForNull SCMRevision revision, String source,
String credentialsId) {
public MercurialSCMBuilder(@Nonnull SCMHead head, @CheckForNull SCMRevision revision, @Nonnull String source,
@CheckForNull String credentialsId) {
super(MercurialSCM.class, head, revision);
this.source = source;
this.credentialsId = credentialsId;
@@ -54,6 +54,7 @@
import jenkins.scm.api.trait.SCMSourceTrait;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import jenkins.scm.impl.trait.RegexSCMHeadFilterTrait;
import jenkins.scm.impl.trait.RegexSCMSourceFilterTrait;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
@@ -154,21 +155,13 @@ public void setCredentialsId(@CheckForNull String credentialsId) {
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public String getInstallation() {
for (SCMSourceTrait t: traits) {
if (t instanceof MercurialInstallationSCMSourceTrait) {
return ((MercurialInstallationSCMSourceTrait) t).getInstallation();
}
}
return null;
MercurialInstallationSCMSourceTrait t = getTrait(MercurialInstallationSCMSourceTrait.class);
return t != null ? t.getInstallation() : null;
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public String getBranchPattern() {
for (SCMSourceTrait t: traits) {
if (t instanceof RegexSCMHeadFilterTrait) {
return ((RegexSCMHeadFilterTrait) t).getRegex();
}
}
return "";
RegexSCMHeadFilterTrait t = getTrait(RegexSCMHeadFilterTrait.class);
return t != null ? t.getRegex() : "";
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public String getModules() {
@@ -180,21 +173,21 @@ public void setCredentialsId(@CheckForNull String credentialsId) {
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public HgBrowser getBrowser() {
for (SCMSourceTrait t: traits) {
if (t instanceof MercurialBrowserSCMSourceTrait) {
return ((MercurialBrowserSCMSourceTrait) t).getBrowser();
}
}
return null;
MercurialBrowserSCMSourceTrait t = getTrait(MercurialBrowserSCMSourceTrait.class);
return t != null ? t.getBrowser() : null;
}

@Deprecated @Restricted(DoNotUse.class) @RestrictedSince("2.0") public boolean isClean() {
return getTrait(CleanMercurialSCMSourceTrait.class) != null;
}

private @CheckForNull <T extends SCMSourceTrait> T getTrait(@Nonnull Class<T> traitClass) {
for (SCMSourceTrait t: traits) {
if (t instanceof CleanMercurialSCMSourceTrait) {
return true;
if (traitClass.isInstance(t)) {
return traitClass.cast(t);
}
}
return false;
return null;
}

@Override protected void retrieve(@CheckForNull SCMSourceCriteria criteria, @Nonnull SCMHeadObserver observer,

0 comments on commit 900cbd0

Please sign in to comment.
You can’t perform that action at this time.