List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:org.geogit.repository.DepthSearch.java
/** * @param parent/*from w w w . ja v a 2 s.c o m*/ * @param directChildName * @return */ public Optional<Node> getDirectChild(RevTree parent, String directChildName, final int subtreesDepth) { if (parent.isEmpty()) { return Optional.absent(); } if (parent.trees().isPresent() || parent.features().isPresent()) { if (parent.trees().isPresent()) { ImmutableList<Node> refs = parent.trees().get(); for (int i = 0; i < refs.size(); i++) { if (directChildName.equals(refs.get(i).getName())) { return Optional.of(refs.get(i)); } } } if (parent.features().isPresent()) { ImmutableList<Node> refs = parent.features().get(); for (int i = 0; i < refs.size(); i++) { if (directChildName.equals(refs.get(i).getName())) { return Optional.of(refs.get(i)); } } } return Optional.absent(); } Integer bucket = refOrder.bucket(directChildName, subtreesDepth); ImmutableSortedMap<Integer, Bucket> buckets = parent.buckets().get(); Bucket subtreeBucket = buckets.get(bucket); if (subtreeBucket == null) { return Optional.absent(); } RevTree subtree = objectDb.get(subtreeBucket.id(), RevTree.class); return getDirectChild(subtree, directChildName, subtreesDepth + 1); }
From source file:org.locationtech.geogig.repository.impl.DepthSearch.java
/** * @param parent/*from w w w .j av a2 s . c om*/ * @param directChildName * @return */ public Optional<Node> getDirectChild(RevTree parent, String directChildName, final int subtreesDepth) { if (parent.isEmpty()) { return Optional.absent(); } if (!parent.trees().isEmpty() || !parent.features().isEmpty()) { if (!parent.trees().isEmpty()) { ImmutableList<Node> refs = parent.trees(); for (int i = 0; i < refs.size(); i++) { if (directChildName.equals(refs.get(i).getName())) { return Optional.of(refs.get(i)); } } } if (!parent.features().isEmpty()) { ImmutableList<Node> refs = parent.features(); for (int i = 0; i < refs.size(); i++) { if (directChildName.equals(refs.get(i).getName())) { return Optional.of(refs.get(i)); } } } return Optional.absent(); } Integer bucket = refOrder.bucket(directChildName, subtreesDepth); ImmutableSortedMap<Integer, Bucket> buckets = parent.buckets(); Bucket subtreeBucket = buckets.get(bucket); if (subtreeBucket == null) { return Optional.absent(); } RevTree subtree = objectDb.get(subtreeBucket.getObjectId(), RevTree.class); return getDirectChild(subtree, directChildName, subtreesDepth + 1); }
From source file:com.github.hilcode.versionator.impl.DefaultVersionChangeExtractor.java
Result<String, RequestedVersionChange> extractOldNew(final GroupArtifact groupArtifact, final String oldVersion, final String newVersion, final ImmutableList<String> arguments) { final Result<String, ImmutableList<Gav>> gavs = this.gavExtractor .extract(arguments.subList(0, arguments.size() - 3)); if (gavs.isFailure()) { return Result.asFailure(gavs); } else {/*from www . j a v a2 s. com*/ final FromOldToNewVersion versionChange = new FromOldToNewVersion(groupArtifact, oldVersion, newVersion); final Either<FromOldToNewVersion, FromAnyToNewVersion> fromOldToNewVersion = Either.left(versionChange); return Result.success(new RequestedVersionChange(fromOldToNewVersion, gavs.success())); } }
From source file:com.getbase.android.schema.Schemas.java
private static void validateTableOperations(String tableName, ImmutableList<? extends TableOperation> operations) { Preconditions.checkArgument(!operations.isEmpty(), "Schema part should contain at least one operation"); List<TableOperationId> ids = Lists.newArrayList(); for (TableOperation operation : operations) { ids.add(operation.getId());//from www. j a va 2 s .com } if (ids.contains(DropTable.DROP_TABLE_OPERATION_ID)) { Preconditions.checkArgument(operations.size() == 1, "DropTable operation in downgrade definition for table " + tableName + " cannot be mixed with other operations"); } Preconditions.checkArgument(Sets.newHashSet(ids).size() == ids.size(), "Duplicate operations on single column or constraint in " + tableName); }
From source file:ru.org.linux.topic.TopicTagService.java
/** * ? ?? ??.//from w ww . ja v a2 s . com * ? ? * * @param msgId ?? * @return ? ?? */ public ImmutableList<String> getMessageTagsForTitle(int msgId) { ImmutableList<String> tags = topicTagDao.getTags(msgId); return tags.subList(0, Math.min(tags.size(), MAX_TAGS_IN_TITLE)); }
From source file:edu.illinois.my.wiki.plugin.servlet.action.SearchAction.java
@Override protected ImmutableList<WikiLocation> createLocationsResponse(User user, Parameters requestParameters) { String query = requestParameters.get(Search.QUERY); if (query.isEmpty()) { throw responseFactory.createException(MISSING_QUERY, WikiService.BAD_REQUEST, MISSING_QUERY); }//from ww w . j a v a2 s . c o m // This MultiTextFieldQuery is an abomination, but it is taken from // siteSearchQuery, which means this is how the Confluence text search // works as well. SearchQuery textQuery = new MultiTextFieldQuery(query, "title", "labelText", "contentBody", "filename", "username", "fullName", "email", "from", "recipients"); ImmutableList<WikiLocation> results = searchManager.search(textQuery, user, MAX_RESULTS, Sort.NONE); eventManager.publishEvent(new SearchPerformedEvent(this, textQuery, user, results.size())); return results; }
From source file:google.registry.tools.GenerateLordnCommand.java
@Override public void run() throws IOException { DateTime now = DateTime.now(UTC);// ww w. j a v a 2 s .c o m ImmutableList.Builder<String> claimsCsv = new ImmutableList.Builder<>(); ImmutableList.Builder<String> sunriseCsv = new ImmutableList.Builder<>(); for (DomainResource domain : ofy().load().type(DomainResource.class).filter("tld", tld)) { String status = " "; if (domain.getLaunchNotice() == null && domain.getSmdId() != null) { sunriseCsv.add(LordnTask.getCsvLineForSunriseDomain(domain, domain.getCreationTime())); status = "S"; } else if (domain.getLaunchNotice() != null || domain.getSmdId() != null) { claimsCsv.add(LordnTask.getCsvLineForClaimsDomain(domain, domain.getCreationTime())); status = "C"; } System.out.printf("%s[%s] ", domain.getFullyQualifiedDomainName(), status); } ImmutableList<String> claimsRows = claimsCsv.build(); ImmutableList<String> claimsAll = new ImmutableList.Builder<String>() .add(String.format("1,%s,%d", now, claimsRows.size())).add(LordnTask.COLUMNS_CLAIMS) .addAll(claimsRows).build(); ImmutableList<String> sunriseRows = sunriseCsv.build(); ImmutableList<String> sunriseAll = new ImmutableList.Builder<String>() .add(String.format("1,%s,%d", now.plusMillis(1), sunriseRows.size())).add(LordnTask.COLUMNS_SUNRISE) .addAll(sunriseRows).build(); Files.write(claimsOutputPath, claimsAll, UTF_8); Files.write(sunriseOutputPath, sunriseAll, UTF_8); }
From source file:auto.http.internal.codegen.AutoHttpWriter.java
private void buildMethods() { for (AutoHttpDescriptor.MethodDescriptor methodDescriptor : autoHttpDescriptor.methodElements()) { ExecutableElement methodElement = methodDescriptor.methodElement(); MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(methodElement.getSimpleName().toString()) .addAnnotation(Override.class) .addModifiers(Sets.difference(methodElement.getModifiers(), ImmutableSet.of(ABSTRACT))) .returns(methodDescriptor.returnTypeName()); String returnType = "returnType"; StringBuilder returnTypeFormat = new StringBuilder("$T $N = $T.wrapType($N.class,"); ImmutableList<Class<?>> returnTypeArguments = methodDescriptor.returnTypeArguments(); for (int i = 0; i < returnTypeArguments.size(); i++) { returnTypeFormat.append(returnTypeArguments.get(i).getSimpleName()); returnTypeFormat.append(".class,"); }/* w ww. jav a 2 s. c o m*/ returnTypeFormat.deleteCharAt(returnTypeFormat.length() - 1).append(")"); methodBuilder.addStatement(returnTypeFormat.toString(), Type.class, returnType, Utils.class, methodDescriptor.returnType().getSimpleName()); String convertType = "convertType"; StringBuilder convertTypeFormat = new StringBuilder("$T $N = $T.wrapType($N.class,"); ImmutableList<Class<?>> converterTypeArguments = methodDescriptor.converterTypeArguments(); for (int i = 0; i < converterTypeArguments.size(); i++) { convertTypeFormat.append(converterTypeArguments.get(i).getSimpleName()); convertTypeFormat.append(".class,"); } convertTypeFormat.deleteCharAt(convertTypeFormat.length() - 1).append(")"); methodBuilder.addStatement(convertTypeFormat.toString(), Type.class, convertType, Utils.class, methodDescriptor.converterType().getSimpleName()); //TODO method body impl String builder = "builder"; methodBuilder.addStatement("$T $N = new $T()", Request.Builder.class, builder, Request.Builder.class) .addStatement("$N.url($N.baseUrl())", builder, FIELD_PLUGINS) .addStatement("return $T.result($N.build(),$N,$N,$N)", ResultFactory.class, builder, FIELD_PLUGINS, returnType, convertType); autoHttpClass.addMethod(methodBuilder.build()); } }
From source file:se.vlovgr.examresults.parse.ParsedResults.java
/** * Creates a new {@code ParsedResults} instance using the specified immutable * list of immutable course exam instances. The parsed results should have been * parsed from the response to a query. The specified integer value is the total * amount of parts available in the response to the query. If a negative value * is specified, the information will be marked as absent. Also, consider using * the {@link #ParsedResults(ImmutableList)} constructor in such case. * * @param courseExams the course exam instances which have been parsed * @param totalParts the total number of parts available; negative if omitted * @throws NullPointerException if the list or any element is {@code null} *//*from w ww .j a va 2s. co m*/ public ParsedResults(final ImmutableList<CourseExam> courseExams, final int totalParts) { checkNotNull(courseExams, "courseExams null"); for (int i = 0, c = courseExams.size(); i < c; i++) checkNotNull(courseExams.get(i), "courseExams[%s] null", i); this.courseExams = courseExams; this.totalParts = totalParts < 0 ? Optional.<Integer>absent() : Optional.of(totalParts); }
From source file:google.registry.monitoring.metrics.contrib.AbstractMetricSubject.java
private @Nullable MetricPoint<T> findMetricPointForLabels(ImmutableList<String> labels) { if (actual().getMetricSchema().labels().size() != labels.size()) { return null; }/*from ww w . j a va 2 s . com*/ for (MetricPoint<T> metricPoint : actual().getTimestampedValues()) { if (metricPoint.labelValues().equals(labels)) { return metricPoint; } } return null; }