List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
From source file:org.openqa.selenium.remote.RemoteLogs.java
public Set<String> getAvailableLogTypes() { Object raw = executeMethod.execute(DriverCommand.GET_AVAILABLE_LOG_TYPES, null); @SuppressWarnings("unchecked") List<String> rawList = (List<String>) raw; ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<String>(); for (String logType : rawList) { builder.add(logType); }/*from ww w . j a v a 2 s .co m*/ builder.addAll(getAvailableLocalLogs()); return builder.build(); }
From source file:com.facebook.buck.features.ocaml.OcamlDepToolStep.java
@Override protected void addOptions(ImmutableSet.Builder<ProcessExecutor.Option> options) { // We need this else we get output with color codes which confuses parsing options.add(ProcessExecutor.Option.EXPECTING_STD_ERR); options.add(ProcessExecutor.Option.EXPECTING_STD_OUT); }
From source file:com.facebook.buck.features.apple.project.XCodeProjectCommandHelper.java
@VisibleForTesting static ImmutableSet<BuildTarget> replaceWorkspacesWithSourceTargetsIfPossible( ImmutableSet<BuildTarget> buildTargets, TargetGraph projectGraph) { Iterable<TargetNode<?>> targetNodes = projectGraph.getAll(buildTargets); ImmutableSet.Builder<BuildTarget> resultBuilder = ImmutableSet.builder(); for (TargetNode<?> node : targetNodes) { if (node.getDescription() instanceof XcodeWorkspaceConfigDescription) { TargetNode<XcodeWorkspaceConfigDescriptionArg> castedWorkspaceNode = castToXcodeWorkspaceTargetNode( node);// www. ja v a 2 s. c om Optional<BuildTarget> srcTarget = castedWorkspaceNode.getConstructorArg().getSrcTarget(); if (srcTarget.isPresent()) { resultBuilder.add(srcTarget.get()); } else { resultBuilder.add(node.getBuildTarget()); } } else { resultBuilder.add(node.getBuildTarget()); } } return resultBuilder.build(); }
From source file:net.morimekta.config.impl.ImmutableConfig.java
private Object immutable(Object o) { if (o instanceof ImmutableList || o instanceof ImmutableSet) { return o; } else if (o instanceof Set) { ImmutableSet.Builder<Object> builder = ImmutableSet.builder(); for (Object v : (Set) o) { builder.add(immutable(v)); }//from w w w . ja v a 2 s. c om return builder.build(); } else if (o instanceof Collection) { ImmutableList.Builder<Object> builder = ImmutableList.builder(); for (Object v : (Collection) o) { builder.add(immutable(v)); } return builder.build(); } else { // Assume all other types of values are natively immutable. return o; } }
From source file:com.exoplatform.iversion.VersionNode.java
/** * Collects this revision and all of its parent's revision * /*from w w w . java 2 s. co m*/ * @param revisions collector revision */ private void collectRevisions(ImmutableSet.Builder<Long> revisions) { revisions.add(getRevision()); // for (VersionNode<K, V, M, T> parent : parents) { revisions.addAll(parent.getRevisions()); } }
From source file:com.spectralogic.ds3client.commands.interfaces.RequestHeadersImpl.java
/** * Retrieves the non-percent encoded key set. Used in unit testing. *//*from www. j av a2 s . c o m*/ @Override public Set<String> keySet() { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (final String key : headers.keySet()) { builder.add(toDecodedString(key)); } return builder.build(); }
From source file:io.github.mywarp.mywarp.bukkit.BukkitGame.java
@Override public ImmutableSet<LocalWorld> getWorlds() { ImmutableSet.Builder<LocalWorld> builder = ImmutableSet.builder(); for (World world : Bukkit.getWorlds()) { builder.add(BukkitAdapter.adapt(world)); }/* w w w . j a va2 s . c o m*/ return builder.build(); }
From source file:com.autsia.codefreeze.impl.CGLIBCodeFreeze.java
@SuppressWarnings("unchecked") private <T> T proxifySet(Set set) throws InstantiationException, IllegalAccessException { ImmutableSet.Builder<Object> builder = ImmutableSet.builder(); set.stream().forEach(bean -> builder.add(freeze(bean))); return (T) builder.build(); }
From source file:org.fcrepo.kernel.rdf.impl.FixityRdfContext.java
/** * Ordinary constructor./*from ww w . j ava 2 s. c o m*/ * * @param node * @param graphSubjects * @param blobs * @throws RepositoryException */ public FixityRdfContext(final Node node, final IdentifierTranslator graphSubjects, final Iterable<FixityResult> blobs) throws RepositoryException { super(node, graphSubjects); concat(Iterators .concat(Iterators.transform(blobs.iterator(), new Function<FixityResult, Iterator<Triple>>() { @Override public Iterator<Triple> apply(final FixityResult blob) { final com.hp.hpl.jena.graph.Node resultSubject = getTransientFixitySubject(); final ImmutableSet.Builder<Triple> b = builder(); try { b.add(create(resultSubject, RDF.type.asNode(), FIXITY_TYPE.asNode())); b.add(create(graphSubjects.getSubject(node.getPath()).asNode(), HAS_FIXITY_RESULT.asNode(), resultSubject)); final String storeIdentifier = blob.getStoreIdentifier(); final com.hp.hpl.jena.graph.Node contentLocation = createResource(storeIdentifier) .asNode(); b.add(create(resultSubject, HAS_CONTENT_LOCATION.asNode(), contentLocation)); b.add(create(contentLocation, RDF.type.asNode(), CONTENT_LOCATION_TYPE.asNode())); b.add(create(contentLocation, HAS_CONTENT_LOCATION_VALUE.asNode(), createLiteral(storeIdentifier))); for (final FixityResult.FixityState state : blob.getStatus()) { b.add(create(resultSubject, HAS_FIXITY_STATE.asNode(), createLiteral(state.toString()))); } final String checksum = blob.getComputedChecksum().toString(); b.add(create(resultSubject, HAS_MESSAGE_DIGEST.asNode(), createURI(checksum))); b.add(create(resultSubject, HAS_SIZE.asNode(), createTypedLiteral(blob.getComputedSize()).asNode())); return b.build().iterator(); } catch (final RepositoryException e) { throw propagate(e); } } }))); }
From source file:org.openqa.selenium.remote.server.AllHandlers.java
private <H extends CommandHandler> Function<String, CommandHandler> handler(String template, Class<H> handler) { UrlTemplate urlTemplate = new UrlTemplate(template); return path -> { UrlTemplate.Match match = urlTemplate.match(path); if (match == null) { return null; }/* www.j a v a 2 s . c om*/ ImmutableSet.Builder<Object> args = ImmutableSet.builder(); args.add(pipeline); args.add(allSessions); args.add(json); if (match.getParameters().containsKey("sessionId")) { SessionId id = new SessionId(match.getParameters().get("sessionId")); args.add(id); ActiveSession session = allSessions.get(id); if (session != null) { args.add(session); args.add(session.getFileSystem()); } } match.getParameters().entrySet().stream().filter(e -> !"sessionId".equals(e.getKey())) .forEach(e -> args.add(e.getValue())); return create(handler, args.build()); }; }