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


Java Collections.unmodifiableMap方法代码示例

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


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

示例1: of

import java.util.Collections; //导入方法依赖的package包/类
public static <K, V> Map<K, V> of(
    K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
  Map<K, V> map = new HashMap<>(5);
  map.put(k1, v1);
  map.put(k2, v2);
  map.put(k3, v3);
  map.put(k4, v4);
  map.put(k5, v5);
  return Collections.unmodifiableMap(map);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ImmutableMap.java

示例2: testIsReadOnly04

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Tests that the readOnly is true always when the map is not modifiable.
 */
@Test
public void testIsReadOnly04() {
    MapELResolver mapELResolver = new MapELResolver();
    ELContext context = new ELContextImpl();

    Map<Object, Object> map = Collections
            .unmodifiableMap(new HashMap<Object, Object>());
    boolean result = mapELResolver.isReadOnly(context, map, new Object());

    Assert.assertTrue(result);
    Assert.assertTrue(context.isPropertyResolved());
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:16,代码来源:TestMapELResolver.java

示例3: index

import java.util.Collections; //导入方法依赖的package包/类
private static Map<Label, BasicBlock> index(Iterable<BasicBlock> blocks) {
  Map<Label, BasicBlock> result = new HashMap<>();
  for (BasicBlock b : blocks) {
    result.put(b.label(), b);
  }
  return Collections.unmodifiableMap(result);
}
 
开发者ID:kroepke,项目名称:luna,代码行数:8,代码来源:Code.java

示例4: updatePortsWithNewPortsByNumber

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Set the internal data structure storing this switch's port
 * to the ports specified by newPortsByNumber
 *
 * CALLER MUST HOLD WRITELOCK
 *
 * @param newPortsByNumber
 * @throws IllegaalStateException if called without holding the
 * writelock
 */
private void updatePortsWithNewPortsByNumber(
		Map<OFPort,OFPortDesc> newPortsByNumber) {
	if (!lock.writeLock().isHeldByCurrentThread()) {
		throw new IllegalStateException("Method called without " +
				"holding writeLock");
	}
	Map<String,OFPortDesc> newPortsByName =
			new HashMap<String, OFPortDesc>();
	List<OFPortDesc> newPortList =
			new ArrayList<OFPortDesc>();
	List<OFPortDesc> newEnabledPortList =
			new ArrayList<OFPortDesc>();
	List<OFPort> newEnabledPortNumbers = new ArrayList<OFPort>();

	for(OFPortDesc p: newPortsByNumber.values()) {
		newPortList.add(p);
		newPortsByName.put(p.getName().toLowerCase(), p);
		if (!p.getState().contains(OFPortState.LINK_DOWN) 
				&& !p.getConfig().contains(OFPortConfig.PORT_DOWN)) {
			newEnabledPortList.add(p);
			newEnabledPortNumbers.add(p.getPortNo());
		}
	}
	portsByName = Collections.unmodifiableMap(newPortsByName);
	portsByNumber =
			Collections.unmodifiableMap(newPortsByNumber);
	enabledPortList =
			Collections.unmodifiableList(newEnabledPortList);
	enabledPortNumbers =
			Collections.unmodifiableList(newEnabledPortNumbers);
	portList = Collections.unmodifiableList(newPortList);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:43,代码来源:OFSwitch.java

示例5: getResponseHeaders

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Get a copy of all <em>response</em> headers.
 *
 * @return Never {@code null}.
 */
public Map<String, List<String>> getResponseHeaders() {
    Map<String, List<String>> responseHeaders = threadLocal.get().responseHeaders;
    HashMap<String, List<String>> map = new HashMap<>(responseHeaders.size());

    for (Map.Entry<String, List<String>> entry : responseHeaders.entrySet()) {
        map.put(entry.getKey(), Collections.unmodifiableList(entry.getValue()));
    }

    return Collections.unmodifiableMap(map);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ThreadContext.java

示例6: StandardJavascriptLibrary

import java.util.Collections; //导入方法依赖的package包/类
public StandardJavascriptLibrary()
{
	List<JavascriptModule> modules = new ArrayList<JavascriptModule>();
	modules.add(new StandardModule());
	modules.add(new JSONModule());
	modules.add(new SelectModule());

	Map<String, JavascriptModule> tempModuleMap = new HashMap<String, JavascriptModule>();
	for( JavascriptModule module : modules )
	{
		tempModuleMap.put(module.getId(), module);
	}
	moduleMap = Collections.unmodifiableMap(tempModuleMap);
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:StandardJavascriptLibrary.java

示例7: Notify

import java.util.Collections; //导入方法依赖的package包/类
public Notify(Type type, long notifyTime, DtoChanges dtoChanges, URL url, Map<String, Object> json) {
    _type = type;
    _notifyTime = notifyTime;
    _targetVersion = dtoChanges.getTargetVersion().toString();
    _targetTime = dtoChanges.getTargetTime();
    _dtoChanges = Collections.unmodifiableMap(json);
    _uri = url.toString();
    _rawDtoChanges = dtoChanges;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:10,代码来源:Notify.java

示例8: getTextTypeToNative

import java.util.Collections; //导入方法依赖的package包/类
/**
 * An accessor to textTypeToNative map.  Since we use lazy initialization we
 * must use this accessor instead of direct access to the field which may not
 * be initialized yet. This method will initialize the field if needed.
 *
 * @return textTypeToNative
 */
private synchronized Map<String, LinkedHashSet<String>> getTextTypeToNative() {
    if (!isMapInitialized) {
        initSystemFlavorMap();
        // From this point the map should not be modified
        textTypeToNative = Collections.unmodifiableMap(textTypeToNative);
    }
    return textTypeToNative;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SystemFlavorMap.java

示例9: parseToMap

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Parse specified sql template to immutable map of templates. Name of template is a key for map.
 * @param text template
 * @return map with (template.name, template) entries.
 * @throws IOException
 */
public Map<String, SqlTemplate> parseToMap(Reader text) throws IOException {
    Map<String, SqlTemplate> map = new HashMap<>();
    parse(text, (template) -> {
        map.put(template.getName(), template);
    });
    return Collections.unmodifiableMap(map);
}
 
开发者ID:wayerr,项目名称:sqlfiles,代码行数:14,代码来源:SqlParser.java

示例10: getAllFields

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Get a simple map containing all the fields.
 */
public Map<FieldDescriptorType, Object> getAllFields() {
  return Collections.unmodifiableMap(fields);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:7,代码来源:FieldSet.java

示例11: getAttributes

import java.util.Collections; //导入方法依赖的package包/类
/** Returns an unmodifiable view on the string-to-string map of additional attributes. */
public Map<String,String> getAttributes() {
    return Collections.unmodifiableMap(this.attributeMap);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:5,代码来源:AttrNode.java

示例12: getPropertyValues

import java.util.Collections; //导入方法依赖的package包/类
public Map<String, String> getPropertyValues() {
    return Collections.unmodifiableMap(propertyValues);
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:4,代码来源:PropertyInstance.java

示例13: Beans

import java.util.Collections; //导入方法依赖的package包/类
private Beans(TableMap<T> annotations, Map<String, Bean<T, Object>> map) {
    this.properties = new DynamoDbMapperTableModel.Properties.Immutable<T>(annotations);
    this.map = Collections.unmodifiableMap(map);
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:5,代码来源:StandardBeanProperties.java

示例14: getBytecode

import java.util.Collections; //导入方法依赖的package包/类
Map<String, byte[]> getBytecode() {
    return Collections.unmodifiableMap(bytecode);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Compiler.java

示例15: getTermCandidates

import java.util.Collections; //导入方法依赖的package包/类
public Map<String, TermCandidate> getTermCandidates() {
	return Collections.unmodifiableMap(termCandidates);
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:4,代码来源:YateaHandler.java


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