Example usage for com.google.common.collect ImmutableList.Builder add

List of usage examples for com.google.common.collect ImmutableList.Builder add

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder add.

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:org.basepom.mojo.propertyhelper.PropertyField.java

public static List<PropertyElement> createProperties(final Model model, final Map<String, String> values,
        final PropertyGroup propertyGroup) throws IOException, InterpolationException {
    checkNotNull(model, "model is null");
    checkNotNull(values, "values is null");
    checkNotNull(propertyGroup, "propertyGroup is null");

    final InterpolatorFactory interpolatorFactory = new InterpolatorFactory(Optional.of(model));

    final ImmutableList.Builder<PropertyElement> result = ImmutableList.builder();
    final Map<String, String> properties = propertyGroup.getProperties();

    for (String name : properties.keySet()) {
        final String value = propertyGroup.getPropertyValue(interpolatorFactory, name, values);
        result.add(new PropertyField(name, value));
    }/*from   ww  w.jav  a  2 s.  c  o m*/
    return result.build();
}

From source file:org.sosy_lab.cpachecker.util.resources.ResourceLimitChecker.java

/**
 * Create an instance of this class from some configuration options.
 * The returned instance is not started yet.
 *///from  ww  w  .  ja va2s  . co  m
public static ResourceLimitChecker fromConfiguration(Configuration config, LogManager logger,
        ShutdownNotifier notifier) throws InvalidConfigurationException {

    ResourceLimitOptions options = new ResourceLimitOptions();
    config.inject(options);

    ImmutableList.Builder<ResourceLimit> limits = ImmutableList.builder();
    if (options.walltime.compareTo(TimeSpan.empty()) >= 0) {
        limits.add(WalltimeLimit.fromNowOn(options.walltime));
    }
    if (options.cpuTime.compareTo(TimeSpan.empty()) >= 0) {
        try {
            limits.add(ProcessCpuTimeLimit.fromNowOn(options.cpuTime));
        } catch (JMException e) {
            logger.logDebugException(e, "Querying cpu time failed");
            logger.log(Level.WARNING,
                    "Your Java VM does not support measuring the cpu time, cpu time threshold disabled.");
        }
    }

    ImmutableList<ResourceLimit> limitsList = limits.build();
    if (!limitsList.isEmpty()) {
        logger.log(Level.INFO, "Using the following resource limits:",
                Joiner.on(", ").join(Lists.transform(limitsList, new Function<ResourceLimit, String>() {
                    @Override
                    public String apply(@Nonnull ResourceLimit pInput) {
                        return pInput.getName();
                    }
                })));
    }
    return new ResourceLimitChecker(notifier, limitsList);
}