List of usage examples for com.google.common.collect ImmutableSortedSet reverseOrder
public static <E extends Comparable<?>> Builder<E> reverseOrder()
From source file:com.google.devtools.build.lib.bazel.rules.android.AndroidRepositoryUtils.java
/** * Gets the numeric api levels from the contents of the platforms directory in descending order. * * Note that the directory entries are assumed to match {@code android-[0-9]+}. Any directory * entries that are not directories or do not match that pattern are ignored. *//* w ww.j a va2 s. c o m*/ static ImmutableSortedSet<Integer> getApiLevels(Dirents platformsDirectories) { ImmutableSortedSet.Builder<Integer> apiLevels = ImmutableSortedSet.reverseOrder(); for (Dirent platformDirectory : platformsDirectories) { if (platformDirectory.getType() != Dirent.Type.DIRECTORY) { continue; } Matcher matcher = PLATFORMS_API_LEVEL_PATTERN.matcher(platformDirectory.getName()); if (matcher.matches()) { apiLevels.add(Integer.parseInt(matcher.group(1))); } } return apiLevels.build(); }
From source file:com.facebook.buck.java.DefaultJavaPackageFinder.java
/** * @param pathPatterns elements that start with a slash must be prefix patterns; all other * elements indicate individual directory names (and therefore cannot contain slashes). *///from w w w . j a va 2 s .co m public static DefaultJavaPackageFinder createDefaultJavaPackageFinder(Iterable<String> pathPatterns) { ImmutableSortedSet.Builder<String> pathsFromRoot = ImmutableSortedSet.reverseOrder(); ImmutableSet.Builder<String> pathElements = ImmutableSet.builder(); for (String pattern : pathPatterns) { if (pattern.charAt(0) == '/') { // Strip the leading slash. pattern = pattern.substring(1); // Ensure there is a trailing slash, unless it is an empty string. if (!pattern.isEmpty() && !pattern.endsWith("/")) { pattern = pattern + "/"; } pathsFromRoot.add(pattern); } else { if (pattern.contains("/")) { throw new HumanReadableException( "Path pattern that does not start with a slash cannot contain a slash: %s", pattern); } pathElements.add(pattern); } } return new DefaultJavaPackageFinder(pathsFromRoot.build(), pathElements.build()); }
From source file:com.google.devtools.build.lib.bazel.rules.android.AndroidRepositoryFunction.java
/** * Gets the numeric api levels from the contents of the platforms directory in descending order. * * <p>Note that the directory entries are assumed to match {@code android-[0-9]+}. Any directory * entries that are not directories or do not match that pattern are ignored. *///from w w w . j a v a2s. co m static final ImmutableSortedSet<Integer> getApiLevels(Dirents platformsDirectories) { ImmutableSortedSet.Builder<Integer> apiLevels = ImmutableSortedSet.reverseOrder(); for (Dirent platformDirectory : platformsDirectories) { if (platformDirectory.getType() != Dirent.Type.DIRECTORY) { continue; } Matcher matcher = PLATFORMS_API_LEVEL_PATTERN.matcher(platformDirectory.getName()); if (matcher.matches()) { apiLevels.add(Integer.parseInt(matcher.group(1))); } } return apiLevels.build(); }
From source file:com.google.devtools.build.android.SplitConfigurationFilter.java
/** Generates a SplitConfigurationFilter from the suffix of a split generated by aapt. */ static SplitConfigurationFilter fromFilenameSuffix(String suffix) { ImmutableSortedSet.Builder<ResourceConfiguration> configs = ImmutableSortedSet.reverseOrder(); for (String configuration : Splitter.on('_').split(suffix)) { configs.add(ResourceConfiguration.fromString(configuration)); }//w ww . j a va 2 s . c o m return new SplitConfigurationFilter(suffix, configs.build()); }
From source file:com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryFunction.java
/** * Gets the numeric api levels from the contents of the platforms directory in descending order. *//*from w w w .ja v a 2s . c o m*/ private static ImmutableSortedSet<Integer> getApiLevels(Dirents platformsDirectories) { ImmutableSortedSet.Builder<Integer> apiLevels = ImmutableSortedSet.reverseOrder(); for (Dirent platformDirectory : platformsDirectories) { if (platformDirectory.getType() != Dirent.Type.DIRECTORY) { continue; } Matcher matcher = PLATFORMS_API_LEVEL_PATTERN.matcher(platformDirectory.getName()); if (matcher.matches()) { apiLevels.add(Integer.parseInt(matcher.group(1))); } } return apiLevels.build(); }