本文整理匯總了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;
}
示例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();
}
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例9: getUnresolvedVendorSpecificProperties
public Map getUnresolvedVendorSpecificProperties() {
return Collections.EMPTY_MAP;
}
示例10: getAttachments
@Override
public Map<String, String> getAttachments() {
return attachments != null ? attachments : Collections.EMPTY_MAP;
}
示例11: getUnresolvedVendorSpecificProperties
@Override
public Map getUnresolvedVendorSpecificProperties() {
return Collections.EMPTY_MAP;
}
示例12: CollectionSecondPass
public CollectionSecondPass(Mappings mappings, Collection collection) {
this(mappings, collection, Collections.EMPTY_MAP);
}
示例13: getUsersMap
public Map getUsersMap() throws CommandStoppedException {
return Collections.EMPTY_MAP;
}
示例14: ProxyServlet
public ProxyServlet(String name, Servlet servlet) {
this(name, servlet, Collections.EMPTY_MAP, true);
}
示例15: getBuildRunAttributes
/**
* {@inheritDoc}
*/
public Map getBuildRunAttributes() throws IOException, AgentFailureException {
return Collections.EMPTY_MAP;
}