本文整理汇总了Java中com.google.common.collect.Iterables.concat方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.concat方法的具体用法?Java Iterables.concat怎么用?Java Iterables.concat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectDependencies
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static List<DependencySpec> collectDependencies(final BinarySpec binary, @Nullable final SourceComponentSpec owner, final Collection<DependencySpec>... specificDependencies) {
List<DependencySpec> dependencies = Lists.newArrayList();
if (specificDependencies!=null) {
for (Collection<DependencySpec> deps : specificDependencies) {
dependencies.addAll(deps);
}
}
Collection<LanguageSourceSet> binarySources = binary.getSources().values();
Iterable<LanguageSourceSet> sourceSets = owner != null ? Iterables.concat(owner.getSources().values(), binarySources) : binarySources;
for (LanguageSourceSet sourceSet : sourceSets) {
if (sourceSet instanceof DependentSourceSet) {
dependencies.addAll(((DependentSourceSet) sourceSet).getDependencies().getDependencies());
}
}
return dependencies;
}
示例2: ideaConfigurations
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Iterable<Configuration> ideaConfigurations(final IdeaModule ideaModule) {
Set<Configuration> configurations = Sets.newLinkedHashSet(ideaModule.getProject().getConfigurations());
for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) {
for (Configuration cfg : Iterables.concat(scopeMap.values())) {
configurations.add(cfg);
}
}
return Iterables.filter(
configurations,
new Predicate<Configuration>() {
@Override
public boolean apply(Configuration input) {
return isMappedToIdeaScope(input, ideaModule);
}
});
}
示例3: getAllAnnotations
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* @param element the element
* @return all annotations on the element and on the type of the element
*/
public static Iterable<? extends AnnotationMirror> getAllAnnotations(Element element) {
// for methods, we care about annotations on the return type, not on the method type itself
TypeMirror typeMirror =
element instanceof Symbol.MethodSymbol
? ((Symbol.MethodSymbol) element).getReturnType()
: element.asType();
return Iterables.concat(element.getAnnotationMirrors(), typeMirror.getAnnotationMirrors());
}
示例4: concat
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Return the concatenation of the {@link Iterables} in the given {@link Collection}.
*
* Result is equivalent to {@link Iterables#concat}, but there are some optimizations
* for the cases where size == 0 and size == 1.
*/
public static <T> Iterable<T> concat(Collection<? extends Iterable<? extends T>> iterables) {
switch(iterables.size()) {
case 0: return emptyIterable();
case 1: return (Iterable<T>) getFirst(iterables);
default: return Iterables.concat(iterables);
}
}
示例5: unify
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private ClassFileSource unify(final List<ClassFileSource> sources) {
final Iterable<ClassFileLocation> concatenatedStreams = Iterables.concat(sources);
return new ClassFileSource() {
@Override
public Iterator<ClassFileLocation> iterator() {
return concatenatedStreams.iterator();
}
};
}
示例6: successfulSplitCRLF
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Test
public void successfulSplitCRLF() throws Exception {
final NewlineChunkSplitter splitter = new NewlineChunkSplitter();
final String logLines = "Feb 20 17:05:18 otter kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=32696[GoogleSoftwareUp] final status 0x0, allow (remove VALID)ing page\r\n" +
"Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KeystoneDaemon logServiceState] GoogleSoftwareUpdate daemon (1.1.0.3659) vending:\r\n" +
"Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KSUpdateEngine updateProductID:] KSUpdateEngine updating product ID: \"com.google.Keystone\"\r\n";
final ByteBuf buffer = Unpooled.copiedBuffer(logLines, UTF_8);
final Iterable<String> firstTwoChunks = splitter.split(buffer, UTF_8);
final Iterable<String> remainingChunk = splitter.splitRemaining(buffer, UTF_8);
int messageNum = 0;
for (String chunk : Iterables.concat(firstTwoChunks, remainingChunk)) {
switch (++messageNum) {
case 1:
assertEquals("Feb 20 17:05:18 otter kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=32696[GoogleSoftwareUp] final status 0x0, allow (remove VALID)ing page", chunk);
break;
case 2:
assertEquals("Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KeystoneDaemon logServiceState] GoogleSoftwareUpdate daemon (1.1.0.3659) vending:", chunk);
break;
case 3:
assertEquals("Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KSUpdateEngine updateProductID:] KSUpdateEngine updating product ID: \"com.google.Keystone\"", chunk);
break;
}
}
assertEquals("the last chunk should have triggered a message (no follow mode active)", 3, messageNum);
}
示例7: merge
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public BlankLineWanted merge(BlankLineWanted other) {
if (!(other instanceof ConditionalBlankLine)) {
return other;
}
return new ConditionalBlankLine(
Iterables.concat(this.tags, ((ConditionalBlankLine) other).tags));
}
示例8: get
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public Iterable<? extends File> get() {
Variant variant = buildConfig.getCurrentVariant();
if (variant != null) {
AndroidArtifact testArtifact = AndroidBuildVariants.instrumentTestArtifact(variant.getExtraAndroidArtifacts());
Iterable<File> testCompileCPEntries
= Collections.<File>singleton(variant.getMainArtifact().getClassesFolder());
if (testArtifact != null) {
List<File> javaLibs = new ArrayList<>();
for (JavaLibrary lib : testArtifact.getDependencies().getJavaLibraries()) {
collectJavaLibraries(javaLibs, lib);
}
testCompileCPEntries = Iterables.concat(
testCompileCPEntries,
Iterables.transform(
testArtifact.getDependencies().getLibraries(),
new Function<AndroidLibrary, File>() {
@Override
public File apply(AndroidLibrary f) {
return f.getJarFile();
}
}),
javaLibs);
}
return testCompileCPEntries;
}
return Collections.<File>emptyList();
}
示例9: collectInstanceDataNodeContainers
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Collects Instance DataNode Containers.
* @param potentialSchemaNodes - A list of possible DataSchemaNode values
* @param container - DataNodeContainer
* @param name - the Name of the data node
*/
private static void collectInstanceDataNodeContainers(final List<DataSchemaNode> potentialSchemaNodes,
final DataNodeContainer container, final String name) {
final Predicate<DataSchemaNode> filter = new Predicate<DataSchemaNode>() {
@Override
public boolean apply(final DataSchemaNode node) {
return Objects.equal(node.getQName().getLocalName(), name);
}
};
final Iterable<DataSchemaNode> nodes = Iterables.filter(container.getChildNodes(), filter);
// Can't combine this loop with the filter above because the filter is
// lazily-applied by Iterables.filter.
for (final DataSchemaNode potentialNode : nodes) {
if (isInstantiatedDataSchema(potentialNode)) {
potentialSchemaNodes.add(potentialNode);
}
}
final Iterable<ChoiceSchemaNode> choiceNodes = Iterables.filter(container.getChildNodes(), ChoiceSchemaNode.class);
final Iterable<Set<ChoiceCaseNode>> map = Iterables.transform(choiceNodes, CHOICE_FUNCTION);
final Iterable<ChoiceCaseNode> allCases = Iterables.<ChoiceCaseNode> concat(map);
for (final ChoiceCaseNode caze : allCases) {
collectInstanceDataNodeContainers(potentialSchemaNodes, caze, name);
}
}
示例10: DefaultTaskClassValidatorExtractor
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public DefaultTaskClassValidatorExtractor(Iterable<? extends PropertyAnnotationHandler> customAnnotationHandlers) {
Iterable<PropertyAnnotationHandler> allAnnotationHandlers = Iterables.concat(HANDLERS, customAnnotationHandlers);
this.annotationHandlers = Maps.uniqueIndex(allAnnotationHandlers, new Function<PropertyAnnotationHandler, Class<? extends Annotation>>() {
@Override
public Class<? extends Annotation> apply(PropertyAnnotationHandler handler) {
return handler.getAnnotationType();
}
});
this.annotationOverrides = collectAnnotationOverrides(allAnnotationHandlers);
}
示例11: members
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Iterable<TMember> members(int source) {
return hasSource(source) ? Iterables.concat(members(
source, GETTER),
members(source, SETTER),
members(source, FIELD),
members(source, METHOD)) : MemberList.emptyList();
}
示例12: getGroupNames
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Returns the names of all counter classes.
* @return Set of counter names.
*/
public synchronized Iterable<String> getGroupNames() {
HashSet<String> deprecated = new HashSet<String>();
for(Map.Entry<String, String> entry : legacyMap.entrySet()) {
String newGroup = entry.getValue();
boolean isFGroup = isFrameworkGroup(newGroup);
if(isFGroup ? fgroups.containsKey(newGroup) : groups.containsKey(newGroup)) {
deprecated.add(entry.getKey());
}
}
return Iterables.concat(fgroups.keySet(), groups.keySet(), deprecated);
}
示例13: successfulSplit
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Test
public void successfulSplit() {
final PatternChunkSplitter splitter = new PatternChunkSplitter("^(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)");
String logLines = "Feb 20 17:05:18 otter kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=32696[GoogleSoftwareUp] final status 0x0, allow (remove VALID)ing page\n" +
"Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KeystoneDaemon logServiceState] GoogleSoftwareUpdate daemon (1.1.0.3659) vending:\n" +
"\t\tcom.google.Keystone.Daemon.UpdateEngine: 2 connection(s)\n" +
"\t\tcom.google.Keystone.Daemon.Administration: 0 connection(s)\n" +
"Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KSUpdateEngine updateProductID:] KSUpdateEngine updating product ID: \"com.google.Keystone\"\n";
final ByteBuf buffer = Unpooled.copiedBuffer(logLines, UTF_8);
final Iterable<String> firstTwoChunks = splitter.split(buffer, UTF_8);
final Iterable<String> remainingChunk = splitter.splitRemaining(buffer, UTF_8);
int messageNum = 0;
for (String chunk : Iterables.concat(firstTwoChunks, remainingChunk)) {
switch (++messageNum) {
case 1:
assertEquals("Feb 20 17:05:18 otter kernel[0]: CODE SIGNING: cs_invalid_page(0x1000): p=32696[GoogleSoftwareUp] final status 0x0, allow (remove VALID)ing page\n", chunk);
break;
case 2:
assertEquals("Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KeystoneDaemon logServiceState] GoogleSoftwareUpdate daemon (1.1.0.3659) vending:\n" +
"\t\tcom.google.Keystone.Daemon.UpdateEngine: 2 connection(s)\n" +
"\t\tcom.google.Keystone.Daemon.Administration: 0 connection(s)\n",
chunk);
break;
case 3:
assertEquals("Feb 20 17:05:18 otter GoogleSoftwareUpdateDaemon[32697]: -[KSUpdateEngine updateProductID:] KSUpdateEngine updating product ID: \"com.google.Keystone\"\n", chunk);
break;
}
}
assertEquals("the last chunk should have triggered a message (no follow mode active)", 3, messageNum);
}
示例14: getFileStatuses
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Start executing and return FileStatuses based on the parameters specified
* @return fetched file statuses
* @throws InterruptedException
* @throws IOException
*/
public Iterable<FileStatus> getFileStatuses() throws InterruptedException,
IOException {
// Increment to make sure a race between the first thread completing and the
// rest being scheduled does not lead to a termination.
runningTasks.incrementAndGet();
for (Path p : inputDirs) {
runningTasks.incrementAndGet();
ListenableFuture<ProcessInitialInputPathCallable.Result> future = exec
.submit(new ProcessInitialInputPathCallable(p, conf, inputFilter));
Futures.addCallback(future, processInitialInputPathCallback);
}
runningTasks.decrementAndGet();
lock.lock();
try {
while (runningTasks.get() != 0 && unknownError == null) {
condition.await();
}
} finally {
lock.unlock();
}
this.exec.shutdownNow();
if (this.unknownError != null) {
if (this.unknownError instanceof Error) {
throw (Error) this.unknownError;
} else if (this.unknownError instanceof RuntimeException) {
throw (RuntimeException) this.unknownError;
} else if (this.unknownError instanceof IOException) {
throw (IOException) this.unknownError;
} else if (this.unknownError instanceof InterruptedException) {
throw (InterruptedException) this.unknownError;
} else {
throw new IOException(this.unknownError);
}
}
if (this.invalidInputErrors.size() != 0) {
if (this.newApi) {
throw new org.apache.hadoop.mapreduce.lib.input.InvalidInputException(
invalidInputErrors);
} else {
throw new InvalidInputException(invalidInputErrors);
}
}
return Iterables.concat(resultQueue);
}
示例15: configureSingle
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public StoragePluginConfig configureSingle(MongoConfig mongo) {
// Authority
StringBuilder connection = new StringBuilder("mongodb://");
if (AuthenticationType.MASTER.equals(mongo.getAuthenticationType())) {
String username = mongo.getUsername();
if (username != null) {
connection.append(urlEncode(username));
}
String password = mongo.getPassword();
if (password != null) {
connection.append(":").append(urlEncode(password));
}
connection.append("@");
// host list
appendHosts(connection, checkNotNull(mongo.getHostList(), "hostList missing"), ',').append("/");
final String database = mongo.getAuthDatabase();
if (database != null) {
connection.append(database);
}
} else {
// host list
appendHosts(connection, checkNotNull(mongo.getHostList(), "hostList missing"), ',').append("/");
}
// Query string
Iterable<Property> propertyList = checkNotNull(mongo.getUseSsl(), "useSSL missing")
? Iterables.concat(mongo.getPropertyList(), Collections.singleton(new Property().setName("ssl").setValue("true")))
: mongo.getPropertyList();
connection.append("?");
appendProperties(connection, checkNotNull(propertyList, "propertyList missing"), '=', '&');
// default 2s
int authTimeoutMillis = mongo.getAuthenticationTimeoutMillis() == null ? 2000 : mongo.getAuthenticationTimeoutMillis().intValue();
boolean secondaryReadsOnly = mongo.getSecondaryReadsOnly() == null ? false : mongo.getSecondaryReadsOnly().booleanValue();
// 0 means disabled
int subpartitionSize = mongo.getSubpartitionSize() == null ? 0 : mongo.getSubpartitionSize().intValue();
MongoStoragePluginConfig config = new MongoStoragePluginConfig(
authTimeoutMillis,
connection.toString(),
secondaryReadsOnly,
subpartitionSize
);
return config;
}