Package com.google.common.collect

Examples of com.google.common.collect.MapMaker


        (Function<K, Set<V>>) CREATE_HASH_SET);
  }

  @SuppressWarnings({ "unchecked" })
  public static <K> Map<K, AtomicLong> newAtomicLongValueMap() {
    return new MapMaker().makeComputingMap(
          new Function<K, AtomicLong>() {
            @Override
            public AtomicLong apply(K from) {
              return new AtomicLong(0L);
            }
View Full Code Here


      );
  }

  @SuppressWarnings({ "unchecked" })
  public static <K> Map<K, AtomicInteger> newAtomicIntValuedMap() {
    return new MapMaker().makeComputingMap(
          new Function<K, AtomicInteger>() {
            @Override
            public AtomicInteger apply(K from) {
              return new AtomicInteger(0);
            }
View Full Code Here

      );
  }

  public static <K> Map<K, AtomicBoolean> newAtomicBooleanValuedMap(
      final Boolean initialDefaultValue) {
    return new MapMaker().makeComputingMap(
          new Function<K, AtomicBoolean>() {
            @Override
            public AtomicBoolean apply(K from) {
              return new AtomicBoolean(initialDefaultValue);
            }
View Full Code Here

   * {@link GimletMaps#newExistingUniqueKeyMap()}.
   */
  @SuppressWarnings({"unchecked"})
  public static <K1, K2, V> Map<K1, Map<K2, V>>
  newExistingUniqueKeyMapValuedMap() {
    return new MapMaker().makeComputingMap(
        (Function<K1, Map<K2, V>>) CREATE_EXISTING_UNIQUE_KEY_MAP);
  }
View Full Code Here

    private final ConcurrentNavigableMap<Long, ITaskManagerHook> taskManagerRemovalRegister;
    private final ConcurrentMap<ITaskManagerHook, Long> taskManagerRemovalBackRegister;

    public DefaultTaskManager() {
        this.executorService = Executors.newCachedThreadPool();
        this.taskManagerHooks = new MapMaker().weakValues().makeMap();
        this.taskManagerRemovalRegister = new ConcurrentSkipListMap<Long, ITaskManagerHook>();
        this.taskManagerRemovalBackRegister = new MapMaker().weakKeys().makeMap();
    }
View Full Code Here

    // ================================ helper method ==========================

    private void initTables(final JdbcTemplate jdbcTemplate) {
        // soft引用设置,避免内存爆了
        GenericMapMaker mapMaker = null;
        mapMaker = new MapMaker().softValues().evictionListener(new MapEvictionListener<List<String>, Table>() {

            public void onEviction(List<String> names, Table table) {
                logger.warn("Eviction For Table:" + table);
            }
        });
View Full Code Here

    // 第一层tableId,第二层schema.table,解决tableId重复,对应多张表
    private Map<String, TableMeta> tableMetaCache;

    public TableMetaCache(MysqlConnection con){
        this.connection = con;
        tableMetaCache = new MapMaker().makeComputingMap(new Function<String, TableMeta>() {

            public TableMeta apply(String name) {
                try {
                    return getTableMeta0(name);
                } catch (IOException e) {
View Full Code Here

  }

  @Test
  public void updateJohnDoeApplicationDataSettingCountTo5() throws Exception {
    // Do update
    Map<String, String> values = new MapMaker().makeMap();
    values.put("count", "5");
    this.appDataServiceDb.updatePersonData(new UserId(Type.userId, "john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, SpiTestUtil.asSet("count"), values, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);

    // Verify that update succeeded
    Future<DataCollection> results = this.appDataServiceDb.getPersonData(SpiTestUtil.buildUserIds("john.doe"), new GroupId(GroupId.Type.self, "@self"), DEFAULT_APPLICATION_ID, null, SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
View Full Code Here

   * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,
   *      com.thoughtworks.xstream.converters.UnmarshallingContext)
   */
  @Override
  public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Map<String, Object> m = new MapMaker().makeMap();
    reader.moveDown();
    while (reader.hasMoreChildren()) {
      String key = reader.getNodeName();
      if ("entry".equals(key)) {
        Object value = null;
View Full Code Here

   * Hook into the post load event in JPA to take the database fields and load
   * the transient fields prior to making the object available to java.
   */
  @PostLoad
  public void loadTransientFields() {
    templateParams = new MapMaker().makeMap();
    for (Entry<String, ActivityTemplateParamsDb> e : templateParamsDb
        .entrySet()) {
      templateParams.put(e.getKey(), e.getValue().value);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.common.collect.MapMaker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.