本文整理汇总了Java中com.google.common.collect.Iterables.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.addAll方法的具体用法?Java Iterables.addAll怎么用?Java Iterables.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterables
的用法示例。
在下文中一共展示了Iterables.addAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectImplementedViews
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static <T, D> Set<ModelType<?>> collectImplementedViews(ModelType<T> publicType, Iterable<? extends ModelType<?>> internalViewTypes, ModelType<D> delegateType) {
final Set<ModelType<?>> viewsToImplement = Sets.newLinkedHashSet();
viewsToImplement.add(publicType);
Iterables.addAll(viewsToImplement, internalViewTypes);
// TODO:LPTR This should be removed once BinaryContainer is a ModelMap
// We need to also implement all the interfaces of the delegate type because otherwise
// BinaryContainer won't recognize managed binaries as BinarySpecInternal
if (delegateType != null) {
walkTypeHierarchy(delegateType.getConcreteClass(), new TypeVisitor<D>() {
@Override
public void visitType(Class<? super D> type) {
if (type.isInterface()) {
viewsToImplement.add(ModelType.of(type));
}
}
});
}
return ModelTypes.collectHierarchy(viewsToImplement);
}
示例2: getSql
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* @return the sql
*/
public List<String> getSql() {
List<String> results = Lists.newLinkedList();
if (!sql.isEmpty() || !upgradeScriptAdditions.isEmpty())
results.addAll(initialisationSql);
results.addAll(sql);
for (UpgradeScriptAddition addition : upgradeScriptAdditions) {
Iterables.addAll(results, addition.sql());
}
if (!results.isEmpty())
results.addAll(finalisationSql);
return Collections.unmodifiableList(results);
}
示例3: match
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public void match(Platform platform, boolean requeueOnFailure, Function<Operation, Boolean> onMatch) {
synchronized(queuedOperations) {
ImmutableList.Builder<Operation> rejectedOperations = new ImmutableList.Builder<Operation>();
boolean matched = false;
while (!matched && !queuedOperations.isEmpty()) {
Operation operation = queuedOperations.remove(0);
if (satisfiesRequirements(platform, operation)) {
matched = true;
if (onMatch.apply(operation)) {
onDispatched(operation);
} else if (!requeueOnFailure) {
rejectedOperations.add(operation);
}
} else {
rejectedOperations.add(operation);
}
}
Iterables.addAll(queuedOperations, rejectedOperations.build());
if (!matched) {
synchronized(workers) {
workers.add(new Worker(platform, onMatch));
}
}
}
}
示例4: matchOperation
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
protected boolean matchOperation(Operation operation) {
ImmutableList.Builder<Worker> rejectedWorkers = new ImmutableList.Builder<>();
boolean dispatched = false;
synchronized(workers) {
while (!dispatched && !workers.isEmpty()) {
Worker worker = workers.remove(0);
if (!satisfiesRequirements(worker.getPlatform(), operation)) {
rejectedWorkers.add(worker);
} else {
// worker onMatch false return indicates inviability
if (dispatched = worker.apply(operation)) {
onDispatched(operation);
}
}
}
Iterables.addAll(workers, rejectedWorkers.build());
}
return dispatched;
}
示例5: getGeneratorMarkers
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
protected Map<OutputConfiguration, Iterable<IMarker>> getGeneratorMarkers(IProject builtProject,
Collection<OutputConfiguration> outputConfigurations) throws CoreException {
if (builtProject instanceof ExternalProject) {
return emptyMap();
}
Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = newHashMap();
for (OutputConfiguration config : outputConfigurations) {
if (config.isCleanUpDerivedResources()) {
List<IMarker> markers = Lists.newArrayList();
for (IContainer container : getOutputs(builtProject, config)) {
Iterables.addAll(
markers,
getDerivedResourceMarkers().findDerivedResourceMarkers(container,
getGeneratorIdProvider().getGeneratorIdentifier()));
}
generatorMarkers.put(config, markers);
}
}
return generatorMarkers;
}
示例6: pushUnsatisfiedDependencies
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void pushUnsatisfiedDependencies(Iterable<? extends DefaultModelSchemaExtractionContext<?>> allDependencies, Queue<DefaultModelSchemaExtractionContext<?>> dependencyQueue, final ModelSchemaCache cache) {
Iterables.addAll(dependencyQueue, Iterables.filter(allDependencies, new Predicate<ModelSchemaExtractionContext<?>>() {
public boolean apply(ModelSchemaExtractionContext<?> dependency) {
return cache.get(dependency.getType()) == null;
}
}));
}
示例7: collectHierarchy
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* Collect all types that make up the type hierarchy of the given types.
*/
public static Set<ModelType<?>> collectHierarchy(Iterable<? extends ModelType<?>> types) {
Queue<ModelType<?>> queue = new ArrayDeque<ModelType<?>>(Iterables.size(types) * 2);
Iterables.addAll(queue, types);
Set<ModelType<?>> seenTypes = Sets.newLinkedHashSet();
ModelType<?> type;
while ((type = queue.poll()) != null) {
// Do not process Object's or GroovyObject's methods
Class<?> rawClass = type.getRawClass();
if (rawClass.equals(Object.class) || rawClass.equals(GroovyObject.class)) {
continue;
}
// Do not reprocess
if (!seenTypes.add(type)) {
continue;
}
Class<?> superclass = rawClass.getSuperclass();
if (superclass != null) {
ModelType<?> superType = ModelType.of(superclass);
if (!seenTypes.contains(superType)) {
queue.add(superType);
}
}
for (Class<?> iface : rawClass.getInterfaces()) {
ModelType<?> ifaceType = ModelType.of(iface);
if (!seenTypes.contains(ifaceType)) {
queue.add(ifaceType);
}
}
}
return seenTypes;
}
示例8: shardsWithState
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public List<ShardRouting> shardsWithState(ShardRoutingState... state) {
// TODO these are used on tests only - move into utils class
List<ShardRouting> shards = new ArrayList<>();
for (RoutingNode routingNode : this) {
shards.addAll(routingNode.shardsWithState(state));
}
for (ShardRoutingState s : state) {
if (s == ShardRoutingState.UNASSIGNED) {
Iterables.addAll(shards, unassigned());
break;
}
}
return shards;
}
示例9: getAllAnnotations
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Annotation> getAllAnnotations() {
final BasicEList<Annotation> result = XcoreCollectionLiterals.<Annotation>newBasicEList();
final EObject parent = this.eContainer();
if ((parent instanceof ExportDeclaration)) {
EList<Annotation> _annotations = ((ExportDeclaration)parent).getAnnotations();
Iterables.<Annotation>addAll(result, _annotations);
}
EList<Annotation> _annotations_1 = this.getAnnotations();
Iterables.<Annotation>addAll(result, _annotations_1);
return result;
}
示例10: newVmCommandBuilder
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override public VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory) {
List<String> vmCommand = new ArrayList<String>();
vmCommand.addAll(run.target.targetProcessPrefix(workingDirectory));
vmCommand.add(run.getAndroidData());
Iterables.addAll(vmCommand, run.invokeWith());
vmCommand.add(run.vmCommand);
// If you edit this, see also HostRuntime...
VmCommandBuilder vmCommandBuilder = new VmCommandBuilder(run.log)
.vmCommand(vmCommand)
.vmArgs("-Duser.home=" + run.deviceUserHome)
.maxLength(1024);
if (modeId == ModeId.APP_PROCESS) {
return vmCommandBuilder
.vmArgs(action.getUserDir().getPath())
.classpathViaProperty(true);
}
vmCommandBuilder
.vmArgs("-Duser.name=" + run.target.getDeviceUserName())
.vmArgs("-Duser.language=en")
.vmArgs("-Duser.region=US");
if (modeId == ModeId.DEVICE_ART_KITKAT) {
// Required for KitKat to select the ART runtime. Default is Dalvik.
vmCommandBuilder.vmArgs("-XXlib:libart.so");
}
if (!run.benchmark) {
vmCommandBuilder.vmArgs("-Xverify:none");
vmCommandBuilder.vmArgs("-Xdexopt:none");
vmCommandBuilder.vmArgs("-Xcheck:jni");
}
// dalvikvm defaults to no limit, but the framework sets the limit at 2000.
vmCommandBuilder.vmArgs("-Xjnigreflimit:2000");
return vmCommandBuilder;
}
示例11: updateOperationWatchers
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
protected void updateOperationWatchers(Operation operation) {
synchronized(watchers) {
List<Function<Operation, Boolean>> operationWatchers =
watchers.get(operation.getName());
if (operationWatchers != null) {
if (operation.getDone()) {
watchers.remove(operation.getName());
}
long unfilteredWatcherCount = operationWatchers.size();
super.updateOperationWatchers(operation);
ImmutableList.Builder<Function<Operation, Boolean>> filteredWatchers = new ImmutableList.Builder<>();
long filteredWatcherCount = 0;
for (Function<Operation, Boolean> watcher : operationWatchers) {
if (watcher.apply(operation)) {
filteredWatchers.add(watcher);
filteredWatcherCount++;
}
}
if (!operation.getDone() && filteredWatcherCount != unfilteredWatcherCount) {
operationWatchers = new ArrayList<>();
Iterables.addAll(operationWatchers, filteredWatchers.build());
watchers.put(operation.getName(), operationWatchers);
}
} else {
throw new IllegalStateException();
}
}
}
示例12: getInputs
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public Iterable<NodeDef> getInputs(String name, String... ops){
NodeDef nodeDef = getNodeDef(name);
Collection<Trail> trails = new LinkedHashSet<>();
collectInputs(new ArrayDeque<>(), nodeDef, new HashSet<>(Arrays.asList(ops)), trails);
Function<Trail, NodeDef> function = new Function<Trail, NodeDef>(){
@Override
public NodeDef apply(Trail trail){
return trail.getNodeDef();
}
};
Collection<NodeDef> inputs = new LinkedHashSet<>();
Iterables.addAll(inputs, Iterables.transform(trails, function));
return inputs;
}
示例13: write
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
public void write(Iterable<OFMessage> msglist) {
Iterables.addAll(messages, msglist);
}
示例14: lookupProfiles
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Nonnull
@Override
public Promise<Map<UUID, Profile>> lookupProfiles(@Nonnull Iterable<UUID> uniqueIds) {
Set<UUID> toFind = new HashSet<>();
Iterables.addAll(toFind, uniqueIds);
Map<UUID, Profile> ret = new HashMap<>();
for (Iterator<UUID> iterator = toFind.iterator(); iterator.hasNext(); ) {
UUID u = iterator.next();
Profile profile = getProfile(u);
if (profile.getName().isPresent()) {
ret.put(u, profile);
iterator.remove();
}
}
StringBuilder sb = new StringBuilder("(");
boolean first = true;
for (UUID uniqueId : toFind) {
if (uniqueId == null) {
continue;
}
if (!first) {
sb.append(", ");
}
sb.append("UNHEX(`").append(UuidUtils.toString(uniqueId)).append("`)");
first = false;
}
if (first) {
return Promise.completed(ret);
}
sb.append(")");
return Scheduler.supplyAsync(() -> {
try (Connection c = sql.getConnection()) {
try (Statement s = c.createStatement()) {
try (ResultSet rs = s.executeQuery(replaceTableName(String.format(SELECT_ALL_UIDS, sb.toString())))) {
while (rs.next()) {
String name = rs.getString("name");
Timestamp lastUpdate = rs.getTimestamp("lastupdate");
String uuidString = rs.getString("canonicalid");
UUID uuid = UuidUtils.fromString(uuidString);
ImmutableProfile p = new ImmutableProfile(uuid, name, lastUpdate.getTime());
updateCache(p);
ret.put(uuid, p);
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return ret;
});
}
示例15: visitParquetScanPrel
import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private PrelWithDictionaryInfo visitParquetScanPrel(ParquetScanPrel parquetScanPrel, Void value) throws RuntimeException {
final ReadDefinition readDefinition = parquetScanPrel.getTableMetadata().getReadDefinition();
if (readDefinition == null || readDefinition.getExtendedProperty() == null) {
return new PrelWithDictionaryInfo(parquetScanPrel);
}
// Make sure we don't apply global dictionary on columns that have conditions pushed into the scan
final Set<String> columnsPushedToScan = new HashSet<>();
if (parquetScanPrel.getConditions() != null) {
Iterables.addAll(columnsPushedToScan, Iterables.transform(parquetScanPrel.getConditions(), FilterCondition.EXTRACT_COLUMN_NAME));
}
final Map<String, String> dictionaryEncodedColumnsToDictionaryFilePath = Maps.newHashMap();
long dictionaryVersion = -1;
final ParquetDatasetXAttr xAttr = ParquetDatasetXAttrSerDe.PARQUET_DATASET_XATTR_SERIALIZER.revert(
readDefinition.getExtendedProperty().toByteArray());
final DictionaryEncodedColumns dictionaryEncodedColumns = xAttr.getDictionaryEncodedColumns();
if (dictionaryEncodedColumns != null) {
dictionaryVersion = dictionaryEncodedColumns.getVersion();
// Construct paths to dictionary files based on the version found in namespace. Do NOT look for files during planning.
final Path dictionaryRootPath = new Path(dictionaryEncodedColumns.getRootPath());
for (String dictionaryEncodedColumn : dictionaryEncodedColumns.getColumnsList()) {
if (!columnsPushedToScan.contains(dictionaryEncodedColumn)) {
dictionaryEncodedColumnsToDictionaryFilePath.put(dictionaryEncodedColumn,
GlobalDictionaryBuilder.dictionaryFilePath(dictionaryRootPath, dictionaryEncodedColumn).toString());
}
}
}
if (dictionaryEncodedColumnsToDictionaryFilePath.isEmpty()) {
return new PrelWithDictionaryInfo(parquetScanPrel);
}
final StoragePluginId storagePluginId = parquetScanPrel.getPluginId();
boolean encodedColumns = false;
final List<RelDataTypeField> newFields = Lists.newArrayList();
final GlobalDictionaryFieldInfo[] fieldInfos = new GlobalDictionaryFieldInfo[parquetScanPrel.getRowType().getFieldCount()];
final List<GlobalDictionaryFieldInfo> globalDictionaryColumns = Lists.newArrayList();
for (int i = 0; i < parquetScanPrel.getRowType().getFieldCount(); ++i) {
final RelDataTypeField field = parquetScanPrel.getRowType().getFieldList().get(i);
if (dictionaryEncodedColumnsToDictionaryFilePath.containsKey(field.getName())) {
fieldInfos[i] = new GlobalDictionaryFieldInfo(
dictionaryVersion,
field.getName(),
storagePluginId,
CompleteType.fromMinorType(TypeInferenceUtils.getMinorTypeFromCalciteType(field.getType())).getType(),
dictionaryEncodedColumnsToDictionaryFilePath.get(field.getName()),
new RelDataTypeFieldImpl(field.getName(), field.getIndex(), field.getType()));
newFields.add(dictionaryEncodedField(field));
globalDictionaryColumns.add(fieldInfos[i]);
encodedColumns = true;
} else {
fieldInfos[i] = null;
newFields.add(field);
}
}
if (!encodedColumns) {
return new PrelWithDictionaryInfo(parquetScanPrel);
}
final RelDataType newRelDataType = PrelWithDictionaryInfo.toRowDataType(newFields, parquetScanPrel.getCluster().getTypeFactory());
final ParquetScanPrel newParquetScanPrel = parquetScanPrel.cloneWithGlobalDictionaryColumns(globalDictionaryColumns, newRelDataType);
return new PrelWithDictionaryInfo(newParquetScanPrel, fieldInfos);
}