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


Java Multimaps.newListMultimap方法代码示例

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


在下文中一共展示了Multimaps.newListMultimap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: detectPotentialLocksCycle

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Algorithm to detect a potential lock cycle.
 *
 * For lock's thread owner check which lock is it trying to take.
 * Repeat recursively. When current thread is found a potential cycle is detected.
 *
 * @see CycleDetectingLock#lockOrDetectPotentialLocksCycle()
 */
private ListMultimap<Long, ID> detectPotentialLocksCycle() {
  final long currentThreadId = Thread.currentThread().getId();
  if (lockOwnerThreadId == null || lockOwnerThreadId == currentThreadId) {
    // if nobody owns this lock, lock cycle is impossible
    // if a current thread owns this lock, we let Guice to handle it
    return ImmutableListMultimap.of();
  }

  ListMultimap<Long, ID> potentialLocksCycle = Multimaps.newListMultimap(
      new LinkedHashMap<Long, Collection<ID>>(),
      new Supplier<List<ID>>() {
        @Override
        public List<ID> get() {
          return Lists.newArrayList();
        }
      });
  // lock that is a part of a potential locks cycle, starts with current lock
  ReentrantCycleDetectingLock lockOwnerWaitingOn = this;
  // try to find a dependency path between lock's owner thread and a current thread
  while (lockOwnerWaitingOn != null && lockOwnerWaitingOn.lockOwnerThreadId != null) {
    Long threadOwnerThreadWaits = lockOwnerWaitingOn.lockOwnerThreadId;
    // in case locks cycle exists lock we're waiting for is part of it
    potentialLocksCycle.putAll(threadOwnerThreadWaits,
        getAllLockIdsAfter(threadOwnerThreadWaits, lockOwnerWaitingOn));

    if (threadOwnerThreadWaits == currentThreadId) {
      // owner thread depends on current thread, cycle detected
      return potentialLocksCycle;
    }
    // going for the next thread we wait on indirectly
    lockOwnerWaitingOn = lockThreadIsWaitingOn.get(threadOwnerThreadWaits);
  }
  // no dependency path from an owner thread to a current thread
  return ImmutableListMultimap.of();
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:44,代码来源:CycleDetectingLock.java

示例2: testTransOldType2Multimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * 将原始写法转成Multimap
 */
@Test
public void testTransOldType2Multimap() {
    // 原始的实现形式
    Map<String, Collection<String>> hashMap = Maps.newHashMap();
    Collection<String> listStrs = Lists.newArrayList("aaa", "ccc", "bbb");
    hashMap.put("list_1", listStrs);

    // 转成Multimap
    ListMultimap<String, String> multiMap = Multimaps.newListMultimap(hashMap, LinkedList::new);
    System.out.println(multiMap);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:15,代码来源:MultimapsDemo.java

示例3: newLinkedHashListMultimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Creates a new, empty {@code ListMultimap} with the default initial capacities that uses a linked map internally.
 */
public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap() {
	return Multimaps.newListMultimap(Maps.<K, Collection<V>> newLinkedHashMap(), new Supplier<List<V>>() {
		@Override
		public List<V> get() {
			return Lists.newArrayList();
		}
	});
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:Multimaps2.java

示例4: createParamsMultimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
protected static Multimap<String, String> createParamsMultimap() {
    return Multimaps.<String, String> newListMultimap(new LinkedHashMap<String, Collection<String>>(),
            new Supplier<ArrayList<String>>() {
                @Override
                public ArrayList<String> get() {
                    return new ArrayList<String>();
                }
            });
}
 
开发者ID:pidoco,项目名称:juri,代码行数:10,代码来源:JURI.java

示例5: JobClassInfo

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public JobClassInfo(ProcessingEnvironment env) {
    mProcEnv = env;
    mErrorReporter = new ErrorReporter(env);
    mJobInfo = Multimaps.newListMultimap(
            new HashMap<String, Collection<FieldInfo>>(),
            new Supplier<List<FieldInfo>>() {
                @Override
                public List<FieldInfo> get() {
                    return Lists.newArrayList();
                }
            });
}
 
开发者ID:Dzhey,项目名称:DroidWorker,代码行数:13,代码来源:JobClassInfo.java

示例6: detectPotentialLocksCycle

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Algorithm to detect a potential lock cycle.
 *
 * <p>For lock's thread owner check which lock is it trying to take. Repeat recursively. When
 * current thread is found a potential cycle is detected.
 *
 * @see CycleDetectingLock#lockOrDetectPotentialLocksCycle()
 */
private ListMultimap<Thread, ID> detectPotentialLocksCycle() {
  final Thread currentThread = Thread.currentThread();
  if (lockOwnerThread == null || lockOwnerThread == currentThread) {
    // if nobody owns this lock, lock cycle is impossible
    // if a current thread owns this lock, we let Guice to handle it
    return ImmutableListMultimap.of();
  }

  ListMultimap<Thread, ID> potentialLocksCycle =
      Multimaps.newListMultimap(
          new LinkedHashMap<Thread, Collection<ID>>(),
          new Supplier<List<ID>>() {
            @Override
            public List<ID> get() {
              return Lists.newArrayList();
            }
          });
  // lock that is a part of a potential locks cycle, starts with current lock
  ReentrantCycleDetectingLock<?> lockOwnerWaitingOn = this;
  // try to find a dependency path between lock's owner thread and a current thread
  while (lockOwnerWaitingOn != null && lockOwnerWaitingOn.lockOwnerThread != null) {
    Thread threadOwnerThreadWaits = lockOwnerWaitingOn.lockOwnerThread;
    // in case locks cycle exists lock we're waiting for is part of it
    lockOwnerWaitingOn =
        addAllLockIdsAfter(threadOwnerThreadWaits, lockOwnerWaitingOn, potentialLocksCycle);
    if (threadOwnerThreadWaits == currentThread) {
      // owner thread depends on current thread, cycle detected
      return potentialLocksCycle;
    }
  }
  // no dependency path from an owner thread to a current thread
  return ImmutableListMultimap.of();
}
 
开发者ID:google,项目名称:guice,代码行数:42,代码来源:CycleDetectingLock.java

示例7: updateOsuDb

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Parses the current osu database.
 */
public void updateOsuDb() {
  try {
    OsuDbFile db = OsuDbFile.parse(settings.getOsuDbPath());
    Multimap<String, OsuBeatmapInfo> beatmaps =
        Multimaps.newListMultimap(new HashMap<>(), ArrayList::new);
    Stream.of(db.getBeatmaps()).forEach(
        map -> beatmaps.put(
            String.format("%s - %s [%s]", map.getArtistName(), map.getSongTitle(),
                map.getDifficulty()), map));
    this.beatmaps = beatmaps;
  } catch (Exception e) {
    log.error("error while reading osu db", e);
  }
}
 
开发者ID:OsuCelebrity,项目名称:OsuCelebrity,代码行数:18,代码来源:OsuApplication.java

示例8: getParticipantScores

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public Multimap<Participant, String> getParticipantScores() {
    Multimap<Participant, String> scores = Multimaps.newListMultimap(new ConcurrentHashMap<>(), ArrayList::new);
    for (Map.Entry<String, BattleMetaData> entry : battle.getInvolved().entrySet()) {
        Participant participant = DGData.PLAYER_R.fromId(entry.getKey());
        if (entry.getValue().hits > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.YELLOW + "Hits: " + ChatColor.WHITE +
                    entry.getValue().hits);
        }
        if (entry.getValue().kills > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.YELLOW + "Kills: " + ChatColor.WHITE +
                    entry.getValue().kills);
        }
        if (entry.getValue().deaths > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.YELLOW + "Deaths: " + ChatColor.WHITE +
                    entry.getValue().deaths);
        }
        if (entry.getValue().denies > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.YELLOW + "Denies: " + ChatColor.WHITE +
                    entry.getValue().denies);
        }
        if (entry.getValue().assists > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.YELLOW + "Assists: " + ChatColor.WHITE +
                    entry.getValue().assists);
        }
        if (entry.getValue().teamKills > 0) {
            scores.put(participant, ChatColor.DARK_GRAY + " ➥ " + ChatColor.RED + "Team kills: " + ChatColor.WHITE +
                    entry.getValue().teamKills);
        }
    }
    return scores;
}
 
