Java 类com.google.common.collect.ImmutableSortedMap.Builder 实例源码

项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder =
      ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
    @Override public String getKey() {
      return holder.string;
    }
    @Override public Integer getValue() {
      return 1;
    }
  };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder =
      ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
    @Override public String getKey() {
      return holder.string;
    }
    @Override public Integer getValue() {
      return 1;
    }
  };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:blockplus    文件:Polyominos.java   
private Polyominos() {
    final Builder<String, Polyomino> typesBuilder = new ImmutableSortedMap.Builder<String, Polyomino>(Ordering.natural());
    final Builder<String, PolyominoInstance> instancesBuilder = new ImmutableSortedMap.Builder<String, PolyominoInstance>(Ordering.natural());
    final Set<Integer> radius = Sets.newTreeSet();
    for (final Polyomino polyomino : Polyomino.set()) {
        for (final PolyominoInstance instance : polyomino.get()) {
            final String representation = instance.toString();
            typesBuilder.put(representation, polyomino);
            instancesBuilder.put(representation, instance);
            radius.add(polyomino.radius());
        }
    }
    this.typeIndexes = typesBuilder.build();
    this.instanceIndexes = instancesBuilder.build();
    this.radiusIndexes = computeRadiusIndexes(radius);
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder =
      ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
    @Override public String getKey() {
      return holder.string;
    }
    @Override public Integer getValue() {
      return 1;
    }
  };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder =
      ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry = new AbstractMapEntry<String, Integer>() {
    @Override public String getKey() {
      return holder.string;
    }
    @Override public Integer getValue() {
      return 1;
    }
  };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:guava    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry =
      new AbstractMapEntry<String, Integer>() {
        @Override
        public String getKey() {
          return holder.string;
        }

        @Override
        public Integer getValue() {
          return 1;
        }
      };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:guava    文件:ImmutableSortedMapTest.java   
