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


Java MapUtils.invertMap方法代码示例

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


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

示例1: checkNewComponents

import org.apache.commons.collections4.MapUtils; //导入方法依赖的package包/类
/**
 * Check the required components we need to create before the changes
 */
private void checkNewComponents(final ImportContext context, final ImportStatus result, final int jira) {
	log.info("Get existing components");
	context.existingComponents = MapUtils.invertMap(jiraDao.getComponents(context.dataSource, jira));
	context.newComponentsAsSet = computeDiff(context.existingComponents, context.completeComponents);
	result.setNewComponents(context.newComponentsAsSet.size());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:10,代码来源:JiraImportPluginResource.java

示例2: validateRequiredData

import org.apache.commons.collections4.MapUtils; //导入方法依赖的package包/类
private void validateRequiredData(final ImportStatus result, final ImportContext context) {
	// Collect of foreign keys to validate/complete and initialize the
	// business objects
	log.info("Collect required data for the {} issues", context.issues.size());
	final List<ImportEntry> rawEntries = context.rawEntries;
	completeContext(result, rawEntries, context);
	final Set<String> requiredStatuses = context.requiredStatuses;
	final Set<String> requiredPriorities = context.requiredPriorities;
	final Set<String> requiredTypes = context.requiredTypes;
	final Set<String> requiredUsers = context.requiredUsers;
	final Set<String> requiredCustomFields = context.requiredCustomFields;
	final Set<String> requiredResolutions = context.requiredResolutions;
	result.setPriorities(requiredPriorities.size());
	result.setStatuses(requiredStatuses.size());
	result.setTypes(requiredTypes.size());
	result.setUsers(requiredUsers.size());
	result.setCustomFields(requiredCustomFields.size());
	result.setResolutions(requiredResolutions.size());
	result.setVersions(context.completeVersions.size());
	result.setComponents(context.completeComponents.size());
	nextStep(result);

	// Get and check mandatory links
	log.info("Load and check required data ...");
	log.info("... Statuses");
	context.statuses = jiraDao.getStatuses(context.dataSource, new ArrayList<>(), requiredStatuses);
	context.invertedStatuses = MapUtils.invertMap(context.statuses);
	checkRequired(FIELD_STATUS, "statuses", context.invertedStatuses, requiredStatuses);
	nextStep(result);

	log.info("... Priorities");
	context.priorities = MapUtils.invertMap(jiraDao.getPriorities(context.dataSource));
	checkRequired("priority", "priorities", context.priorities, requiredPriorities);
	nextStep(result);

	log.info("... Resolutions");
	context.resolutions = MapUtils.invertMap(jiraDao.getResolutions(context.dataSource));
	checkRequired(FIELD_RESOLUTION, "resolutions", context.resolutions, requiredResolutions);
	nextStep(result);

	log.info("... Types");
	context.types = MapUtils.invertMap(jiraDao.getTypes(context.dataSource, result.getJira()));
	checkRequired("type", "types", context.types, requiredTypes);
	nextStep(result);

	log.info("... Custom fields definition");
	context.customFields = jiraDao.getCustomFields(context.dataSource, requiredCustomFields, result.getJira());
	checkCustomFields(rawEntries, requiredCustomFields, context.customFields);
	nextStep(result);

	log.info("... Users");
	checkUsers(context.dataSource, requiredUsers);
	nextStep(result);

	// Convert text to identifiers
	log.info("Convert texts to identifiers");
	convertTextToId(rawEntries, context);
	nextStep(result);

	// Compare changes for at least on change each line for each issue
	log.info("Compute changes");
	context.changes = checkChanges(rawEntries);
	nextStep(result);

	// Compute labels
	log.info("Compute labels");
	result.setLabels(computeNbLabels(context.changes));
	nextStep(result);
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:70,代码来源:JiraImportPluginResource.java

示例3: checkNewVersions

import org.apache.commons.collections4.MapUtils; //导入方法依赖的package包/类
private void checkNewVersions(final ImportContext context, final ImportStatus result, final int jira) {
	log.info("Get existing versions");
	context.existingVersions = MapUtils.invertMap(jiraDao.getVersions(context.dataSource, jira));
	context.newVersionsAsSet = computeDiff(context.existingVersions, context.completeVersions);
	result.setNewVersions(context.newVersionsAsSet.size());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:7,代码来源:JiraImportPluginResource.java

示例4: invertMap

import org.apache.commons.collections4.MapUtils; //导入方法依赖的package包/类
/**
 * 将 <code>map</code> 的key和value互转.
 * 
 * <h3>说明:</h3>
 * <blockquote>
 * <ol>
 * <li><span style="color:red">这个操作map预先良好的定义</span>.</li>
 * <li>如果传过来的map,不同的key有相同的value,那么返回的map(key)只会有一个(value),其他重复的key被丢掉了</li>
 * </ol>
 * </blockquote>
 * 
 * <h3>示例:</h3>
 * <blockquote>
 * 
 * <pre class="code">
 * Map{@code <String, Integer>} map = new HashMap{@code <>}();
 * map.put("a", 3007);
 * map.put("b", 3001);
 * map.put("c", 3001);
 * map.put("d", 3003);
 * LOGGER.debug(JsonUtil.format(MapUtil.invertMap(map)));
 * </pre>
 * 
 * <b>返回:</b>
 * 
 * <pre class="code">
 * {
 * "3001": "c",
 * "3007": "a",
 * "3003": "d"
 * }
 * </pre>
 * 
 * 可以看出 b元素被覆盖了
 * 
 * </blockquote>
 * 
 * @param <K>
 *            the key type
 * @param <V>
 *            the value type
 * @param map
 *            the map
 * @return 如果<code>map</code> 是null,返回 null<br>
 *         如果<code>map</code> 是empty,返回 一个 new HashMap
 * @see org.apache.commons.collections4.MapUtils#invertMap(Map)
 * @since 1.2.2
 */
public static <K, V> Map<V, K> invertMap(Map<K, V> map){
    return null == map ? null : MapUtils.invertMap(map);//返回的是 HashMap
}
 
开发者ID:venusdrogon,项目名称:feilong-core,代码行数:52,代码来源:MapUtil.java


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