Example #1
0
 public void testKeySet() {
   ImmutableBiMap<String, Integer> bimap =
       ImmutableBiMap.copyOf(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4));
   Set<String> keys = bimap.keySet();
   assertEquals(Sets.newHashSet("one", "two", "three", "four"), keys);
   ASSERT.that(keys).hasContentsInOrder("one", "two", "three", "four");
 }
Example #2
0
 public void testKeySet() {
   ImmutableBiMap<String, Integer> bimap =
       ImmutableBiMap.copyOf(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4));
   Set<String> keys = bimap.keySet();
   assertEquals(Sets.newHashSet("one", "two", "three", "four"), keys);
   assertThat(keys).containsExactly("one", "two", "three", "four").inOrder();
 }
Example #3
0
  private int doExecute(ExecutionContext context) throws IOException, InterruptedException {
    List<Predicate<Path>> pathPredicates = Lists.newArrayList();

    boolean canDownscale = imageScaler != null && imageScaler.isAvailable(context);
    LOG.info(
        "FilterResourcesStep: canDownscale: %s. imageScalar non-null: %s.",
        canDownscale, imageScaler != null);

    if (filterDrawables) {
      Preconditions.checkNotNull(drawableFinder);
      Set<Path> drawables =
          drawableFinder.findDrawables(inResDirToOutResDirMap.keySet(), filesystem);
      pathPredicates.add(
          ResourceFilters.createImageDensityFilter(
              drawables, Preconditions.checkNotNull(targetDensities), canDownscale));
    }

    final boolean localeFilterEnabled = !locales.isEmpty();
    if (localeFilterEnabled || enableStringWhitelisting) {
      pathPredicates.add(
          new Predicate<Path>() {
            @Override
            public boolean apply(Path path) {
              Matcher matcher =
                  NON_ENGLISH_STRINGS_FILE_PATH.matcher(MorePaths.pathWithUnixSeparators(path));
              if (!matcher.matches()) {
                return true;
              }

              if (enableStringWhitelisting) {
                return isPathWhitelisted(path);
              } else {
                Preconditions.checkState(localeFilterEnabled);
                String locale = matcher.group(1);
                if (matcher.group(2) != null) {
                  locale += "_" + matcher.group(2);
                }

                return locales.contains(locale);
              }
            }
          });
    }

    // Create filtered copies of all resource directories. These will be passed to aapt instead.
    filteredDirectoryCopier.copyDirs(
        filesystem, inResDirToOutResDirMap, Predicates.and(pathPredicates));

    // If an ImageScaler was specified, but only if it is available, try to apply it.
    if (canDownscale && filterDrawables) {
      scaleUnmatchedDrawables(context);
    }

    return 0;
  }
  public static void main(String[] args) {
    ArrayList<Integer> list = Lists.newArrayList(new Integer[] {1, 2, 3, 4});

    List<String> transform =
        Lists.transform(
            list,
            new Function<Integer, String>() {
              @Override
              public String apply(Integer integer) {
                return integer + "";
              }
            });

    List<Integer> reverseList = Lists.reverse(list);
    for (Object o : transform) {
      System.out.println(o.getClass().toString() + o);
    }
    for (Object o : reverseList) {
      System.out.println(o);
    }
    System.out.println("Hell o");
    // 不可变集合
    ImmutableList<Integer> immutableList = ImmutableList.of(1, 2, 3, 4);
    ImmutableBiMap<Integer, String> immutableBiMap = ImmutableBiMap.of(1, "1", 2, "2");
    ImmutableSet<Integer> immutableSet = ImmutableSet.of(1, 2, 3, 4);
    ImmutableCollection<Integer> immutableCollection = ImmutableList.of(1, 2, 3, 4);

    for (Integer i : immutableList) {
      System.out.print(i + "-");
    }
    System.out.println();
    for (Integer i : immutableBiMap.keySet()) {
      System.out.print(immutableBiMap.get(i) + "-");
    }
    System.out.println();
    for (Integer i : immutableList) {
      System.out.print(i + "-");
    }
    System.out.println();
    for (Integer i : immutableCollection) {
      System.out.print(i + "-");
    }
    // 新集合类型
    ArrayList arrayList = new ArrayList();
    arrayList.toArray();
    // 集合工具
    // 扩展工具类
  }