Search in sources :

Example 1 with Closure

use of org.apache.commons.collections.Closure in project head by mifos.

the class MultipleLoanAccountsCreationActionForm method reset.

@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    CollectionUtils.forAllDo(clientDetails, new Closure() {

        @Override
        public void execute(Object arg0) {
            ((MultipleLoanCreationDto) arg0).resetSelected();
        }
    });
}
Also used : Closure(org.apache.commons.collections.Closure)

Example 2 with Closure

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

the class BuildAssignmentService method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    LOGGER.info("[Configuration Changed] Removing jobs for pipelines that no longer exist in configuration.");
    synchronized (this) {
        List<JobPlan> jobsToRemove = new ArrayList<>();
        for (JobPlan jobPlan : jobPlans) {
            if (!newCruiseConfig.hasBuildPlan(new CaseInsensitiveString(jobPlan.getPipelineName()), new CaseInsensitiveString(jobPlan.getStageName()), jobPlan.getName(), true)) {
                jobsToRemove.add(jobPlan);
            }
        }
        forAllDo(jobsToRemove, new Closure() {

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

Example 3 with Closure

use of org.apache.commons.collections.Closure in project smarthome by eclipse.

the class JavaSoundAudioSink method getVolume.

@Override
public PercentType getVolume() throws IOException {
    if (!isMac) {
        final Float[] volumes = new Float[1];
        runVolumeCommand(new Closure() {

            @Override
            public void execute(Object input) {
                FloatControl volumeControl = (FloatControl) input;
                volumes[0] = volumeControl.getValue();
            }
        });
        if (volumes[0] != null) {
            return new PercentType(new BigDecimal(volumes[0] * 100f));
        } else {
            throw new IOException("Cannot determine master volume level");
        }
    } else {
        // we use a cache of the value as the script execution is pretty slow
        if (macVolumeValue == null) {
            Process p = Runtime.getRuntime().exec(new String[] { "osascript", "-e", "output volume of (get volume settings)" });
            String value = IOUtils.toString(p.getInputStream()).trim();
            macVolumeValue = new PercentType(value);
        }
        return macVolumeValue;
    }
}
Also used : Closure(org.apache.commons.collections.Closure) PercentType(org.eclipse.smarthome.core.library.types.PercentType) IOException(java.io.IOException) FloatControl(javax.sound.sampled.FloatControl) BigDecimal(java.math.BigDecimal)

Example 4 with Closure

use of org.apache.commons.collections.Closure in project smarthome by eclipse.

the class JavaSoundAudioSink method setVolume.

@Override
public void setVolume(final PercentType volume) throws IOException {
    if (volume.intValue() < 0 || volume.intValue() > 100) {
        throw new IllegalArgumentException("Volume value must be in the range [0,100]!");
    }
    if (!isMac) {
        runVolumeCommand(new Closure() {

            @Override
            public void execute(Object input) {
                FloatControl volumeControl = (FloatControl) input;
                volumeControl.setValue(volume.floatValue() / 100f);
            }
        });
    } else {
        Runtime.getRuntime().exec(new String[] { "osascript", "-e", "set volume output volume " + volume.intValue() });
        macVolumeValue = volume;
    }
}
Also used : Closure(org.apache.commons.collections.Closure) FloatControl(javax.sound.sampled.FloatControl)

Example 5 with Closure

use of org.apache.commons.collections.Closure in project mule by mulesoft.

the class PersistentXaTransactionContext method size.

public int size(QueueStore queue) {
    final AtomicInteger addSize = new AtomicInteger(0);
    CollectionUtils.forAllDo(this.transactionJournal.getLogEntriesForTx(xid), new Closure() {

        @Override
        public void execute(Object value) {
            if (((XaQueueTxJournalEntry) value).isAdd() || ((XaQueueTxJournalEntry) value).isAddFirst()) {
                addSize.incrementAndGet();
            }
        }
    });
    return queue.getSize() + addSize.get();
}
Also used : Closure(org.apache.commons.collections.Closure) XaQueueTxJournalEntry(org.mule.runtime.core.internal.util.journal.queue.XaQueueTxJournalEntry) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

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