List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:com.spectralogic.ds3cli.views.cli.GetVersionedBucketView.java
protected String[][] formatTableContents() { final ImmutableList.Builder<String[]> builder = ImmutableList.builder(); for (final Contents content : contents) { final String[] arrayEntry = new String[6]; arrayEntry[0] = nullGuard(content.getKey()); arrayEntry[1] = nullGuard(Long.toString(content.getSize())); arrayEntry[2] = nullGuard(content.getOwner().getDisplayName()); arrayEntry[3] = nullGuardFromDate(content.getLastModified(), DATE_FORMAT); arrayEntry[4] = nullGuard(content.getETag()); arrayEntry[5] = nullGuard(content.getVersionId()); builder.add(arrayEntry);//from ww w .ja v a 2 s .co m } final ImmutableList<String[]> contentStrings = builder.build(); return contentStrings.toArray(new String[contentStrings.size()][]); }
From source file:com.google.devtools.build.lib.bazel.rules.sh.ShBinary.java
@Override public ConfiguredTarget create(RuleContext ruleContext) throws RuleErrorException { ImmutableList<Artifact> srcs = ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list(); if (srcs.size() != 1) { ruleContext.attributeError("srcs", "you must specify exactly one file in 'srcs'"); return null; }//from ww w. j a va 2 s . co m Artifact symlink = ruleContext.createOutputArtifact(); // Note that src is used as the executable script too Artifact src = srcs.get(0); // The interpretation of this deceptively simple yet incredibly generic rule is complicated // by the distinction between targets and (not properly encapsulated) artifacts. It depends // on the notion of other rule's "files-to-build" sets, which are undocumented, making it // impossible to give a precise definition of what this rule does in all cases (e.g. what // happens when srcs = ['x', 'y'] but 'x' is an empty filegroup?). This is a pervasive // problem in Blaze. ruleContext.registerAction(new ExecutableSymlinkAction(ruleContext.getActionOwner(), src, symlink)); NestedSet<Artifact> filesToBuild = NestedSetBuilder.<Artifact>stableOrder().add(src).add(symlink).build(); Runfiles runfiles = new Runfiles.Builder(ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles()).addTransitiveArtifacts(filesToBuild) .addRunfiles(ruleContext, RunfilesProvider.DEFAULT_RUNFILES).build(); RunfilesSupport runfilesSupport = RunfilesSupport.withExecutable(ruleContext, runfiles, symlink); return new RuleConfiguredTargetBuilder(ruleContext).setFilesToBuild(filesToBuild) .setRunfilesSupport(runfilesSupport, symlink) .addProvider(RunfilesProvider.class, RunfilesProvider.simple(runfiles)).build(); }
From source file:com.google.devtools.build.lib.skyframe.serialization.ImmutableListRuntimeCodec.java
@Override public void serialize(SerializationContext context, ImmutableList object, CodedOutputStream codedOut) throws IOException, SerializationException { codedOut.writeInt32NoTag(object.size()); for (Object obj : object) { context.serialize(obj, codedOut); }/*from w w w . ja va2s . co m*/ }
From source file:uk.q3c.krail.core.option.hierarchy.SimpleUserHierarchy.java
@Override public synchronized String lowestRankName() { ImmutableList<String> ranks = ranksForCurrentUser(); return ranks.get(ranks.size() - 1); }
From source file:com.liveramp.megadesk.recipes.queue.PopOne.java
@Override public Void run(Context context) throws Exception { ImmutableList<VALUE> list = context.read(this.list); if (!list.isEmpty()) { ImmutableList<VALUE> newList = list.subList(1, list.size()); context.write(this.list, newList); }/*from w ww .j a v a 2 s . c om*/ if (context.read(this.list).isEmpty()) { context.write(this.frozen, false); } return null; }
From source file:com.publictransitanalytics.scoregenerator.workflow.RetrospectiveMovementAssembler.java
@Override public MovementPath assemble(final PointLocation terminal, final Map<PointLocation, DynamicProgrammingRecord> lastRow) { final ImmutableList.Builder<Movement> movementsBuilder = ImmutableList.builder(); PointLocation location = terminal;/*ww w. j av a 2 s . c o m*/ DynamicProgrammingRecord record = lastRow.get(location); while (record != null) { final ModeInfo mode = record.getMode(); final ModeType type = mode.getType(); if (type.equals(ModeType.TRANSIT)) { final EntryPoint trip = mode.getTransitTrip(); final Movement movement = new TransitRideMovement(trip.getTrip(), location, record.getReachTime(), record.getPredecessor(), trip.getTime()); movementsBuilder.add(movement); } else if (type.equals(ModeType.WALKING)) { final WalkingCosts costs = mode.getWalkCosts(); final PointLocation predecessor = record.getPredecessor(); final LocalDateTime predecessorReachTime = lastRow.get(predecessor).getReachTime(); final double distanceMeters = costs.getDistanceMeters(); final LocalDateTime reachTime = record.getReachTime(); final Movement movement = new WalkMovement(reachTime, distanceMeters, location, predecessorReachTime, predecessor); movementsBuilder.add(movement); } location = record.getPredecessor(); record = (location == null) ? null : lastRow.get(location); final ImmutableList<Movement> movements = movementsBuilder.build(); if (movements.size() > 1) { final Movement recentMovement = movements.get(movements.size() - 1); final Movement priorMovement = movements.get(movements.size() - 2); if (recentMovement instanceof WalkMovement && priorMovement instanceof WalkMovement) { } } } return new FixedPath(movementsBuilder.build()); }
From source file:com.github.hilcode.versionator.impl.DefaultVersionChangeExtractor.java
@Override public final Result<String, RequestedVersionChange> extract(final ImmutableList<String> arguments) { final int argumentCount = arguments.size(); if (argumentCount == 0) { return Result.failure("Expected either a GAV or a group:artifact followed by an old and a new version, " + "but you provided nothing.\n\n" + "Perhaps try --help?"); }//from w w w. ja v a2 s. co m if (argumentCount < 3) { return extractAny(arguments); } final Matcher matcher = GROUP_ARTIFACT.matcher(arguments.get(argumentCount - 3)); if (!matcher.matches()) { return extractAny(arguments); } else { final String oldVersion = arguments.get(argumentCount - 2); if (oldVersion.contains(":")) { return failure(arguments.get(argumentCount - 3), arguments.get(argumentCount - 2)); } final String newVersion = arguments.get(argumentCount - 1); if (newVersion.contains(":")) { return failure(arguments.get(argumentCount - 3), arguments.get(argumentCount - 1)); } return extractOldNew(this.matchers.toGroupArtifact(matcher), oldVersion, newVersion, arguments); } }
From source file:com.github.hilcode.versionator.impl.DefaultVersionChangeExtractor.java
Result<String, RequestedVersionChange> extractAny(final ImmutableList<String> arguments) { final int indexOfLastArgument = arguments.size() - 1; final String lastArgument = arguments.get(indexOfLastArgument); final Matcher matcher = GAV.matcher(lastArgument); if (!matcher.matches()) { return Result.failure(String .format("Expected a GAV, but you provided: '%s'.\n\n" + "Perhaps try --help?", lastArgument)); }//ww w. j av a 2s . c o m final Result<String, ImmutableList<Gav>> gavs = this.gavExtractor .extract(arguments.subList(0, indexOfLastArgument)); if (gavs.isFailure()) { return Result.asFailure(gavs); } else { final FromAnyToNewVersion versionChange = new FromAnyToNewVersion(this.matchers.toGav(matcher)); final Either<FromOldToNewVersion, FromAnyToNewVersion> fromAnyToNewVersion = Either .right(versionChange); return Result.success(new RequestedVersionChange(fromAnyToNewVersion, gavs.success())); } }
From source file:com.google.devtools.build.lib.skyframe.serialization.ImmutableListCodec.java
@Override public void serialize(ImmutableList<T> list, CodedOutputStream codedOut) throws SerializationException, IOException { codedOut.writeInt32NoTag(list.size()); for (T item : list) { codec.serialize(item, codedOut); }//from w ww . j ava2s. c o m }
From source file:com.microsoft.thrifty.schema.LinkEnvironment.java
public ImmutableList<String> getErrors() { if (!hasErrors()) { return ImmutableList.of(); }//from w ww .j a v a 2s .c o m ImmutableList<ErrorReporter.Report> reports = errorReporter.reports(); List<String> errors = new ArrayList<>(reports.size()); for (ErrorReporter.Report report : reports) { String level = report.level().name(); String msg = level + ": " + report.message() + "(" + report.location() + ")"; errors.add(msg); } return ImmutableList.copyOf(errors); }