com.google.common.collect.ImmutableSortedSet#contains ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableSortedSet#contains ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bats   文件: DateRangeRules.java
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e, String timeZone) {
    ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
    if (!timeUnits.contains(TimeUnitRange.YEAR)) {
        // Case when we have FLOOR or CEIL but no extract on YEAR.
        // Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
        // with timeUnit YEAR.
        timeUnits = ImmutableSortedSet.<TimeUnitRange> naturalOrder().addAll(timeUnits).add(TimeUnitRange.YEAR)
                .build();
    }
    final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
    for (TimeUnitRange timeUnit : timeUnits) {
        e = e.accept(new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits, timeZone));
    }
    return e;
}
 
源代码2 项目: Quicksql   文件: DateRangeRules.java
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e,
    String timeZone) {
  ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
  if (!timeUnits.contains(TimeUnitRange.YEAR)) {
    // Case when we have FLOOR or CEIL but no extract on YEAR.
    // Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
    // with timeUnit YEAR.
    timeUnits = ImmutableSortedSet.<TimeUnitRange>naturalOrder()
        .addAll(timeUnits).add(TimeUnitRange.YEAR).build();
  }
  final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
  for (TimeUnitRange timeUnit : timeUnits) {
    e = e.accept(
        new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits,
            timeZone));
  }
  return e;
}
 
源代码3 项目: calcite   文件: DateRangeRules.java
/** Replaces calls to EXTRACT, FLOOR and CEIL in an expression. */
@VisibleForTesting
public static RexNode replaceTimeUnits(RexBuilder rexBuilder, RexNode e,
    String timeZone) {
  ImmutableSortedSet<TimeUnitRange> timeUnits = extractTimeUnits(e);
  if (!timeUnits.contains(TimeUnitRange.YEAR)) {
    // Case when we have FLOOR or CEIL but no extract on YEAR.
    // Add YEAR as TimeUnit so that FLOOR gets replaced in first iteration
    // with timeUnit YEAR.
    timeUnits = ImmutableSortedSet.<TimeUnitRange>naturalOrder()
        .addAll(timeUnits).add(TimeUnitRange.YEAR).build();
  }
  final Map<RexNode, RangeSet<Calendar>> operandRanges = new HashMap<>();
  for (TimeUnitRange timeUnit : timeUnits) {
    e = e.accept(
        new ExtractShuttle(rexBuilder, timeUnit, operandRanges, timeUnits,
            timeZone));
  }
  return e;
}
 
源代码4 项目: buck   文件: Cells.java
/** @return Path of the topmost cell's path that roots all other cells */
public AbsPath getSuperRootPath() {
  AbsPath cellRoot = getRootCell().getRoot();
  ImmutableSortedSet<AbsPath> allRoots = getRootCell().getKnownRootsOfAllCells();
  AbsPath path = cellRoot.getRoot();

  // check if supercell is a root folder, like '/' or 'C:\'
  if (allRoots.contains(path)) {
    return path;
  }

  // There is an assumption that there is exactly one cell with a path that prefixes all other
  // cell paths. So just try to find the cell with the shortest common path.
  for (Path next : cellRoot.getPath()) {
    path = path.resolve(next);
    if (allRoots.contains(path)) {
      return path;
    }
  }
  throw new IllegalStateException(
      "Unreachable: at least one path should be in getKnownRoots(), including root cell '"
          + cellRoot.toString()
          + "'; known roots = ["
          + allRoots.stream().map(Objects::toString).collect(Collectors.joining(", "))
          + "]");
}
 
源代码5 项目: bazel   文件: NinjaGraph.java
private void checkDirectoriesAttributes(
    RuleContext ruleContext, PathFragment outputRoot, PathFragment workingDirectory)
    throws InterruptedException {
  Environment env = ruleContext.getAnalysisEnvironment().getSkyframeEnv();
  ImmutableSortedSet<String> notSymlinkedDirs =
      BazelSkyframeExecutorConstants.EXTERNAL_PACKAGE_HELPER.getNotSymlinkedInExecrootDirectories(
          env);
  if (env.valuesMissing()) {
    return;
  }

  // We can compare strings because notSymlinkedDirs contains normalized directory names
  if (!notSymlinkedDirs.contains(outputRoot.getPathString())) {
    ruleContext.attributeError(
        "output_root",
        String.format(
            "Ninja output root directory '%s' must be declared"
                + " using global workspace function toplevel_output_directories().",
            outputRoot.getPathString()));
  }

  if (!workingDirectory.isEmpty() && !workingDirectory.equals(outputRoot)) {
    ruleContext.attributeError(
        "working_directory",
        String.format(
            "Ninja working directory '%s' is restricted to be either empty (or not defined),"
                + " or be the same as output root '%s'.",
            workingDirectory.getPathString(), outputRoot.getPathString()));
  }
}
 
