Permalink
Browse files

fixed anonymous class warning

[FIXES JENKINS-50750]
  • Loading branch information...
daspilker committed Apr 12, 2018
1 parent c094cd7 commit 50f78603067d4bd0ed77646d801b5ccd771def3d
Showing with 12 additions and 14 deletions.
  1. +2 −0 docs/Home.md
  2. +10 −14 job-dsl-plugin/src/main/groovy/javaposse/jobdsl/plugin/LookupStrategy.java
@@ -38,6 +38,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* Fixed problem with
[Pipeline Multibranch Plugin](https://wiki.jenkins.io/display/JENKINS/Pipeline+Multibranch+Plugin)
([JENKINS-50119](https://issues.jenkins-ci.org/browse/JENKINS-50119))
* Fixed anonymous class warning
([JENKINS-50750](https://issues.jenkins-ci.org/browse/JENKINS-50750))
* Support for older versions of the
[CloudBees Folders Plugin](https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin) is deprecated, see
[Migration](Migration#migrating-to-169)
@@ -5,6 +5,8 @@
import jenkins.model.Jenkins;
import org.apache.commons.io.FilenameUtils;

import java.util.function.Function;

/**
* A JobLookupStrategy encapsulates where a seed job will look for existing jobs
* and where it will create new jobs. This matters when you use relative names in
@@ -14,26 +16,17 @@
/**
* Using this naming strategy jobs with relative path names are absolute names.
*/
JENKINS_ROOT("Jenkins Root") {
@Override
protected ItemGroup getContext(Item seedJob) {
return Jenkins.getInstance();
}
},
JENKINS_ROOT("Jenkins Root", (seedJob) -> Jenkins.getInstance()),

/**
* Using this naming strategy jobs with relative path names are created relative
* to the seed job's parent folder.
*/
SEED_JOB("Seed Job") {
@Override
protected ItemGroup getContext(Item seedJob) {
return seedJob.getParent();
}
};
SEED_JOB("Seed Job", Item::getParent);

LookupStrategy(String displayName) {
LookupStrategy(String displayName, Function<Item, ItemGroup> context) {
this.displayName = displayName;
this.context = context;
}

/**
@@ -60,7 +53,9 @@ protected ItemGroup getContext(Item seedJob) {
* @param seedJob a seed job
* @return the context
*/
protected abstract ItemGroup getContext(Item seedJob);
protected ItemGroup getContext(Item seedJob) {
return context.apply(seedJob);
}

/**
* Get the parent {@link hudson.model.ItemGroup} of the item addressed by the given path.
@@ -93,6 +88,7 @@ public String getDisplayName() {
}

private final String displayName;
private final Function<Item, ItemGroup> context;

private static ItemGroup getItemGroup(String path) {
Jenkins instance = Jenkins.getInstance();

0 comments on commit 50f7860

Please sign in to comment.