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

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

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.smoketurner.notification.application.core.LongSetParam.java

@Override
protected Set<Long> parse(final String input) throws Exception {
    if (Strings.isNullOrEmpty(input)) {
        return Collections.emptySet();
    }/*from w  ww.  j  a  v a 2 s.c om*/

    final Iterable<String> splitter = Splitter.on(',').omitEmptyStrings().trimResults().split(input);

    final ImmutableSet.Builder<Long> builder = ImmutableSet.builder();
    for (String value : splitter) {
        try {
            builder.add(Long.parseLong(value));
        } catch (NumberFormatException ignore) {
            // ignore invalid numbers
        }
    }
    return builder.build();
}

From source file:org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub.java

@Override
public Iterable<ITmfEventAspect<?>> getEventAspects() {
    /*/*from  w  w w .  j  a va 2  s. co m*/
     * This method needs to fill the aspects dynamically because aspects in
     * the parent class are not all present at the beginning of the trace
     */
    ImmutableSet.Builder<ITmfEventAspect<?>> builder = ImmutableSet.builder();
    builder.addAll(super.getEventAspects());
    builder.add(KernelTidAspect.INSTANCE);
    builder.add(ThreadPriorityAspect.INSTANCE);
    return builder.build();
}

From source file:org.novelang.outfit.shell.DefaultJmxKit.java

@Override
public ImmutableSet<String> getJvmProperties(final int jmxPortForJvmProperty,
        final Integer heartbeatMaximumPeriod) {
    final ImmutableSet.Builder<String> argumentList = ImmutableSet.builder();
    argumentList.add("-Dcom.sun.management.jmxremote.port=" + jmxPortForJvmProperty);

    // No security here.
    argumentList.add("-Dcom.sun.management.jmxremote.authenticate=false");
    argumentList.add("-Dcom.sun.management.jmxremote.ssl=false");

    argumentList.add("-javaagent:" + AgentFileInstaller.getInstance().getJarFile().getAbsolutePath()
            + (heartbeatMaximumPeriod == null ? ""
                    : "=" + Insider.MAXIMUM_HEARTBEATDELAY_PARAMETERNAME + heartbeatMaximumPeriod));

    return argumentList.build();
}

From source file:org.sonar.plugins.csharp.CSharpSonarRulesDefinition.java

@Override
public void define(Context context) {
    NewRepository repository = context.createRepository(REPOSITORY_KEY, CSharpPlugin.LANGUAGE_KEY)
            .setName(REPOSITORY_NAME);/*from   w w w.jav a  2 s  .c  om*/

    RulesDefinitionXmlLoader loader = new RulesDefinitionXmlLoader();
    loader.load(repository, new InputStreamReader(
            getClass().getResourceAsStream("/org/sonar/plugins/csharp/rules.xml"), StandardCharsets.UTF_8));
    SqaleXmlLoader.load(repository, "/org/sonar/plugins/csharp/sqale.xml");

    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    for (NewRule rule : repository.rules()) {
        builder.add(rule.key());
    }
    allRuleKeys = builder.build();

    repository.done();
}

From source file:com.stackframe.sarariman.DirectorySynchronizerImpl.java

private Set<Integer> getEmployeeIDs(DataSource dataSource) throws SQLException {
    Connection connection = dataSource.getConnection();
    try {/*  w w w .  j a v a 2 s  .co  m*/
        PreparedStatement ps = connection.prepareStatement("SELECT id FROM employee");
        try {
            ResultSet rs = ps.executeQuery();
            ImmutableSet.Builder<Integer> setBuilder = ImmutableSet.builder();
            while (rs.next()) {
                setBuilder.add(rs.getInt("id"));
            }

            return setBuilder.build();
        } finally {
            ps.close();
        }
    } finally {
        connection.close();
    }
}

From source file:org.jclouds.googlecompute.compute.functions.MachineTypeToHardware.java

private Iterable<Volume> collectVolumes(MachineType input) {
    ImmutableSet.Builder<Volume> volumes = ImmutableSet.builder();
    for (MachineType.EphemeralDisk disk : input.getEphemeralDisks()) {
        volumes.add(new VolumeImpl(null, Volume.Type.LOCAL, new Integer(disk.getDiskGb()).floatValue(), null,
                true, false));//  ww  w  .  jav a  2 s.  com
    }
    return volumes.build();
}

From source file:com.github.fge.jsonschema.keyword.validator.draftv4.RequiredKeywordValidator.java

public RequiredKeywordValidator(final JsonNode digest) {
    super("required");
    final ImmutableSet.Builder<String> builder = ImmutableSet.builder();

    for (final JsonNode element : digest.get(keyword))
        builder.add(element.textValue());

    required = builder.build();//from  www. ja v  a 2  s  .com
}

From source file:ch.ledcom.tomcat.valves.allocation.RequestAllocationRecorderValve.java

public RequestAllocationRecorderValve() {
    disabled = parseBoolean(System.getProperty(PROP_DISABLED), false);
    boolean printSummary = parseBoolean(System.getProperty(PROP_PRINT_SUMMARY), false);
    int printSummaryPeriod = parseInt(System.getProperty(PROP_PRINT_SUMMARY_PERIOD), 1);

    if (!disabled) {
        threadAllocationTracer = new InstrumentedThreadAllocationTracer();
    } else {//from w  ww.  j  ava 2  s  .c o m
        threadAllocationTracer = null;
    }

    ImmutableSet.Builder<AllocationReporter> builder = ImmutableSet.builder();
    builder.add(new AllocationLogger());

    if (printSummary) {
        builder.add(new SummaryAllocationLogger(printSummaryPeriod));
    }
    reporters = builder.build();
}

From source file:com.spectralogic.ds3autogen.java.generators.requestmodels.StreamRequestPayloadGenerator.java

/**
 * Gets all the required imports that the Request will need in order to properly
 * generate the Java request code, including the Stream and Channel imports
 *///  w  w w .j  a va 2 s  .com
@Override
public ImmutableList<String> getAllImports(final Ds3Request ds3Request, final String packageName) {
    final ImmutableSet.Builder<String> builder = ImmutableSet.builder();

    builder.add(getParentImport(ds3Request));
    builder.addAll(getImportsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getImportsFromParamList(ds3Request.getOptionalQueryParams()));

    if (isResourceAnArg(ds3Request.getResource(), ds3Request.includeIdInPath())) {
        if (RequestConverterUtil.isResourceId(ds3Request.getResource())) {
            builder.add("java.util.UUID");
        }
        builder.add("com.google.common.net.UrlEscapers");
    }
    builder.add("com.spectralogic.ds3client.utils.SeekableByteChannelInputStream");
    builder.add("java.nio.channels.SeekableByteChannel");
    builder.add("java.io.InputStream");

    return builder.build().asList();
}

From source file:org.eclipse.buildship.core.workspace.internal.DefaultCompositeGradleBuild.java

@Override
public CompositeGradleBuild withBuild(FixedRequestAttributes build) {
    ImmutableSet.Builder<FixedRequestAttributes> builds = ImmutableSet.builder();
    builds.addAll(this.builds);
    builds.add(build);
    return new DefaultCompositeGradleBuild(builds.build());
}