@Override public Map<String, Object> asMapWithStringKeys() { synchronized (contents) { return MutableMap.copyOf(contents).asUnmodifiable(); } }
/** current values for all entries which have not yet been used * @return non-modifiable map of strings to object */ public synchronized Map<String,Object> getUnusedConfig() { return MutableMap.copyOf(unusedConfig).asUnmodifiable(); }
/** current values for all entries * @return non-modifiable map of strings to object */ public synchronized Map<String,Object> getAllConfig() { return MutableMap.copyOf(config).asUnmodifiable(); }
public Map<String, Object> getCustomAttributes() { return MutableMap.copyOf(customAttributes).asUnmodifiable(); }
/** Returns the internal map containing the current values for all entries; * for use where the caller wants to modify this directly and knows it is safe to do so * <p> * Accesses to the returned map must be synchronized on this bag if the * thread-safe behaviour is required. */ public Map<String,Object> getAllConfigMutable() { if (live) { // TODO sealed no longer works as before, because `config` is the backing storage map. // Therefore returning it is dangerous! Even if we were to replace our field with an immutable copy, // the underlying datagrid's map would still be modifiable. We need a way to switch the returned // value's behaviour to sealable (i.e. wrapping the returned map). return (sealed) ? MutableMap.copyOf(config).asUnmodifiable() : config; } else { return config; } }
public Map<String, Object> getCustomAttributes() { return MutableMap.copyOf(customAttributes).asUnmodifiable(); }
private <T> Map<Entity, T> copyValues(Sensor<T> sensor) { synchronized (values) { @SuppressWarnings("unchecked") Map<Entity, T> sv = (Map<Entity, T>) values.get(sensor.getName()); //use MutableMap because of potentially null values return MutableMap.copyOf(sv).asUnmodifiable(); } }
public PlanInterpretationContext(Map<String,?> originalDeploymentPlan, List<PlanInterpreter> interpreters) { super(); this.originalDeploymentPlan = MutableMap.<String, Object>copyOf(originalDeploymentPlan).asUnmodifiable(); this.interpreters = ImmutableList.copyOf(interpreters); this.allInterpreter = new PlanInterpreter() {
private static Object immutable(Object in) { if (in instanceof Map) return MutableMap.copyOf((Map<?,?>)in).asUnmodifiable(); if (in instanceof Iterable) return MutableList.copyOf((Iterable<?>)in).asUnmodifiable(); return in; }
protected void checkTemplates(EntityInternal ent) { Map<String, Object> substitutions = MutableMap.copyOf(ent.config().get(SoftwareProcess.TEMPLATE_SUBSTITUTIONS)).asUnmodifiable(); String out0 = TemplateProcessor.processTemplateContents("hello "+"${field}", substitutions); Assert.assertEquals(out0, "hello val"); String out1 = TemplateProcessor.processTemplateContents("hello "+"${config['template.substitutions']['field']}", ent, substitutions); Assert.assertEquals(out1, "hello val"); }
@Override public Map<String,BrooklynObject> getAllBrooklynObjects() { MutableMap<String,BrooklynObject> result = MutableMap.of(); result.putAll(locations); result.putAll(entities); result.putAll(policies); result.putAll(enrichers); result.putAll(feeds); result.putAll(catalogItems); result.putAll(bundles); return result.asUnmodifiable(); }
.addIfNotNull("parent", parentUri) .addIfNotNull("spec", specUri) .asUnmodifiable() );