org.apache.brooklyn.util.collections.MutableMap类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.apache.brooklyn.util.collections.MutableMap类的一些代码示例,展示了MutableMap类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableMap类的具体详情如下:
包路径:org.apache.brooklyn.util.collections.MutableMap
类名称:MutableMap

MutableMap介绍

[英]Map impl, exposing simple builder operations (add) in a fluent-style API, where the final map is mutable. You can also toImmutable.
[中]Map impl,在fluent风格的API中公开简单的构建器操作(add),其中最终的映射是可变的。你也可以改变。

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@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();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

protected Map<Entity, T> copyOfValues() {
  // Don't use ImmutableMap, as can contain null values
  synchronized (values) {
    return Collections.unmodifiableMap(MutableMap.copyOf(values));
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
protected Map<String, Object> merge(Map<String, Object> base, Map<String, Object> subkeys, boolean unmodifiable) {
  Map<String, Object> result = MutableMap.copyOf(base).add(subkeys);
  if (unmodifiable) result = Collections.unmodifiableMap(result);
  return result;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

public static <K,V> MutableMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3,K k4, V v4,K k5, V v5,K k6,V v6) {
  MutableMap<K,V> result = new MutableMap<K,V>();
  result.put(k1, v1);
  result.put(k2, v2);
  result.put(k3, v3);
  result.put(k4, v4);
  result.put(k5, v5);
  result.put(k6, v6);
  return result;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** 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();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public Map<String, String> buildHeaders(Map<String, String> baseHeaders) {
  return MutableMap.<String,String>builder()
      .putAll(baseHeaders)
      .putAll(headers)
      .build();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@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;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@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

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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());
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** 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;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@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);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp

@Override
public Map<String, String> getShellEnvironment() {
  return MutableMap.<String, String>builder().putAll(super.getShellEnvironment())
      .put("PORT", Integer.toString(getHttpPort()))
      .build();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** current values for all entries 
 * @return non-modifiable map of strings to object */
public synchronized Map<String,Object> getAllConfig() {
  return MutableMap.copyOf(config).asUnmodifiable();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

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;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** as {@link MutableList#asUnmodifiableCopy()} */
public Map<K,V> asUnmodifiableCopy() {
  return Collections.unmodifiableMap(MutableMap.copyOf(this));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public static Map<String,Object> getBasicAddonSubstitutions(EntityDriver driver, String addon) {
  return MutableMap.<String,Object>builder()
      .putAll(getBasicEntitySubstitutions(driver))
      .put("addon", addon)
      .build();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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();
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

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;
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/**
 * 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);
}

相关文章