@Override public Map<String, Object> getProvisioningFlags(Collection<String> tags) { if (tags.size() > 0) { LOG.warn("Location {}, ignoring provisioning tags {}", this, tags); } return MutableMap.<String, Object>of(); }
protected Map<Entity, T> copyOfValues() { // Don't use ImmutableMap, as can contain null values synchronized (values) { return Collections.unmodifiableMap(MutableMap.copyOf(values)); } }
/** 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(); }
public Map<String, String> buildHeaders(Map<String, String> baseHeaders) { return MutableMap.<String,String>builder() .putAll(baseHeaders) .putAll(headers) .build(); }
@Override protected Object compute() { Map<Entity, Object> ks = MutableMap.copyOf(Maps.filterValues(getValues(keySensor), valueFilter)); Map<Entity, Object> vs = MutableMap.copyOf(Maps.filterValues(getValues(valueSensor), valueFilter)); MutableMap<Object, Object> result = MutableMap.of(); for (Entity entity : ks.keySet()) { if (vs.containsKey(entity)) { result.put(ks.get(entity), vs.get(entity)); } } return result; }
@Override public LocationMemento getMemento() { Map<String, PortMapping> mappingsCopy; Map<String,String> publicIpIdToHostnameCopy; synchronized (mutex) { mappingsCopy = MutableMap.copyOf(mappings); publicIpIdToHostnameCopy = MutableMap.copyOf(publicIpIdToHostname); } return getMementoWithProperties(MutableMap.<String,Object>of( "mappings", mappingsCopy, "portReserved", portReserved.get(), "publicIpIdToHostname", publicIpIdToHostnameCopy)); } @Override
protected String execCommands(ConfigBag config, List<String> cmds, Map<String,?> env) { ByteArrayOutputStream out = new ByteArrayOutputStream(); MutableMap<String,Object> flags = MutableMap.<String,Object>of("out", out); if (config!=null) flags.add(config.getAllConfig()); tool.execCommands(flags, cmds, env); return new String(out.toByteArray()); }
/** as {@link #put(Object, Object)} but excluding null keys and values, and fluent style */ public MutableMap<K,V> addIfNotNull(K key, V value) { if (key!=null && value!=null) add(key, value); return this; }
@Override public int execCommands(Map<String,?> props, List<String> commands, Map<String,?> env) { Map<String,Object> props2 = new MutableMap<String,Object>(); if (props!=null) props2.putAll(props); props2.put(SshTool.PROP_NO_EXTRA_OUTPUT.getName(), true); return execScript(props2, commands, env); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder().putAll(super.getShellEnvironment()) .put("PORT", Integer.toString(getHttpPort())) .build(); }
/** 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 static <K,V> MutableMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3) { MutableMap<K,V> result = new MutableMap<K,V>(); result.put(k1, v1); result.put(k2, v2); result.put(k3, v3); return result; }
protected <K, V> Map<K, V> copyRetainingKeys(Map<K, V> orig, Set<? extends K> keysToKeep) { Map<K, V> result = MutableMap.of(); for (Map.Entry<K, V> entry : orig.entrySet()) { if (keysToKeep.contains(entry.getKey())) { result.put(entry.getKey(), entry.getValue()); } } return result; }
/** as {@link MutableList#asUnmodifiableCopy()} */ public Map<K,V> asUnmodifiableCopy() { return Collections.unmodifiableMap(MutableMap.copyOf(this)); }
public static Map<String,Object> getBasicAddonSubstitutions(EntityDriver driver, String addon) { return MutableMap.<String,Object>builder() .putAll(getBasicEntitySubstitutions(driver)) .put("addon", addon) .build(); }
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 static <K,V> MutableMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3,K k4, V v4) { MutableMap<K,V> result = new MutableMap<K,V>(); result.put(k1, v1); result.put(k2, v2); result.put(k3, v3); result.put(k4, v4); return result; }
/** * Installs a URL onto a remote machine. * * @see #install(Map, SshMachineLocation, String, String, int) */ public static int install(SshMachineLocation machine, String urlToInstall, String target) { return install(MutableMap.<String, Object>of(), machine, urlToInstall, target, NUM_RETRIES_FOR_COPYING); }