-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use invokeStatic instead of Functions
- Loading branch information
1 parent
f905a3f
commit 63367c7
Showing
3 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
package jenkins.views; | ||
|
||
import java.util.List; | ||
import java.util.logging.Logger; | ||
import java.util.stream.Collectors; | ||
|
||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
import hudson.Extension; | ||
import hudson.ExtensionList; | ||
|
||
@Extension(ordinal = Integer.MIN_VALUE) | ||
public class JenkinsHeader implements Header { | ||
|
||
private static Logger LOGGER = Logger.getLogger(JenkinsHeader.class.getName()); | ||
|
||
@Override | ||
public boolean isHeaderEnabled() { | ||
return true; | ||
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
@CheckForNull | ||
public static Header get() { | ||
List<Header> headers = ExtensionList.lookup(Header.class).stream().filter(header -> header.isHeaderEnabled()).collect(Collectors.toList()); | ||
if (headers.size() > 0) { | ||
if (headers.size() > 1) { | ||
LOGGER.warning("More than one configured header. This should not happen. Serving the Jenkins default header and please review"); | ||
} else { | ||
return headers.get(0); | ||
} | ||
} | ||
return new JenkinsHeader(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters