當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。