package com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.features;

import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.JobView;
import com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.features.headline.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;

/**
 * @author Jan Molak
 */
public class HasHeadline implements Feature<Headline> {

    private final HeadlineConfig config;
    private JobView job;

    public HasHeadline(HeadlineConfig config) {
        this.config = config;
    }

    @Override
    public HasHeadline of(JobView jobView) {
        this.job = jobView;

        return this;
    }

    @Override
    public Headline asJson() {
        return headlineOf(job).asJson();
    }

    private CandidateHeadline headlineOf(final JobView job) {
        List<CandidateHeadline> availableHeadlines = new ArrayList<>();
        Collections.addAll(availableHeadlines,
                new HeadlineOfExecuting(job, config),
                new HeadlineOfAborted(job, config),
                new HeadlineOfFixed(job, config),
                new HeadlineOfFailing(job, config)
        );

        return availableHeadlines.stream().filter(new Predicate<CandidateHeadline>() {
            @Override
            public boolean test(CandidateHeadline candidateHeadline) {
                return candidateHeadline.isApplicableTo(job);
            }
        }).findFirst().orElse(new NoHeadline());
    }
}

@@ -315,45 +315,8 @@
 ist;
-%0Aimport java.util.function.Predicate;
 %0A%0A/*
@@ -1206,168 +1206,53 @@
 am()
-.filter(new Predicate%3CCandidateHeadline%3E() %7B%0A            @Override%0A            public boolean test(CandidateHeadline candidateHeadline) %7B%0A                return
+%0A                .filter(candidateHeadline -%3E
  can
@@ -1285,17 +1285,17 @@
 eTo(job)
-;
+)
 %0A       
@@ -1299,22 +1299,16 @@
     
-    %7D%0A
         
 %7D).f
@@ -1307,10 +1307,8 @@
     
-%7D)
 .fin
@@ -1315,16 +1315,33 @@
 dFirst()
+%0A                
 .orElse(

Replace anonymous type with lambda