Java Code Examples for java.util.Collections.EMPTY_MAP

The following are Jave code examples for showing how to use EMPTY_MAP of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: linq   File: JpaUtil.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 2
Project: monarch   File: CompactMapRangeIndex.java   View Source Code Vote up 6 votes
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();
    }
  }
}
 
Example 3
Project: incubator-netbeans   File: TreeChecker.java   View Source Code Vote up 6 votes
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;
    }
}
 
Example 4
Project: tifoon   File: PortScannerResultTest.java   View Source Code Vote up 6 votes
@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);
}
 
Example 5
Project: empiria.player   File: AreasMapsComparatorJUnitTest.java   View Source Code Vote up 5 votes
@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);
}
 
Example 6
Project: lams   File: DirContextURLConnection.java   View Source Code Vote up 5 votes
/**
 * 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);

}
 
Example 7
Project: karate   File: HttpBody.java   View Source Code Vote up 5 votes
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;
}
 
Example 8
Project: linq   File: JpaUtil.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 9
Project: incubator-netbeans   File: DefaultProvider.java   View Source Code Vote up 4 votes
public Map getUnresolvedVendorSpecificProperties() {
    return Collections.EMPTY_MAP;
}
 
Example 10
Project: mango   File: DefaultRequest.java   View Source Code Vote up 4 votes
@Override
public Map<String, String> getAttachments() {
    return attachments != null ? attachments : Collections.EMPTY_MAP;
}
 
Example 11
Project: incubator-netbeans   File: HibernateProvider.java   View Source Code Vote up 4 votes
@Override
public Map getUnresolvedVendorSpecificProperties() {
    return Collections.EMPTY_MAP;
}
 
Example 12
Project: lams   File: CollectionSecondPass.java   View Source Code Vote up 4 votes
public CollectionSecondPass(Mappings mappings, Collection collection) {
	this(mappings, collection, Collections.EMPTY_MAP);
}
 
Example 13
Project: parabuild-ci   File: AccurevVersionControl.java   View Source Code Vote up 4 votes
public Map getUsersMap() throws CommandStoppedException {
  return Collections.EMPTY_MAP;
}
 
Example 14
Project: lemon   File: ProxyServlet.java   View Source Code Vote up 4 votes
public ProxyServlet(String name, Servlet servlet) {
    this(name, servlet, Collections.EMPTY_MAP, true);
}
 
Example 15
Project: parabuild-ci   File: AbstractSourceControl.java   View Source Code Vote up 4 votes
/**
 * {@inheritDoc}
 */
public Map getBuildRunAttributes() throws IOException, AgentFailureException {
  return Collections.EMPTY_MAP;
}
 
Example 16
Project: parabuild-ci   File: AccurevVersionControlwithWorkspaces.java   View Source Code Vote up 4 votes
/**
 * {@inheritDoc}
 */
public Map getShellVariables() throws IOException {
  return Collections.EMPTY_MAP;
}
 
Example 17
Project: parabuild-ci   File: AccurevVersionControl.java   View Source Code Vote up 4 votes
/**
 * {@inheritDoc}
 */
public Map getShellVariables() throws IOException {
  return Collections.EMPTY_MAP;
}
 
Example 18
Project: springboot-shiro-cas-mybatis   File: DefaultPrincipalFactory.java   View Source Code Vote up 4 votes
@Override
public Principal createPrincipal(final String id) {
    return new SimplePrincipal(id, Collections.EMPTY_MAP);
}
 
Example 19
Project: cas-server-4.2.1   File: SimplePrincipal.java   View Source Code Vote up 2 votes
/**
 * Instantiates a new simple principal.
 *
 * @param id the id
 */
private SimplePrincipal(final String id) {
    this(id, Collections.EMPTY_MAP);
}
 
Example 20
Project: parabuild-ci   File: AbstractCommandBasedSourceControl.java   View Source Code Vote up 2 votes
/**
 * Returns a map containing version control user names as keys
 * and e-mails as values. This method doesn't throw exceptions
 * as it's failure is not critical but it reports errors by
 * calling to ErrorManager.
 *
 * @see ErrorManagerFactory
 * @see ErrorManager
 */
public final Map getUsersMap() {
  return Collections.EMPTY_MAP;
}