当前位置: 首页>>代码示例>>Java>>正文


Java AnEnum类代码示例

本文整理汇总了Java中com.google.common.collect.testing.AnEnum的典型用法代码示例。如果您正苦于以下问题:Java AnEnum类的具体用法?Java AnEnum怎么用?Java AnEnum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnEnum类属于com.google.common.collect.testing包,在下文中一共展示了AnEnum类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIteratesOnce

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testIteratesOnce() {
  Map<AnEnum, AnEnum> map =
      Maps.asMap(
          ImmutableSet.of(AnEnum.A),
          new Function<AnEnum, AnEnum>() {
            boolean used = false;

            @Override
            public AnEnum apply(AnEnum ae) {
              checkState(!used, "should not be applied more than once");
              used = true;
              return ae;
            }
          });
  ImmutableMap<AnEnum, AnEnum> copy = Maps.immutableEnumMap(map);
  assertThat(copy.entrySet()).containsExactly(Helpers.mapEntry(AnEnum.A, AnEnum.A));
}
 
开发者ID:google,项目名称:guava,代码行数:18,代码来源:ImmutableEnumMapTest.java

示例2: create

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
public Multiset<AnEnum> create(Object... elements) {
  AnEnum[] array = new AnEnum[elements.length];
  int i = 0;
  for (Object e : elements) {
    array[i++] = (AnEnum) e;
  }
  return create(array);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:TestEnumMultisetGenerator.java

示例3: create

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
protected Map<AnEnum, String> create(Entry<AnEnum, String>[] entries) {
  Map<AnEnum, String> map = Maps.newHashMap();
  for (Entry<AnEnum, String> entry : entries) {
    // checkArgument(!map.containsKey(entry.getKey()));
    map.put(entry.getKey(), entry.getValue());
  }
  return Maps.immutableEnumMap(map);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:MapGenerators.java

示例4: order

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
public Iterable<Entry<AnEnum, String>> order(List<Entry<AnEnum, String>> insertionOrder) {
  return new Ordering<Entry<AnEnum, String>>() {

    @Override
    public int compare(Entry<AnEnum, String> left, Entry<AnEnum, String> right) {
      return left.getKey().compareTo(right.getKey());
    }
  }.sortedCopy(insertionOrder);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:MapGenerators.java

示例5: create

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
protected Map<AnEnum, String> create(Entry<AnEnum, String>[] entries) {
  Map<AnEnum, String> map = Maps.newHashMap();
  for (Entry<AnEnum, String> entry : entries) {
    map.put(entry.getKey(), entry.getValue());
  }
  return Maps.immutableEnumMap(map);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:ImmutableEnumMapTest.java

示例6: testImmutableEnumMapOrdering

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testImmutableEnumMapOrdering() {
  ImmutableMap<AnEnum, String> map = Maps.immutableEnumMap(
      ImmutableMap.of(AnEnum.C, "c", AnEnum.A, "a", AnEnum.E, "e"));

  assertThat(map.entrySet()).containsExactly(
      Helpers.mapEntry(AnEnum.A, "a"),
      Helpers.mapEntry(AnEnum.C, "c"),
      Helpers.mapEntry(AnEnum.E, "e")).inOrder();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:ImmutableEnumMapTest.java

示例7: testToImmutableEnumMap

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testToImmutableEnumMap() {
  Collector<Entry<AnEnum, Integer>, ?, ImmutableMap<AnEnum, Integer>> collector =
      Maps.toImmutableEnumMap(Entry::getKey, Entry::getValue);
  Equivalence<ImmutableMap<AnEnum, Integer>> equivalence =
      Equivalence.equals().<Entry<AnEnum, Integer>>pairwise().onResultOf(ImmutableMap::entrySet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          ImmutableMap.of(AnEnum.A, 1, AnEnum.C, 2, AnEnum.E, 3),
          mapEntry(AnEnum.A, 1),
          mapEntry(AnEnum.C, 2),
          mapEntry(AnEnum.E, 3));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:ImmutableEnumMapTest.java

示例8: testToImmutableMap_exceptionOnDuplicateKey

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testToImmutableMap_exceptionOnDuplicateKey() {
  Collector<Entry<AnEnum, Integer>, ?, ImmutableMap<AnEnum, Integer>> collector =
      Maps.toImmutableEnumMap(Entry::getKey, Entry::getValue);
  try {
    Stream.of(mapEntry(AnEnum.A, 1), mapEntry(AnEnum.A, 11)).collect(collector);
    fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException expected) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:ImmutableEnumMapTest.java

示例9: testToImmutableMapMerging

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testToImmutableMapMerging() {
  Collector<Entry<AnEnum, Integer>, ?, ImmutableMap<AnEnum, Integer>> collector =
      Maps.toImmutableEnumMap(Entry::getKey, Entry::getValue, Integer::sum);
  Equivalence<ImmutableMap<AnEnum, Integer>> equivalence =
      Equivalence.equals().<Entry<AnEnum, Integer>>pairwise().onResultOf(ImmutableMap::entrySet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          ImmutableMap.of(AnEnum.A, 1, AnEnum.B, 4, AnEnum.C, 3),
          mapEntry(AnEnum.A, 1),
          mapEntry(AnEnum.B, 2),
          mapEntry(AnEnum.C, 3),
          mapEntry(AnEnum.B, 2));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:14,代码来源:ImmutableEnumMapTest.java

示例10: enumMultisetGenerator

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
private static TestEnumMultisetGenerator enumMultisetGenerator() {
  return new TestEnumMultisetGenerator() {
    @Override protected Multiset<AnEnum> create(AnEnum[] elements) {
      return (elements.length == 0)
          ? EnumMultiset.create(AnEnum.class)
          : EnumMultiset.create(asList(elements));
    }
  };
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:EnumMultisetTest.java

示例11: create

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
protected Map<AnEnum, String> create(Entry<AnEnum, String>[] entries) {
  Map<AnEnum, String> map = new HashMap<AnEnum, String>();
  for (Entry<AnEnum, String> entry : entries) {
    map.put(entry.getKey(), entry.getValue());
  }
  return Immutables.immutableEnumMap(map);
}
 
开发者ID:ypresto,项目名称:miniguava,代码行数:9,代码来源:ImmutableEnumMapTest.java

示例12: testImmutableEnumMapOrdering

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
public void testImmutableEnumMapOrdering() {
  ImmutableMap<AnEnum, String> map = Immutables.immutableEnumMap(
      ImmutableMap.of(AnEnum.C, "c", AnEnum.A, "a", AnEnum.E, "e"));

  assertThat(map.entrySet()).containsExactly(
      Helpers.mapEntry(AnEnum.A, "a"),
      Helpers.mapEntry(AnEnum.C, "c"),
      Helpers.mapEntry(AnEnum.E, "e")).inOrder();
}
 
开发者ID:ypresto,项目名称:miniguava,代码行数:10,代码来源:ImmutableEnumMapTest.java

示例13: order

import com.google.common.collect.testing.AnEnum; //导入依赖的package包/类
@Override
public Iterable<Entry<AnEnum, String>> order(List<Entry<AnEnum, String>> insertionOrder) {
  return new Ordering<Entry<AnEnum, String>>() {

    @Override
    public int compare(Entry<AnEnum, String> left, Entry<AnEnum, String> right) {
      return left.getKey().compareTo(right.getKey());
    }

  }.sortedCopy(insertionOrder);
}
 
开发者ID:sander120786,项目名称:guava-libraries,代码行数:12,代码来源:MapGenerators.java


注:本文中的com.google.common.collect.testing.AnEnum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。