public void testBuilder_withMutableEntry() {
  ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  final StringHolder holder = new StringHolder();
  holder.string = "one";
  Entry<String, Integer> entry =
      new AbstractMapEntry<String, Integer>() {
        @Override
        public String getKey() {
          return holder.string;
        }

        @Override
        public Integer getValue() {
          return 1;
        }
      };

  builder.put(entry);
  holder.string = "two";
  assertMapEquals(builder.build(), "one", 1);
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilder_orderEntriesByValueFails() {
  ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.orderEntriesByValue(Ordering.natural());
    fail("Expected UnsupportedOperationException");
  } catch (UnsupportedOperationException expected) {}
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderReuse() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  ImmutableSortedMap<String, Integer> mapOne = builder
      .put("one", 1)
      .put("two", 2)
      .build();
  ImmutableSortedMap<String, Integer> mapTwo = builder
      .put("three", 3)
      .put("four", 4)
      .build();

  assertMapEquals(mapOne, "one", 1, "two", 2);
  assertMapEquals(mapTwo, "four", 4, "one", 1, "three", 3, "two", 2);
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put(null, 1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put("one", null);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKeyViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap(null, 1));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValueViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap("one", null));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String, Integer> builder
      = ImmutableSortedMap.<String, Integer>naturalOrder()
          .put("one", 1)
          .put("one", 2); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
  }
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderComparator() {
  Comparator<String> comparator = Ordering.natural().reverse();
  ImmutableSortedMap<String, Integer> map
      = new ImmutableSortedMap.Builder<String, Integer>(comparator)
          .put("one", 1)
          .put("two", 2)
          .put("three", 3)
          .put("four", 4)
          .put("five", 5)
          .build();
  assertMapEquals(map,
      "two", 2, "three", 3, "one", 1, "four", 4, "five", 5);
  assertSame(comparator, map.comparator());
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SelfComparable() {
  ImmutableSortedMap.Builder<SelfComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SelfComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:guava-mock    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SuperComparable() {
  ImmutableSortedMap.Builder<SuperComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SuperComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilder_orderEntriesByValueFails() {
  ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.orderEntriesByValue(Ordering.natural());
    fail("Expected UnsupportedOperationException");
  } catch (UnsupportedOperationException expected) {}
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderReuse() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  ImmutableSortedMap<String, Integer> mapOne = builder
      .put("one", 1)
      .put("two", 2)
      .build();
  ImmutableSortedMap<String, Integer> mapTwo = builder
      .put("three", 3)
      .put("four", 4)
      .build();

  assertMapEquals(mapOne, "one", 1, "two", 2);
  assertMapEquals(mapTwo, "four", 4, "one", 1, "three", 3, "two", 2);
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put(null, 1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put("one", null);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKeyViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap(null, 1));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValueViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap("one", null));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String, Integer> builder
      = ImmutableSortedMap.<String, Integer>naturalOrder()
          .put("one", 1)
          .put("one", 2); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
  }
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderComparator() {
  Comparator<String> comparator = Ordering.natural().reverse();
  ImmutableSortedMap<String, Integer> map
      = new ImmutableSortedMap.Builder<String, Integer>(comparator)
          .put("one", 1)
          .put("two", 2)
          .put("three", 3)
          .put("four", 4)
          .put("five", 5)
          .build();
  assertMapEquals(map,
      "two", 2, "three", 3, "one", 1, "four", 4, "five", 5);
  assertSame(comparator, map.comparator());
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SelfComparable() {
  ImmutableSortedMap.Builder<SelfComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SelfComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:googles-monorepo-demo    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SuperComparable() {
  ImmutableSortedMap.Builder<SuperComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SuperComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:blockplus    文件:Polyominos.java   
private static SortedMap<Integer, Set<Polyomino>> computeRadiusIndexes(final Set<Integer> radius) {
    final Map<Integer, ImmutableSortedSet.Builder<Polyomino>> tmpMap = Maps.newTreeMap();
    for (final Integer integer : radius)
        tmpMap.put(integer, new ImmutableSortedSet.Builder<Polyomino>(Ordering.natural()));
    for (final Polyomino polyomino : Polyomino.set())
        tmpMap.get(polyomino.radius()).add(polyomino);
    final Builder<Integer, Set<Polyomino>> builder = new ImmutableSortedMap.Builder<Integer, Set<Polyomino>>(Ordering.natural());
    for (final Entry<Integer, ImmutableSortedSet.Builder<Polyomino>> entry : tmpMap.entrySet())
        builder.put(entry.getKey(), entry.getValue().build());
    return builder.build();
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderReuse() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  ImmutableSortedMap<String, Integer> mapOne = builder
      .put("one", 1)
      .put("two", 2)
      .build();
  ImmutableSortedMap<String, Integer> mapTwo = builder
      .put("three", 3)
      .put("four", 4)
      .build();

  assertMapEquals(mapOne, "one", 1, "two", 2);
  assertMapEquals(mapTwo, "four", 4, "one", 1, "three", 3, "two", 2);
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put(null, 1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put("one", null);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKeyViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap(null, 1));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValueViaPutAll() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.putAll(Collections.<String, Integer>singletonMap("one", null));
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String, Integer> builder
      = ImmutableSortedMap.<String, Integer>naturalOrder()
          .put("one", 1)
          .put("one", 2); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderComparator() {
  Comparator<String> comparator = Ordering.natural().reverse();
  ImmutableSortedMap<String, Integer> map
      = new ImmutableSortedMap.Builder<String, Integer>(comparator)
          .put("one", 1)
          .put("two", 2)
          .put("three", 3)
          .put("four", 4)
          .put("five", 5)
          .build();
  assertMapEquals(map,
      "two", 2, "three", 3, "one", 1, "four", 4, "five", 5);
  assertSame(comparator, map.comparator());
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SelfComparable() {
  ImmutableSortedMap.Builder<SelfComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SelfComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderGenerics_SuperComparable() {
  ImmutableSortedMap.Builder<SuperComparableExample, Object> natural =
      ImmutableSortedMap.naturalOrder();

  ImmutableSortedMap.Builder<SuperComparableExample, Object> reverse =
      ImmutableSortedMap.reverseOrder();
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderReuse() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  ImmutableSortedMap<String, Integer> mapOne = builder
      .put("one", 1)
      .put("two", 2)
      .build();
  ImmutableSortedMap<String, Integer> mapTwo = builder
      .put("three", 3)
      .put("four", 4)
      .build();

  assertMapEquals(mapOne, "one", 1, "two", 2);
  assertMapEquals(mapTwo, "four", 4, "one", 1, "three", 3, "two", 2);
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullKey() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put(null, 1);
    fail();
  } catch (NullPointerException expected) {
  }
}
项目:guava-libraries    文件:ImmutableSortedMapTest.java   
public void testBuilderPutNullValue() {
  Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  try {
    builder.put("one", null);
    fail();
  } catch (NullPointerException expected) {
  }
}