Repository: jenkinsci/jenkins
File: core/src/main/java/jenkins/views/Header.java (Java)

Code before:
     */
    public boolean isAvailable() {
        return isCompatible() && isEnabled();
    }

    /**
     * Checks API compatibility of the header
     * @return if header is compatible
     */
    public abstract boolean isCompatible();

    /**
     * Checks if header is enabled.
     * @return if header is enabled
     */
    public abstract boolean isEnabled();

    @Restricted(NoExternalUse.class)
    public static Header get() {
        Optional<Header> header = ExtensionList.lookup(Header.class).stream().filter(Header::isAvailable).findFirst();
        return header.orElseGet(JenkinsHeader::new);
    }

    /**
     * @return a list of {@link Action} to show in the header.
     * The default implemention returns an {@link Jenkins#getActions()} that should be displayed (ie have an icon).
     */
    @Restricted(NoExternalUse.class)
    public List<Action> getActions() {
        // There's an issue where new actions (e.g. a new plugin installation) don't appear in the order
        // of their ordinal annotation - to work around that we manually sort the list
        Map<String, Double> rootActionsOrdinal = ExtensionList.lookup(RootAction.class)
                .getComponents()
                .stream()
                .collect(Collectors.toMap(
                        c -> c.getInstance().getClass().getName(),
                        ExtensionComponent::ordinal
                ));

        return Jenkins.get()
                .getActions()
                .stream()
                .filter(e -> e.getIconFileName() != null || (e instanceof IconSpec is && is.getIconClassName() != null))
                .sorted(Comparator.comparingDouble(
                        a -> rootActionsOrdinal.getOrDefault(a.getClass().getName(), Double.MAX_VALUE)
                ).reversed())
                .toList();
    }
}


Review comment (suggestion):
Typo in Javadoc: 'implemention' should be corrected to 'implementation'.
```suggestion
     * The default implementation returns an {@link Jenkins#getActions()} that should be displayed (ie have an icon).
```

Code after:
     */
    public boolean isAvailable() {
        return isCompatible() && isEnabled();
    }

    /**
     * Checks API compatibility of the header
     * @return if header is compatible
     */
    public abstract boolean isCompatible();

    /**
     * Checks if header is enabled.
     * @return if header is enabled
     */
    public abstract boolean isEnabled();

    @Restricted(NoExternalUse.class)
    public static Header get() {
        Optional<Header> header = ExtensionList.lookup(Header.class).stream().filter(Header::isAvailable).findFirst();
        return header.orElseGet(JenkinsHeader::new);
    }

    /**
     * @return a list of {@link Action} to show in the header.
     * The default implementation returns an {@link Jenkins#getActions()} that should be displayed (ie have an icon).
     */
    @Restricted(NoExternalUse.class)
    public List<Action> getActions() {
        // There's an issue where new actions (e.g. a new plugin installation) don't appear in the order
        // of their ordinal annotation - to work around that we manually sort the list
        Map<String, Double> rootActionsOrdinal = ExtensionList.lookup(RootAction.class)
                .getComponents()
                .stream()
                .collect(Collectors.toMap(
                        c -> c.getInstance().getClass().getName(),
                        ExtensionComponent::ordinal
                ));

        return Jenkins.get()
                .getActions()
                .stream()
                .filter(e -> e.getIconFileName() != null || (e instanceof IconSpec is && is.getIconClassName() != null))
                .sorted(Comparator.comparingDouble(
                        a -> rootActionsOrdinal.getOrDefault(a.getClass().getName(), Double.MAX_VALUE)
                ).reversed())
                .toList();
    }
}