List of usage examples for com.google.common.collect Iterables addAll
public static <T> boolean addAll(Collection<T> addTo, Iterable<? extends T> elementsToAdd)
From source file:org.geogit.storage.sqlite.SQLiteGraphDatabase.java
@Override public int getDepth(ObjectId commitId) { int depth = 0; Queue<String> q = Lists.newLinkedList(); Iterables.addAll(q, outgoing(commitId.toString(), cx)); List<String> next = Lists.newArrayList(); while (!q.isEmpty()) { depth++;/* ww w . j a va 2s . com*/ while (!q.isEmpty()) { String n = q.poll(); List<String> parents = Lists.newArrayList(outgoing(n, cx)); if (parents.size() == 0) { return depth; } Iterables.addAll(next, parents); } q.addAll(next); next.clear(); } return depth; }
From source file:dk.ilios.spanner.model.Trial.java
public void addAllMessages(Iterable<String> messages) { checkIsComplete(); Iterables.addAll(this.messages, messages); }
From source file:org.obm.domain.dao.UserPatternDaoJdbcImpl.java
@VisibleForTesting Set<String> getUserPatterns(ObmUser user) { Set<String> patterns = Sets.newTreeSet(); patterns.add(user.getLogin());/*w w w. ja v a 2s. com*/ if (user.getLastName() != null) { Iterables.addAll(patterns, splitWords(user.getLastName())); } if (user.getFirstName() != null) { Iterables.addAll(patterns, splitWords(user.getFirstName())); } if (user.isEmailAvailable()) { patterns.add(user.getEmail()); patterns.addAll(user.getEmailAlias()); } return patterns; }
From source file:org.eclipse.reqcycle.ocl.utils.OCLUtilities.java
public static Collection<DefOperationCS> getOperations(BaseResource resource) { Collection<DefOperationCS> result = Lists.newArrayList(); EList<EObject> contents = resource.getContents(); if (contents.size() == 1) { EObject root = contents.get(0);//from w w w . j a v a 2 s . c om if (root instanceof CompleteOCLDocumentCS) { EList<ContextDeclCS> contexts = ((CompleteOCLDocumentCS) root).getContexts(); for (ContextDeclCS context : contexts) { if (context instanceof ClassifierContextDeclCS) { EList<DefCS> definitions = ((ClassifierContextDeclCS) context).getDefinitions(); Iterables.addAll(result, Iterables.filter(definitions, DefOperationCS.class)); } } } } return result; }
From source file:com.zimbra.soap.admin.message.AdminWaitSetResponse.java
public void setErrors(Iterable<IdAndType> errors) { this.errors.clear(); if (errors != null) { Iterables.addAll(this.errors, errors); }/*from w w w .j a v a 2 s.c o m*/ }
From source file:me.taylorkelly.mywarp.warp.WarpBuilder.java
/** * Adds each player to the set of players invited to the {@code Warp}. * * @param players the Iterable of player profiles * @return this {@code WarpBuilder}//from w w w. ja v a 2s. co m */ public WarpBuilder addInvitedPlayers(Iterable<Profile> players) { Iterables.addAll(invitedPlayers, players); return this; }
From source file:org.semanticweb.owlapi.OWLAPIServiceLoaderModule.java
/** * @param type//from w ww . j av a 2s . com * type to load * @param <T> * return type * @return itrable over T implementations */ protected <T> Iterable<T> load(Class<T> type) { // J2EE compatible search Collection<T> result = new HashSet<>(); try { Iterables.addAll(result, ServiceLoader.load(type)); } catch (ServiceConfigurationError e) { logger.debug("ServiceLoading: ", e); } // in OSGi, the context class loader is likely null. // This would trigger the use of the system class loader, which would // not see the OWLAPI jar, nor any other jar containing implementations. // In that case, use this class classloader to load, at a minimum, the // services provided by the OWLAPI jar itself. if (result.isEmpty()) { ClassLoader classLoader = getClass().getClassLoader(); Iterables.addAll(result, ServiceLoader.load(type, classLoader)); } return result; }
From source file:com.zimbra.soap.mail.type.InviteInfo.java
public void setCalendarReplies(Iterable<CalendarReply> calendarReplies) { this.calendarReplies.clear(); if (calendarReplies != null) { Iterables.addAll(this.calendarReplies, calendarReplies); }//w w w . j a v a2 s. c om }
From source file:com.google.devtools.build.lib.rules.cpp.DiscoveredSourceInputsHelper.java
/** * Converts ActionInputs discovered as inputs during execution into source Artifacts, ignoring any * that are already in mandatoryInputs or that live in builtInIncludeDirectories. If any * ActionInputs cannot be resolved, an ActionExecutionException will be thrown. * * <p>This method duplicates the functionality of CppCompileAction#populateActionInputs, though it * is simpler because it need not deal with derived artifacts and doesn't parse the .d file. *//*from www . j av a2 s.c om*/ public static ImmutableList<Artifact> getDiscoveredInputsFromActionInputs(Iterable<Artifact> mandatoryInputs, ArtifactResolver artifactResolver, Iterable<? extends ActionInput> discoveredInputs, Iterable<PathFragment> builtInIncludeDirectories, Action action, Artifact primaryInput) throws ActionExecutionException { List<PathFragment> systemIncludePrefixes = new ArrayList<>(); for (PathFragment includePath : builtInIncludeDirectories) { if (includePath.isAbsolute()) { systemIncludePrefixes.add(includePath); } } // Avoid duplicates by keeping track of the ones we've seen so far, even though duplicates are // unlikely, since they would have to be inputs to this (non-CppCompile) action and also // #included by a C++ source file. Set<Artifact> knownInputs = new HashSet<>(); Iterables.addAll(knownInputs, mandatoryInputs); ImmutableList.Builder<Artifact> foundInputs = ImmutableList.builder(); // Check inclusions. IncludeProblems problems = new IncludeProblems(); for (ActionInput input : discoveredInputs) { if (input instanceof Artifact) { Artifact artifact = (Artifact) input; if (knownInputs.add(artifact)) { foundInputs.add(artifact); } continue; } PathFragment execPath = new PathFragment(input.getExecPathString()); if (execPath.isAbsolute()) { // Absolute includes from system paths are ignored. if (FileSystemUtils.startsWithAny(execPath, systemIncludePrefixes)) { continue; } // Theoretically, the more sophisticated logic of CppCompileAction#populateActioInputs could // be used here, to allow absolute includes that started with the execRoot. However, since // we don't hit this codepath for local execution, that should be unnecessary. If and when // we examine the results of local execution for scanned includes, that case may need to be // dealt with. problems.add(execPath.getPathString()); } Artifact artifact = artifactResolver.resolveSourceArtifact(execPath); if (artifact != null) { if (knownInputs.add(artifact)) { foundInputs.add(artifact); } } else { // Abort if we see files that we can't resolve, likely caused by // undeclared includes or illegal include constructs. problems.add(execPath.getPathString()); } } problems.assertProblemFree(action, primaryInput); return foundInputs.build(); }
From source file:com.zimbra.soap.mail.type.ContactSpec.java
public void setAttrs(Iterable<NewContactAttr> attrs) { this.attrs.clear(); if (attrs != null) { Iterables.addAll(this.attrs, attrs); }/*from w w w. ja v a2 s.co m*/ }