本文整理匯總了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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例10: getAllFields
import java.util.Collections; //導入方法依賴的package包/類
/**
* Get a simple map containing all the fields.
*/
public Map<FieldDescriptorType, Object> getAllFields() {
return Collections.unmodifiableMap(fields);
}
示例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);
}
示例12: getPropertyValues
import java.util.Collections; //導入方法依賴的package包/類
public Map<String, String> getPropertyValues() {
return Collections.unmodifiableMap(propertyValues);
}
示例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);
}
示例14: getBytecode
import java.util.Collections; //導入方法依賴的package包/類
Map<String, byte[]> getBytecode() {
return Collections.unmodifiableMap(bytecode);
}
示例15: getTermCandidates
import java.util.Collections; //導入方法依賴的package包/類
public Map<String, TermCandidate> getTermCandidates() {
return Collections.unmodifiableMap(termCandidates);
}