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


Java Collections.EMPTY_MAP属性代码示例

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


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

示例1: classify

/**
 * source转Map,Key为propertyName对应的值,Value为source中propertyName属性值相同的元素
 * @param source 源
 * @param propertyName 属性名
 * @param <K> propertyName对应的属性的类型
 * @param <V> source集合元素类型
 * @return 分类Map
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <K, V> Map<K, List<V>> classify(Collection<V> source, String propertyName) {
	if (CollectionUtils.isEmpty(source)) {
		return Collections.EMPTY_MAP;
	}
	Map result = new HashMap();

	for (Object obj : source) {
		Object value = getValue(propertyName, obj);
		Object target = result.get(value);
		if (target != null) {
			((List) target).add(obj);
		} else {
			List list = new ArrayList();
			list.add(obj);
			result.put(value, list);
		}
	}
	return result;
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:28,代码来源:JpaUtil.java

示例2: removeOldMappings

private void removeOldMappings(Collection presentKeys, RegionEntry entry) throws IMQException {
  Map oldKeysAndValuesForEntry = entryToMapKeyIndexKeyMap.get(entry);
  if (oldKeysAndValuesForEntry == null) {
    oldKeysAndValuesForEntry = Collections.EMPTY_MAP;
  }
  Set<Entry> removedKeyValueEntries = oldKeysAndValuesForEntry != null
      ? oldKeysAndValuesForEntry.entrySet() : Collections.EMPTY_SET;
  Iterator<Entry> iterator = removedKeyValueEntries.iterator();
  while (iterator.hasNext()) {
    Entry keyValue = iterator.next();
    Object indexKey = keyValue.getKey() == null ? IndexManager.NULL : keyValue.getKey();
    if (!presentKeys.contains(indexKey)) {
      CompactRangeIndex rg = (CompactRangeIndex) this.mapKeyToValueIndex.get(keyValue.getKey());
      rg.removeMapping(keyValue.getValue(), entry);
      iterator.remove();
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:CompactMapRangeIndex.java

示例3: compareTokens

static Map<Object, CharSequence[]> compareTokens(TokenHierarchy hierarchy0, TokenHierarchy hierarchy1) {
    Map result = new HashMap<Integer, String[]>();
    TokenSequence ts0 = hierarchy0.tokenSequence(JavaTokenId.language());
    TokenSequence ts1 = hierarchy1.tokenSequence(JavaTokenId.language());
    while (ts0.moveNext()) {
        if (ts1.moveNext()) {
            if (!TokenUtilities.equals(ts0.token().text(), ts1.token().text())) {
               result.put(ts0.token().id(), new CharSequence[] { ts0.token().text(), ts1.token().text() });
            }
        }
    }
    if (result.size() > 0) {
       return result;
    } else {
       return Collections.EMPTY_MAP;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TreeChecker.java

示例4: returnsValidMapByNetworkId

@Test
public void returnsValidMapByNetworkId() {
    final NetworkResult networkResult1 = new NetworkResult("network1", true, Collections.EMPTY_MAP);
    final NetworkResult networkResult2 = new NetworkResult("network2", true, Collections.EMPTY_MAP);
    final NetworkResult networkResult3 = new NetworkResult("network3", true, Collections.EMPTY_MAP);

    final List<NetworkResult> networkResults = Arrays.asList(networkResult1, networkResult2, networkResult3);

    portScannerResult.setNetworkResults(networkResults);

    assertThat(portScannerResult.numberOfResults()).as("number of results").isEqualTo(3);

    Map<String, NetworkResult> networkResultMap = portScannerResult.mapNetworkResultsByNetworkId();

    assertThat(networkResultMap.size()).as("map size incorrect").isEqualTo(3);
    Assertions.assertThat(networkResultMap.values()).as("should contain network1, network2, network3").contains(networkResult1, networkResult2, networkResult3);
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:17,代码来源:PortScannerResultTest.java

示例5: testArguments

@Test(expected = IllegalArgumentException.class)
public void testArguments() {
    // given
    Map<Area, ColorModel> previous = Collections.EMPTY_MAP;
    Map<Area, ColorModel> current = ImmutableMap.of(new Area(1, 2), ColorModel.createFromRgba(0, 1, 2, 3), new Area(11, 12),
            ColorModel.createFromRgba(10, 11, 12, 13));

    // when
    comparator.findDifference(previous, current);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:AreasMapsComparatorJUnitTest.java

示例6: getHeaderFields

/**
 * Returns an unmodifiable Map of the header fields.
 */
