本文整理汇总了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;
}