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