开发者ID:DemigodsRPG,项目名称:DemigodsRPG,代码行数:32,代码来源:Report.java

示例9: result

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private static ListMultimap<String, ExprNode> result ()
{
    return Multimaps.newListMultimap(Maps.<String, Collection<ExprNode>>newHashMap(), new Supplier<List<ExprNode>>() {
        @Override
        public List<ExprNode> get ()
        {
            return new LinkedList<>();
        }
    });
}
 
开发者ID:impl,项目名称:yashiro,代码行数:11,代码来源:ContentParserBuilder.java

示例10: newCopyOnWritetListMultimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public static <K, V>ListMultimap<K, V> newCopyOnWritetListMultimap() {
    return Multimaps.newListMultimap(new ConcurrentHashMap<K, Collection<V>>(), new Supplier<List<V>>() {

        @Override
        public List<V> get() {
            return new CopyOnWriteArrayList<V>();
        }
    });
}
 
开发者ID:TechzoneMC,项目名称:TechUtils,代码行数:10,代码来源:Collections3.java

示例11: newLinkedKeyArrayValueMultimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private Multimap<K, String> newLinkedKeyArrayValueMultimap() {
  return Multimaps.newListMultimap(
      new LinkedHashMap<K, Collection<String>>(),
      new Supplier<List<String>>() {
        @Override public List<String> get() {
          return Lists.newArrayList();
        }
      });
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:10,代码来源:MapBinder.java

示例12: runWsimport

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Run wsimport on a WSDL file
 *
 * @param baseDir Base directory
 * @param wsdlFile WSDL file to compile
 */
protected void runWsimport(Path baseDir, Path wsdlFile) {
    JavaExecAction action = getActionFactory().newJavaExecAction();
    String packageName = Optional.ofNullable(wsdlFile.getParent()).map(p -> PACKAGE_JOINER.join(p)).orElse(null);

    Multimap<String, Object> options = Multimaps.newListMultimap(new HashMap<>(), () -> new ArrayList<>());

    if (packageName != null) {
        options.put("p", packageName);
    }

    options.put("wsdllocation", wsdlFile.getFileName().toString());
    options.put("s", getDestinationDir());
    options.put("extension", true);
    options.put("Xnocompile", true);
    options.put("B-classpath", getProject().getConfigurations().getAt("xjc").getAsPath());

    for (String extension : getXjcExtensions()) {
        options.put("B-X" + extension, true);
    }

    if (getProject().getLogger().isDebugEnabled()) {
        options.put("Xdebug", true);
    }
    else {
        options.put("quiet", true);
    }

    for (File bindingFile : Objects.requireNonNull(getBindings()).getFiles()) {
        if (bindingFile.isFile()) {
            options.put("b", bindingFile);
        }
    }

    List<String> arguments = createArguments(options);
    arguments.add(wsdlFile.toString());

    getLogger().debug("Running wsimport with arguments {}", Joiner.on(' ').join(arguments));

    action.setArgs(arguments);
    action.setClasspath(getProject().getConfigurations().getAt("jaxws"));
    action.setMain("com.sun.tools.ws.WsImport");
    action.setWorkingDir(baseDir.toFile());

    ExecResult result = action.execute();

    if (result.getExitValue() != 0) {
        throw new GradleException("Error running wsimport");
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-wsimport-plugin,代码行数:56,代码来源:WsimportTask.java

示例13: newMultimap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private static <T> Multimap<ModelProcessingPhase, T> newMultimap() {
    return Multimaps.newListMultimap(new EnumMap<>(ModelProcessingPhase.class), () -> new ArrayList<>(1));
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:4,代码来源:StatementContextBase.java

示例14: getMultiMap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public static <K,V> ListMultimap<K,V> getMultiMap(Class<V> clazz) {
	return Multimaps.newListMultimap(
			new HashMap<K, java.util.Collection<V>>(), () -> new ArrayList<V>(clazz));
}
 
开发者ID:Katharsas,项目名称:GMM,代码行数:5,代码来源:ArrayList.java

示例15: getMultiMap

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public static <K,V> Multimap<K,V> getMultiMap(Class<V> clazz) {
	return Multimaps.newListMultimap(
			new HashMap<K, java.util.Collection<V>>(), () -> new LinkedList<V>(clazz));
}
 
开发者ID:Katharsas,项目名称:GMM,代码行数:5,代码来源:LinkedList.java


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