List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:com.google.devtools.build.importdeps.ImportDepsChecker.java
public String computeResultOutput(String ruleLabel) { StringBuilder builder = new StringBuilder(); ImmutableList<String> missingClasses = resultCollector.getSortedMissingClassInternalNames(); for (String missing : missingClasses) { builder.append("Missing ").append(missing.replace('/', '.')).append('\n'); }//from w w w. j a v a 2 s.c om ImmutableList<IncompleteState> incompleteClasses = resultCollector.getSortedIncompleteClasses(); for (IncompleteState incomplete : incompleteClasses) { builder.append("Incomplete ancestor classpath for ") .append(incomplete.classInfo().get().internalName().replace('/', '.')).append('\n'); ImmutableList<String> failurePath = incomplete.getResolutionFailurePath(); checkState(!failurePath.isEmpty(), "The resolution failure path is empty. %s", failurePath); builder.append(INDENT).append("missing ancestor: ") .append(failurePath.get(failurePath.size() - 1).replace('/', '.')).append('\n'); builder.append(INDENT).append("resolution failure path: ").append(failurePath.stream() .map(internalName -> internalName.replace('/', '.')).collect(Collectors.joining(" -> "))) .append('\n'); } ImmutableList<MissingMember> missingMembers = resultCollector.getSortedMissingMembers(); for (MissingMember missing : missingMembers) { builder.append("Missing member '").append(missing.memberName()).append("' in class ") .append(missing.owner().replace('/', '.')).append(" : name=").append(missing.memberName()) .append(", descriptor=").append(missing.descriptor()).append('\n'); } if (missingClasses.size() + incompleteClasses.size() + missingMembers.size() != 0) { builder.append("===Total===\n").append("missing=").append(missingClasses.size()).append('\n') .append("incomplete=").append(incompleteClasses.size()).append('\n').append("missing_members=") .append(missingMembers.size()).append('\n'); } ImmutableList<Path> indirectJars = resultCollector.getSortedIndirectDeps(); if (!indirectJars.isEmpty()) { ImmutableList<String> labels = extractLabels(indirectJars); if (ruleLabel.isEmpty() || labels.isEmpty()) { builder.append("*** Missing strict dependencies on the following Jars which don't carry " + "rule labels.\nPlease determine the originating rules, e.g., using Bazel's " + "'query' command, and add them to the dependencies of ") .append(ruleLabel.isEmpty() ? inputJars : ruleLabel).append('\n'); for (Path jar : indirectJars) { builder.append(jar).append('\n'); } } else { builder.append("*** Missing strict dependencies. Run the following command to fix ***\n\n"); builder.append(" add_dep "); for (String indirectLabel : labels) { builder.append(indirectLabel).append(" "); } builder.append(ruleLabel).append('\n'); } } return builder.toString(); }
From source file:com.github.hilcode.versionator.impl.DefaultReleaseExtractor.java
@Override public final Result<String, ImmutableList<GroupArtifact>> extract(final ImmutableList<String> arguments) { Preconditions.checkNotNull(arguments, "Missing 'arguments'."); if (arguments.isEmpty()) { return Result.success(ImmutableList.<GroupArtifact>of()); }/*from www . j a v a2 s . c o m*/ final String firstArgument = arguments.get(0); if (firstArgument.equals("-x") || firstArgument.equals("--exclude")) { final ImmutableList<String> exclusions = arguments.subList(1, arguments.size()); return extractExclusions(exclusions); } else { return Result.failure(String.format( "Expected '-x' or '--exclude' but found '%s' instead.\n\nPerhaps try --help?", firstArgument)); } }
From source file:com.facebook.buck.event.listener.SuperConsoleEventBusListener.java
@VisibleForTesting synchronized void render() { ImmutableList<String> lines = createRenderLinesAtTime(clock.currentTimeMillis()); String nextFrame = clearLastRender() + Joiner.on("\n").join(lines); lastNumLinesPrinted = lines.size(); // Synchronize on the DirtyPrintStreamDecorator to prevent interlacing of output. synchronized (console.getStdOut()) { synchronized (console.getStdErr()) { // If another source has written to stderr or stdout, stop rendering with the SuperConsole. // We need to do this to keep our updates consistent. if (console.getStdOut().isDirty() || console.getStdErr().isDirty()) { stopRenderScheduler();//from www . j a v a 2 s.c o m } else if (!nextFrame.isEmpty()) { nextFrame = ansi.asNoWrap(nextFrame); console.getStdErr().getRawStream().println(nextFrame); } } } }
From source file:org.eclipse.xtext.ui.resource.Storage2UriMapperImpl.java
@Inject private void initializeContributions(ISharedStateContributionRegistry registry) { final ImmutableList<? extends IStorage2UriMapperContribution> allContributions = registry .getContributedInstances(IStorage2UriMapperContribution.class); final int size = allContributions.size(); switch (size) { case 0:/* w ww. j a v a 2 s . c o m*/ // nothing to do break; case 1: contribution = allContributions.get(0); break; default: contribution = new IStorage2UriMapperContribution() { @Override public void initializeCache() { for (IStorage2UriMapperContribution contribution : allContributions) { contribution.initializeCache(); } } @Override public boolean isRejected(/* @NonNull */ IFolder folder) { for (int i = 0; i < size; i++) { if (allContributions.get(i).isRejected(folder)) { return true; } } return false; } /* @NonNull */ @Override public Iterable<Pair<IStorage, IProject>> getStorages(/* @NonNull */ final URI uri) { return Iterables.concat(Lists.transform(allContributions, new Function<IStorage2UriMapperContribution, Iterable<Pair<IStorage, IProject>>>() { /* @NonNull */ @Override public Iterable<Pair<IStorage, IProject>> apply( IStorage2UriMapperContribution contribution) { return contribution.getStorages(uri); } })); } /* @Nullable */ @Override public URI getUri(/* @NonNull */ IStorage storage) { for (int i = 0; i < size; i++) { URI result = allContributions.get(i).getUri(storage); if (result != null) { return result; } } return null; } }; } }
From source file:com.google.devtools.build.lib.remote.TreeNodeRepository.java
/** * This function is a temporary and highly inefficient hack! It builds the tree from a ready list * of input files. TODO(olaola): switch to creating and maintaining the TreeNodeRepository based * on the build graph structure.//from w ww .j a v a 2s .co m */ public TreeNode buildFromActionInputs(Iterable<ActionInput> actionInputs) { TreeMap<PathFragment, ActionInput> sortedMap = new TreeMap<>(); for (ActionInput input : actionInputs) { sortedMap.put(new PathFragment(input.getExecPathString()), input); } ImmutableList.Builder<ImmutableList<String>> segments = ImmutableList.builder(); for (PathFragment path : sortedMap.keySet()) { segments.add(path.getSegments()); } ImmutableList<ActionInput> inputs = ImmutableList.copyOf(sortedMap.values()); return buildParentNode(inputs, segments.build(), 0, inputs.size(), 0); }
From source file:net.osten.watermap.convert.SanGorgonioReport.java
/** * Converts the SanG datafile to water reports. * * @return set of water reports//from ww w. j ava2 s . c o m */ public Set<WaterReport> convert() { Set<WaterReport> results = new HashSet<WaterReport>(); /* Multiset<String> liness = HashMultiset.create( Splitter.on('\t') .trimResults() .omitEmptyStrings() .split( (filePath != null ? Files.asCharSource(new File(filePath), Charsets.UTF_8).read() : Resources.asCharSource(fileURL, Charsets.UTF_8).read()))); System.out.println("found " + liness.size() + " lines"); */ try { ImmutableList<String> lines = filePath != null ? Files.asCharSource(new File(filePath), Charsets.UTF_8).readLines() : Resources.asCharSource(fileURL, Charsets.UTF_8).readLines(); log.fine("found " + lines.size() + " lines"); for (String line : lines) { List<String> fields = Splitter.on('\t').trimResults().splitToList(line); /* Layout of datafile.txt - * String postDate = nextLine[0]; * String location = nextLine[1]; * String comment = nextLine[2]; * String logDate = nextLine[3]; * String user = nextLine[4]; */ WaterReport wr = new WaterReport(); try { wr.setLastReport(dateFormatter.parse(fields.get(3))); wr.setLocation("San Gorgonio"); wr.setDescription(fields.get(2)); wr.setName(fields.get(1)); wr.setSource(SOURCE_TITLE); wr.setUrl(SOURCE_URL); if (locationCoords.containsKey(wr.getName())) { List<String> coords = Splitter.on(',').splitToList(locationCoords.get(wr.getName())); wr.setLon(new BigDecimal(coords.get(0))); wr.setLat(new BigDecimal(coords.get(1))); } else { log.fine("==> cannot find coords for " + wr.getName()); } wr.setState(WaterStateParser.parseState(wr.getDescription())); boolean added = results.add(wr); if (!added) { results.remove(wr); results.add(wr); } } catch (java.text.ParseException e) { log.severe(e.getLocalizedMessage()); } } } catch (IOException e) { log.severe(e.getLocalizedMessage()); } return results; }
From source file:de.gfelbing.microservice.core.http.jetty.server.JettyServer.java
/** * Constructor creating a jetty server and initializes a ContextHandlerCollection, * which can be filled by addHandler()./* w w w . j a v a2 s . co m*/ * * @param hosts IPs / Hostnames jetty will bind itself to. * @param port Port to which the jetty server will bind itself. */ public JettyServer(final ImmutableList<String> hosts, final Integer port) { this.healthState = new AtomicReference<>(State.CREATED); this.server = new Server(); final ImmutableList<Connector> connectors = hosts.stream().map(host -> { ServerConnector connector = new ServerConnector(server); connector.setHost(host); connector.setPort(port); return connector; }).collect(GuavaCollect.immutableList()); this.server.setConnectors(connectors.toArray(new Connector[connectors.size()])); this.contextHandler = new ContextHandlerCollection(); this.server.setHandler(contextHandler); }
From source file:com.opengamma.strata.collect.io.CsvRow.java
/** * Creates an instance, specifying the headers and row. * <p>//from w w w . j a v a2s.c o m * See {@link CsvFile}. * * @param headers the headers * @param fields the fields */ private CsvRow(ImmutableList<String> headers, ImmutableList<String> fields) { this.headers = headers; // need to allow duplicate headers and only store the first instance Map<String, Integer> searchHeaders = new HashMap<>(); for (int i = 0; i < headers.size(); i++) { String searchHeader = headers.get(i).toLowerCase(Locale.ENGLISH); searchHeaders.putIfAbsent(searchHeader, i); } this.searchHeaders = ImmutableMap.copyOf(searchHeaders); this.fields = fields; }
From source file:solar.blaz.rondel.compiler.manager.AbstractInjectorManager.java
protected TypeElement[] parseModuleElements(ImmutableList<TypeMirror> modules) { if (modules == null || modules.size() == 0) { return null; } else {//from w w w .ja va2 s . c om boolean validModules = true; TypeElement[] moduleElements = new TypeElement[modules.size()]; for (int i = 0; i < modules.size(); i++) { TypeMirror moduleClass = modules.get(i); TypeElement module = elementUtils.getTypeElement(moduleClass.toString()); if (module.getAnnotation(Module.class) == null) { messager.error("App module is missing @Module annotation."); validModules = false; } else { moduleElements[i] = module; } } if (validModules) { return moduleElements; } else { return null; } } }
From source file:dagger.internal.codegen.BindingDeclarationFormatter.java
private String formatSubcomponentDeclaration(SubcomponentDeclaration subcomponentDeclaration) { ImmutableList<TypeMirror> moduleSubcomponents = getModuleSubcomponents( subcomponentDeclaration.moduleAnnotation()); int index = Iterables.indexOf(moduleSubcomponents, MoreTypes.equivalence().equivalentTo(subcomponentDeclaration.subcomponentType().asType())); StringBuilder annotationValue = new StringBuilder(); if (moduleSubcomponents.size() != 1) { annotationValue.append("{"); }/*from w w w. java 2 s . com*/ annotationValue.append(formatArgumentInList(index, moduleSubcomponents.size(), subcomponentDeclaration.subcomponentType().getQualifiedName() + ".class")); if (moduleSubcomponents.size() != 1) { annotationValue.append("}"); } return String.format("@%s(subcomponents = %s) for %s", simpleName(subcomponentDeclaration.moduleAnnotation()), annotationValue, subcomponentDeclaration.contributingModule().get()); }