List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:org.openqa.selenium.BuckBuild.java
private Path findOutput(Path projectRoot) throws IOException { ImmutableList.Builder<String> builder = ImmutableList.builder(); findBuck(projectRoot, builder);//from w w w . j a v a 2 s .c om builder.add("targets", "--show-output", target); ImmutableList<String> command = builder.build(); CommandLine commandLine = new CommandLine(command.toArray(new String[command.size()])); commandLine.copyOutputTo(System.err); commandLine.execute(); if (!commandLine.isSuccessful()) { throw new WebDriverException("Unable to find output! " + target); } String[] allLines = commandLine.getStdOut().split(LINE_SEPARATOR.value()); String lastLine = null; for (String line : allLines) { if (line.startsWith(target)) { lastLine = line; break; } } Preconditions.checkNotNull(lastLine); List<String> outputs = Splitter.on(' ').limit(2).splitToList(lastLine); if (outputs.size() != 2) { throw new WebDriverException(String.format("Unable to find output! %s, %s", target, lastLine)); } Path output = projectRoot.resolve(outputs.get(1)); if (!Files.exists(output)) { throw new WebDriverException( String.format("Found output, but it does not exist: %s, %s", target, output)); } return output; }
From source file:org.gradle.internal.execution.history.impl.DefaultPreviousExecutionStateSerializer.java
public void write(Encoder encoder, AfterPreviousExecutionState execution) throws Exception { OriginMetadata originMetadata = execution.getOriginMetadata(); encoder.writeString(originMetadata.getBuildInvocationId().asString()); encoder.writeLong(originMetadata.getExecutionTime()); implementationSnapshotSerializer.write(encoder, execution.getImplementation()); ImmutableList<ImplementationSnapshot> additionalImplementations = execution.getAdditionalImplementations(); encoder.writeSmallInt(additionalImplementations.size()); for (ImplementationSnapshot actionImpl : additionalImplementations) { implementationSnapshotSerializer.write(encoder, actionImpl); }/*from w w w . j a v a 2 s.com*/ writeInputProperties(encoder, execution.getInputProperties()); writeFingerprints(encoder, execution.getInputFileProperties()); writeFingerprints(encoder, execution.getOutputFileProperties()); encoder.writeBoolean(execution.isSuccessful()); }
From source file:com.google.cloud.firestore.ResourcePath.java
/** * The Path's id (last component).// w w w. jav a2 s. c om * * @return The last component of the Path or null if the path points to the root. */ @Nullable String getId() { ImmutableList<String> parts = getSegments(); if (!parts.isEmpty()) { return parts.get(parts.size() - 1); } else { return null; } }
From source file:com.google.errorprone.bugpatterns.argumentselectiondefects.Costs.java
Costs(ImmutableList<Parameter> formals, ImmutableList<Parameter> actuals) { this.formals = formals; this.actuals = actuals; this.costMatrix = new double[formals.size()][actuals.size()]; }
From source file:com.opengamma.strata.pricer.calibration.SyntheticCurveCalibrator.java
/** * Constructs the synthetic market data from an existing rates provider and the configuration of the new curves. * //from w w w. ja va 2s .co m * @param inputMulticurve the input rates provider * @param group the curve group definition for the synthetic curves and instruments * @return the market data */ public MarketData marketData(RatesProvider inputMulticurve, CurveGroupDefinition group) { LocalDate valuationDate = inputMulticurve.getValuationDate(); ImmutableList<NodalCurveDefinition> curveGroups = group.getCurveDefinitions(); // Create fake market quotes of 0, only to be able to generate trades Map<MarketDataKey<?>, Double> mapKey0 = new HashMap<>(); for (NodalCurveDefinition entry : curveGroups) { ImmutableList<CurveNode> nodes = entry.getNodes(); for (int i = 0; i < nodes.size(); i++) { for (SimpleMarketDataKey<?> key : nodes.get(i).requirements()) { mapKey0.put(key, 0.0d); } } } ImmutableMarketData marketQuotes0 = ImmutableMarketData.of(valuationDate, mapKey0); // Generate market quotes from the trades Map<MarketDataKey<?>, Double> mapKeySy = new HashMap<>(); for (NodalCurveDefinition entry : curveGroups) { ImmutableList<CurveNode> nodes = entry.getNodes(); for (CurveNode node : nodes) { Trade trade = node.trade(valuationDate, marketQuotes0); double mq = measures.value(trade, inputMulticurve); MarketDataKey<?> k = node.requirements().iterator().next(); mapKeySy.put(k, mq); } } return ImmutableMarketData.of(valuationDate, mapKeySy); }
From source file:org.geogig.osm.internal.CreateOSMChangesetOp.java
/** * Executes the diff operation.//from w ww .ja va2s. com * * @return an iterator to a set of differences between the two trees * @see DiffEntry */ @Override protected AutoCloseableIterator<ChangeContainer> _call() { AutoCloseableIterator<DiffEntry> nodeIterator = command(DiffOp.class).setFilter(OSMUtils.NODE_TYPE_NAME) .setNewVersion(newRefSpec).setOldVersion(oldRefSpec).setReportTrees(false).call(); AutoCloseableIterator<DiffEntry> wayIterator = command(DiffOp.class).setFilter(OSMUtils.WAY_TYPE_NAME) .setNewVersion(newRefSpec).setOldVersion(oldRefSpec).setReportTrees(false).call(); AutoCloseableIterator<DiffEntry> iterator = AutoCloseableIterator.concat(nodeIterator, wayIterator); final EntityConverter converter = new EntityConverter(); final Function<DiffEntry, ChangeContainer> function = (diff) -> { NodeRef ref = diff.changeType().equals(ChangeType.REMOVED) ? diff.getOldObject() : diff.getNewObject(); RevFeature revFeature = command(RevObjectParse.class).setObjectId(ref.getObjectId()) .call(RevFeature.class).get(); RevFeatureType revFeatureType = command(RevObjectParse.class).setObjectId(ref.getMetadataId()) .call(RevFeatureType.class).get(); SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder( (SimpleFeatureType) revFeatureType.type()); ImmutableList<PropertyDescriptor> descriptors = revFeatureType.descriptors(); for (int i = 0; i < descriptors.size(); i++) { PropertyDescriptor descriptor = descriptors.get(i); Optional<Object> value = revFeature.get(i); featureBuilder.set(descriptor.getName(), value.orNull()); } SimpleFeature feature = featureBuilder.buildFeature(ref.name()); Entity entity = converter.toEntity(feature, id); EntityContainer container; if (entity instanceof Node) { container = new NodeContainer((Node) entity); } else { container = new WayContainer((Way) entity); } ChangeAction action = diff.changeType().equals(ChangeType.ADDED) ? ChangeAction.Create : diff.changeType().equals(ChangeType.MODIFIED) ? ChangeAction.Modify : ChangeAction.Delete; return new ChangeContainer(container, action); }; return AutoCloseableIterator.transform(iterator, function); }
From source file:org.caleydo.core.view.internal.ColorPalettePicker.java
public ColorPalettePicker() { setLayout(GLLayouts.flowVertical(10)); ImmutableSortedSet.Builder<IColorPalette> b = ImmutableSortedSet.orderedBy(new Comparator<IColorPalette>() { @Override/*from w w w . j a va 2 s. c o m*/ public int compare(IColorPalette o1, IColorPalette o2) { int c; if ((c = o1.getType().compareTo(o2.getType())) != 0) return c; c = o1.getSizes().last() - o2.getSizes().last(); if (c != 0) return -c; return String.CASE_INSENSITIVE_ORDER.compare(o1.getLabel(), o2.getLabel()); } }); b.add(ColorBrewer.values()); b.add(AlexColorPalette.values()); final ImmutableList<IColorPalette> l = b.build().asList(); GLElementContainer c = new GLElementContainer(GLLayouts.flowHorizontal(2)); for (IColorPalette p : l.subList(0, l.size() / 2)) c.add(new ColorPalette(p)); this.add(c); c = new GLElementContainer(GLLayouts.flowHorizontal(2)); for (IColorPalette p : l.subList(l.size() / 2, l.size())) c.add(new ColorPalette(p)); this.add(c); }
From source file:org.locationtech.geogig.plumbing.index.BuildIndexOp.java
private int indexOf(String attName, RevFeatureType featureType) { ImmutableList<PropertyDescriptor> descriptors = featureType.descriptors(); for (int i = 0; i < descriptors.size(); i++) { String name = descriptors.get(i).getName().getLocalPart(); if (attName.equals(name)) { return i; }/*from w ww . ja v a 2 s . co m*/ } throw new IllegalArgumentException(String.format("Feature type %s has no attribute '%s'", featureType.getName().getLocalPart(), attName)); }
From source file:com.cognifide.aet.cleaner.processors.StartMetadataCleanupProcessor.java
@Override public void process(Exchange exchange) throws Exception { LOGGER.info("Start processing cleaning workflow."); final CleanerContext cleanerContext = exchange.getIn().getBody(CleanerContext.class); final String companyFilter = cleanerContext.getCompanyFilter(); final String projectFilter = cleanerContext.getProjectFilter(); final Collection<String> dbNames = client.getAetsDBNames(); final DBKeyProjectCompanyPredicate predicate = new DBKeyProjectCompanyPredicate(companyFilter, projectFilter);//from w w w . ja va 2 s. c o m final ImmutableList<DBKey> dbKeys = FluentIterable.from(dbNames).transform(DB_NAMES_TO_DB_KEYS) .filter(predicate).toList(); LOGGER.info("Found {} databases matching criteria {}.", dbKeys.size(), predicate); exchange.getOut().setHeader(CleanerContext.KEY_NAME, cleanerContext); exchange.getOut().setBody(dbKeys); }
From source file:org.apache.james.dlp.api.DLPRules.java
private void checkNotContainDuplicateIds(ImmutableList<DLPConfigurationItem> items) throws DuplicateRulesIdsException { long uniqueIdCount = items.stream().map(DLPConfigurationItem::getId).distinct().count(); if (uniqueIdCount != items.size()) { throw new DuplicateRulesIdsException(); }/*from w w w . j av a 2 s.c o m*/ }