源代码6 项目: buck   文件: HasBundleName.java
/** Computes the bundle name as configured, or falls back to a default name. */
default String computeBundleName(
    ImmutableSortedSet<Flavor> flavors, Supplier<String> defaultName) {
  for (Pair<Flavor, String> nameForFlavor : getBundleNameForFlavor()) {
    if (flavors.contains(nameForFlavor.getFirst())) {
      return nameForFlavor.getSecond();
    }
  }
  return getBundleName().orElseGet(defaultName);
}
 
源代码7 项目: stash-codesearch-plugin   文件: SearchServlet.java
@SuppressWarnings("unchecked")
private ImmutableMap<String, Object> searchHitToDataMap(
    SearchHit hit,
    Map<String, Repository> repoMap, // null iff no permission validation required
    int maxPreviewLines,
    int maxMatchLines,
    ImmutableSet<String> noHighlight) {
    ImmutableMap.Builder<String, Object> hitData = new ImmutableMap.Builder<String, Object>();
    Map<String, Object> hitSource = hit.getSource();

    String type = hit.getType();
    hitData.put("type", type);

    String project = getStringFromMap(hitSource, "project");
    hitData.put("project", project);

    String repository = getStringFromMap(hitSource, "repository");
    hitData.put("repository", repository);

    // Validate permissions & build hit data map
    String repoId = project + "^" + repository;
    Repository repoObject;
    if (repoMap == null) { // current user is system administrator
        repoObject = repositoryServiceManager.getRepositoryService().getBySlug(
            project, repository);
    } else { // must validate against allowed repositories for non-administrators
        repoObject = repoMap.get(repoId);
    }

    if (repoObject != null &&
        repoObject.getProject().getKey().equals(project) &&
        repoObject.getSlug().equals(repository)) {

        // Generate refs array
        ImmutableSortedSet<String> refSet;
        try {
            refSet = ImmutableSortedSet.copyOf((Iterable<String>) hitSource.get("refs"));
        } catch (Exception e) {
            log.warn("Invalid refs collection detected for element in {}/{}", project, repository, e);
            return null;
        }
        if (refSet.isEmpty()) {
            log.warn("Detected empty refs collection for element in {}/{}", project, repository);
            return null;
        }
        hitData.put("refs", refSet);

        // Human-readable labels
        hitData
            .put("projectname", repoObject.getProject().getName())
            .put("repositoryname", repoObject.getName());

        if (type.equals("commit")) {
            hitData
                .put("hash", getStringFromMap(hitSource, "hash"))
                .put("subject", getStringFromMap(hitSource, "subject"))
                .put("body", getStringFromMap(hitSource, "body"))
                .put("commitDate", getDateStringFromMap(hitSource, "commitdate"))
                .put("authorName", getStringFromMap(hitSource, "authorname"))
                .put("authorEmail", getStringFromMap(hitSource, "authoremail"));

        } else if (type.equals("file")) {
            HighlightField highlightField = hit.getHighlightFields().get("contents");
            String path = getStringFromMap(hitSource, "path");
            String primaryRef = "refs/heads/master";
            if (!refSet.contains(primaryRef)) {
                primaryRef = refSet.iterator().next();
            }
            String contents = getStringFromMap(hitSource, "contents");
            SourceSearch searchedContents = SourceSearch.search(
                contents, highlightField, 1, maxPreviewLines, maxMatchLines);
            String extension = getStringFromMap(hitSource, "extension");

            hitData
                .put("path", path)
                .put("blob", getStringFromMap(hitSource, "blob"))
                .put("primaryRef", primaryRef)
                .put("sourceLines", searchedContents.getJoinedLines())
                .put("sourceLineNums", searchedContents.getJoinedLineNums())
                .put("isPreview", searchedContents.isPreview())
                .put("shownLines", searchedContents.getLines().length)
                .put("excessLines", searchedContents.getExcess())
                .put("extension", extension)
                .put("noHighlight", noHighlight.contains(extension));
        }
    } else {
        return null;
    }

    return hitData.build();
}
 
源代码8 项目: buck   文件: HeaderSymlinkTreeWithModuleMap.java
private static boolean containsSwiftHeader(ImmutableSortedSet<Path> paths, String moduleName) {
  return paths.contains(Paths.get(moduleName, moduleName + "-Swift.h"));
}