public Map getHeaderFields() {

  if (!connected) {
      // Try to connect (silently)
      try {
          connect();
      } catch (IOException e) {
      }
  }

  if (attributes == null)
      return (Collections.EMPTY_MAP);

  HashMap headerFields = new HashMap(attributes.size());
  NamingEnumeration attributeEnum = attributes.getIDs();
  try {
      while (attributeEnum.hasMore()) {
          String attributeID = (String)attributeEnum.next();
          Attribute attribute = attributes.get(attributeID);
          if (attribute == null) continue;
          ArrayList attributeValueList = new ArrayList(attribute.size());
          NamingEnumeration attributeValues = attribute.getAll();
          while (attributeValues.hasMore()) {
              Object attrValue = attributeValues.next();
              attributeValueList.add(getHeaderValueAsString(attrValue));
          }
          attributeValueList.trimToSize(); // should be a no-op if attribute.size() didn't lie
          headerFields.put(attributeID, Collections.unmodifiableList(attributeValueList));
      }
  } catch (NamingException ne) {
        // Shouldn't happen
  }

  return Collections.unmodifiableMap(headerFields);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:DirContextURLConnection.java

示例7: getParameters

public Map<String, String[]> getParameters() {
    if (fields == null) {
        return Collections.EMPTY_MAP;
    }
    Map<String, String[]> map = new LinkedHashMap<>(fields.size());
    for (Map.Entry<String, List> entry : fields.entrySet()) {
        List list = entry.getValue();
        String[] values = new String[list.size()];
        for (int i = 0; i < values.length; i++) {
            values[i] = list.get(i) + "";
        }
        map.put(entry.getKey(), values);
    }
    return map;
}
 
开发者ID:intuit,项目名称:karate,代码行数:15,代码来源:HttpBody.java

示例8: index

/**
 * source转Map,Key为source元素的propertyName属性值,Value为该元素
 * @param source 源集合
 * @param propertyName 属性名
 * @param <K> propertyName对应的属性的类型
 * @param <V> source集合元素类型
 * @return 索引Map
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <K, V> Map<K, V> index(Collection<V> source, String propertyName) {
	if (CollectionUtils.isEmpty(source)) {
		return Collections.EMPTY_MAP;
	}
	Map result = new HashMap();

	for (Object obj : source) {
		Object value = getValue(propertyName, obj);

		result.put(value, obj);
	}
	return result;
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:22,代码来源:JpaUtil.java

示例9: getUnresolvedVendorSpecificProperties

public Map getUnresolvedVendorSpecificProperties() {
    return Collections.EMPTY_MAP;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:3,代码来源:DefaultProvider.java

示例10: getAttachments

@Override
public Map<String, String> getAttachments() {
    return attachments != null ? attachments : Collections.EMPTY_MAP;
}
 
开发者ID:TFdream,项目名称:mango,代码行数:4,代码来源:DefaultRequest.java

示例11: getUnresolvedVendorSpecificProperties

@Override
public Map getUnresolvedVendorSpecificProperties() {
    return Collections.EMPTY_MAP;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:HibernateProvider.java

示例12: CollectionSecondPass

public CollectionSecondPass(Mappings mappings, Collection collection) {
	this(mappings, collection, Collections.EMPTY_MAP);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:3,代码来源:CollectionSecondPass.java

示例13: getUsersMap

public Map getUsersMap() throws CommandStoppedException {
  return Collections.EMPTY_MAP;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:3,代码来源:AccurevVersionControl.java

示例14: ProxyServlet

public ProxyServlet(String name, Servlet servlet) {
    this(name, servlet, Collections.EMPTY_MAP, true);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:3,代码来源:ProxyServlet.java

示例15: getBuildRunAttributes

/**
 * {@inheritDoc}
 */
public Map getBuildRunAttributes() throws IOException, AgentFailureException {
  return Collections.EMPTY_MAP;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:6,代码来源:AbstractSourceControl.java


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