Search in sources :

Example 6 with Closure

use of org.apache.commons.collections.Closure in project gocd by gocd.

the class BuildAssignmentService method pipelineConfigChangedListener.

protected EntityConfigChangedListener<PipelineConfig> pipelineConfigChangedListener() {
    return new EntityConfigChangedListener<PipelineConfig>() {

        @Override
        public void onEntityConfigChange(PipelineConfig pipelineConfig) {
            LOGGER.info("[Configuration Changed] Removing deleted jobs for pipeline {}.", pipelineConfig.name());
            synchronized (BuildAssignmentService.this) {
                List<JobPlan> jobsToRemove = new ArrayList<>();
                for (JobPlan jobPlan : jobPlans) {
                    if (pipelineConfig.name().equals(new CaseInsensitiveString(jobPlan.getPipelineName()))) {
                        StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(jobPlan.getStageName()));
                        if (stageConfig != null) {
                            JobConfig jobConfig = stageConfig.jobConfigByConfigName(new CaseInsensitiveString(jobPlan.getName()));
                            if (jobConfig == null) {
                                jobsToRemove.add(jobPlan);
                            }
                        } else {
                            jobsToRemove.add(jobPlan);
                        }
                    }
                }
                forAllDo(jobsToRemove, new Closure() {

                    @Override
                    public void execute(Object o) {
                        removeJob((JobPlan) o);
                    }
                });
            }
        }
    };
}
Also used : Closure(org.apache.commons.collections.Closure) EntityConfigChangedListener(com.thoughtworks.go.listener.EntityConfigChangedListener)

Example 7 with Closure

use of org.apache.commons.collections.Closure in project opencast by opencast.

the class DublinCoreCatalog method get.

@Override
@SuppressWarnings("unchecked")
public List<String> get(EName property, final String language) {
    RequireUtil.notNull(property, "property");
    RequireUtil.notNull(language, "language");
    if (LANGUAGE_ANY.equals(language)) {
        return (List<String>) CollectionUtils.collect(getValuesAsList(property), new Transformer() {

            @Override
            public Object transform(Object o) {
                return ((CatalogEntry) o).getValue();
            }
        });
    } else {
        final List<String> values = new ArrayList<String>();
        final boolean langUndef = LANGUAGE_UNDEFINED.equals(language);
        CollectionUtils.forAllDo(getValuesAsList(property), new Closure() {

            @Override
            public void execute(Object o) {
                CatalogEntry c = (CatalogEntry) o;
                String lang = c.getAttribute(XML_LANG_ATTR);
                if ((langUndef && lang == null) || (language.equals(lang)))
                    values.add(c.getValue());
            }
        });
        return values;
    }
}
Also used : Transformer(org.apache.commons.collections.Transformer) Closure(org.apache.commons.collections.Closure) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Closure (org.apache.commons.collections.Closure)7 FloatControl (javax.sound.sampled.FloatControl)2 EntityConfigChangedListener (com.thoughtworks.go.listener.EntityConfigChangedListener)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Transformer (org.apache.commons.collections.Transformer)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1 XaQueueTxJournalEntry (org.mule.runtime.core.internal.util.journal.queue.XaQueueTxJournalEntry)1