List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:com.tngtech.archunit.library.plantuml.JavaClassDiagramAssociation.java
Set<String> getTargetPackageIdentifiers(final JavaClass javaClass) { ImmutableSet.Builder<String> result = ImmutableSet.builder(); for (PlantUmlComponent target : getComponentOf(javaClass).getDependencies()) { result.addAll(getPackageIdentifiersFromComponentOf(target)); }/* www . j av a 2s . com*/ return result.build(); }
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);/*from w ww . j a va 2 s . c om*/ return new DefaultCompositeGradleBuild(builds.build()); }
From source file:org.apache.cassandra.utils.DirectorySizeCalculator.java
public void rebuildFileList() { assert path != null; ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (File file : path.listFiles()) builder.add(file.getName());// w ww. j av a 2s .co m size.set(0); alive = builder.build(); }
From source file:org.eclipse.tracecompass.analysis.os.linux.core.tests.stubs.trace.TmfXmlKernelTraceStub.java
@Override public Iterable<ITmfEventAspect<?>> getEventAspects() { /*//w ww .jav a 2 s . c o 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.openqa.selenium.remote.server.commandhandler.GetLogTypes.java
@Override public void execute(HttpRequest req, HttpResponse resp) throws IOException { // Try going upstream first. It's okay if this fails. HttpRequest upReq = new HttpRequest(GET, String.format("/session/%s/log/types", session.getId())); HttpResponse upRes = new HttpResponse(); session.execute(upReq, upRes);/*from w w w. ja v a 2 s . c om*/ ImmutableSet.Builder<String> types = ImmutableSet.builder(); types.add(LogType.SERVER); if (upRes.getStatus() == HTTP_OK) { Map<?, ?> upstream = json.toType(upRes.getContentString(), Json.MAP_TYPE); Object raw = upstream.get("value"); if (raw instanceof Collection) { ((Collection<?>) raw).stream().map(String::valueOf).forEach(types::add); } } Response response = new Response(session.getId()); response.setValue(types.build()); response.setStatus(ErrorCodes.SUCCESS); session.getDownstreamDialect().getResponseCodec().encode(() -> resp, response); }
From source file:com.facebook.buck.tools.dxanalysis.StaticStateAnalyzer.java
private void go() { ImmutableSet.Builder<String> unsafeClassesBuilder = ImmutableSet.builder(); for (ClassNode klass : allClasses.values()) { boolean classIsSafe = isClassSafe(klass); if (!classIsSafe) { unsafeClassesBuilder.add(klass.name); }/* w ww . j a v a 2 s.c om*/ } unsafeClasses = unsafeClassesBuilder.build(); }
From source file:at.ac.univie.isc.asio.security.ExpandAuthoritiesContainer.java
/** * Map all {@link org.springframework.security.core.authority.GrantedAuthoritiesContainer authority container} * to themselves and their contained authorities. * Only first level members are expanded, i.e. nested containers are not supported. * * @param authorities source authorities * @return authorities plus all contained ones *///ww w. jav a2 s . c o m @Override public Set<GrantedAuthority> mapAuthorities(final Collection<? extends GrantedAuthority> authorities) { final ImmutableSet.Builder<GrantedAuthority> mapped = ImmutableSet.builder(); mapped.addAll(authorities); for (final GrantedAuthoritiesContainer container : Iterables.filter(authorities, GrantedAuthoritiesContainer.class)) { for (final GrantedAuthority each : container.getGrantedAuthorities()) { mapped.add(each); } } final ImmutableSet<GrantedAuthority> result = mapped.build(); log.debug("mapped source authority containers {} to contained authorities {}", authorities, result); return result; }
From source file:com.textocat.textokit.commons.cas.FSUtils.java
public static Set<String> toSet(StringArrayFS fsArr) { if (fsArr == null) return ImmutableSet.of(); ImmutableSet.Builder<String> resultBuilder = ImmutableSet.builder(); for (int i = 0; i < fsArr.size(); i++) { resultBuilder.add(fsArr.get(i)); }/* w w w . j a v a 2 s. co m*/ return resultBuilder.build(); }
From source file:org.codice.ddf.admin.common.fields.common.DirectoryField.java
@Override public Set<String> getErrorCodes() { return new ImmutableSet.Builder<String>().addAll(super.getErrorCodes()).add(DIRECTORY_DOES_NOT_EXIST) .build();/*w ww . java 2 s .c o m*/ }
From source file:com.github.nmorel.gwtjackson.guava.client.deser.ImmutableSetJsonDeserializer.java
@Override protected ImmutableSet<T> doDeserialize(JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params) { try {//w w w. j a va 2 s . c om currentBuilder = ImmutableSet.builder(); buildCollection(reader, ctx, params); return currentBuilder.build(); } finally { currentBuilder = null; } }