org.jvnet.hk2.component.MultiMap类的使用及代码示例

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

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

MultiMap介绍

[英]Map from a key to multiple values. Order is significant among values, and null values are allowed, although null keys are not.
[中]从一个键映射到多个值。值之间的顺序很重要,允许使用空值,但不允许使用空键。

代码示例

代码示例来源:origin: javaee/glassfish

static MultiMap<String, String> split(String value) {
  MultiMap<String, String> result = new MultiMap<String, String>();
  String split[] = value.split(",");
  for (String s : split) {
   String split2[] = s.split("=");
   assert(2 == split2.length);
   result.add(split2[0], split2[1]);
  }
  return result;
 }
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

/**
 * Gets all the inhabitants that has the given implementation type name.
 */
public Collection<Inhabitant<?>> getInhabitantsByType(
    String fullyQualifiedClassName) {
  return (Collection) byType.get(fullyQualifiedClassName);
}

代码示例来源:origin: javaee/glassfish

private void addXRef(Class type, ConfigModel cm) {
  List<ConfigModel> models = implementorsOf.getOne(type);
  if (models==null) {
    models= new ArrayList<ConfigModel>();
    implementorsOf.add(type, models);
  }
  models.add(cm);
}

代码示例来源:origin: javaee/glassfish

/**
 * Calculates all @Configured interfaces subclassing the passed interface type.
 *
 * @param intf a @Configured interface
 * @return List of all @Configured subclasses
 * @throws ClassNotFoundException
 */
public synchronized List<ConfigModel> getAllModelsImplementing(Class intf) throws ClassNotFoundException {
  if (implementorsOf.size()==0) {
    initXRef();
  }
  return implementorsOf.getOne(intf);   
}

代码示例来源:origin: org.glassfish.main.admin/admin-cli

private void initializeRemoteAdminCommand() throws CommandException {
  if (rac == null) {
    rac = new RemoteCLICommand.CLIRemoteAdminCommand(name,
        programOpts.getHost(), programOpts.getPort(),
        programOpts.isSecure(), programOpts.getUser(),
        programOpts.getPassword(), logger, programOpts.getAuthToken(),programOpts.isNotifyCommand());
    rac.setFileOutputDirectory(outputDir);
    rac.setInteractive(programOpts.isInteractive());
    for (String key : listeners.keySet()) {
      for (AdminCommandListener<GfSseInboundEvent> listener : listeners.get(key)) {
        rac.registerListener(key, listener);
      }
    }
  }
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

private static void add(MultiMap<String, String> dest, String key, String val) {
 List<String> vals = dest.get(key);
 if (null == vals || !vals.contains(val)) {
  dest.add(key, val);
 }
}

代码示例来源:origin: javaee/glassfish

public MultiMap<String, String> process(TypeElement d) {
  visited.clear();
  MultiMap<String,String> r = new MultiMap<String, String>();
  check(d,r);
  return r;
}

代码示例来源:origin: javaee/glassfish

/**
 * Based on the model, parse the annotation mirror and updates the metadata bag by adding
 * discovered values.
 */
public void parse(AnnotationMirror a, MultiMap<String,String> metadataBag) {
  assert a.getAnnotationType().equals(type);
  for (Map.Entry<ExecutableElement, String> e : metadataProperties.entrySet()) {
    Map<? extends ExecutableElement, ? extends AnnotationValue> vals = a.getElementValues();
    AnnotationValue value = vals.get(e.getKey());
    if (value!=null) {
      metadataBag.add(e.getValue(), toString(value));
    } else {
      Collection<ExecutableElement> methods = ElementFilter.methodsIn(a.getAnnotationType().asElement().getEnclosedElements());
      for (ExecutableElement decl : methods) {
        if (e.getKey().equals(decl)) {
          value = decl.getDefaultValue();
          metadataBag.add(e.getValue(), toString(value));
          break;
        }
      }
    }
  }
}

代码示例来源:origin: javaee/glassfish

static String innerSort(String line) {
 MultiMap<String, String> mm = split(line);
 StringBuilder sb = new StringBuilder();
 // class
 List<String> vals = mm.remove("class");
 assert(null != vals && 1 == vals.size());
 sb.append("class=").append(vals.iterator().next());
 
 // indicies
 vals = mm.remove("index");
 if (null != vals && vals.size() > 0) {
  Collections.sort(vals);
  for (String index : vals) {
   sb.append(",index=").append(index);
  }
 }
 
 // metadata
 vals = new ArrayList<String>(mm.keySet());
 Collections.sort(vals);
 for (String key : vals) {
  List<String> subVals = new ArrayList<String>(mm.get(key));
  Collections.sort(subVals);
  for (String val : subVals) {
   sb.append(",").append(key).append("=").append(val);
  }
 }
 return sb.toString();
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

MultiMapIterator(MultiMap map) {
  itr = map.entrySet().iterator();
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

@Override
public boolean equals(Object another) {
  if (!MultiMap.class.isInstance(another)) {
    return false;
  }
  
  @SuppressWarnings("rawtypes")
  MultiMap other = MultiMap.class.cast(another);
  if (size() != other.size()) {
    return false;
  }
  
  for (Entry<K, List<V>> entry : store.entrySet()) {
    @SuppressWarnings("unchecked")
    List<V> vColl = other.get(entry.getKey());
    if (!entry.getValue().equals(vColl)) {
      return false;
    }
  }
  
  return true;
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Copy constructor.
 *
 * @param base map to copy
 */
public MultiMap(MultiMap<K, V> base) {
  this();
  for (Map.Entry<K, List<V>> e : base.entrySet()) {
    List<V> value = newList(e.getValue());
    if (!value.isEmpty()) {
      store.put(e.getKey(), newList(e.getValue()));
    }
  }
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

List<Inhabitant> list = byType._get(HabitatListener.class.getName());
List<Inhabitant> releaseList = new ArrayList<Inhabitant>();
Iterator<Inhabitant> iter = list.iterator();
  MultiMap<String, String> metadata = released.metadata();
  if (null != metadata) {
    List<String> filters = metadata.get(Constants.OBJECTCLASS);
    for (String contract : filters) {
      ListenersByTypeInhabitant sameListeners;

代码示例来源:origin: org.glassfish.hk2/auto-depends

public String getImplName() {
  return metadata.getOne(CLASS_KEY);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Checks if the map contains the given key(s), also extending the search
 * to including the sub collection.
 *
 * @param k1 key from top collection
 * @param k2 key (value) from inner collection
 * @return true if the map contains at least one element for these keys
 */
public boolean contains(K k1, V k2) {
  List<V> list = _get(k1);
  return list.contains(k2);
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

boolean matches(org.glassfish.hk2.MultiMap<K, V> other) {
  if (size() > other.size()) {
    return false;
  }
  
  for (Entry<K, List<V>> entry : store.entrySet()) {
    List<V> vColl = other.get(entry.getKey());
    if (!entry.getValue().equals(vColl)) {
      return false;
    }
  }
  
  return true;
}

代码示例来源:origin: com.sun.enterprise/auto-depends

/**
 * Removes a Contracted service
 *
 * @param index               the contract name
 * @param serviceOrInhabitant the service instance, or an Inhabitant instance
 */
public boolean removeIndex(String index, Object serviceOrInhabitant) {
  boolean removed = false;
  if (byContract.containsKey(index)) {
    List<NamedInhabitant> contracted = byContract._get(index);
    Iterator<NamedInhabitant> iter = contracted.iterator();
    while (iter.hasNext()) {
      NamedInhabitant i = iter.next();
      if (matches(i.inhabitant, serviceOrInhabitant)) {
        if (concurrencyControls) {
          removed = contracted.remove(i);
          assert (removed);
        } else {
          iter.remove();
        }
        removed = true;
        notify(i.inhabitant, EventType.INHABITANT_INDEX_REMOVED,
            index, null, service(serviceOrInhabitant), null);
        // remember to remove the components stored under its type
        remove(i.inhabitant);
      }
    }
  }
  return removed;
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

for (String key : metadata.keySet()) {
  for (String value : metadata.get(key)) {
    descriptor.addMetadata(key, value);

代码示例来源:origin: com.sun.enterprise/auto-depends

private static void add(MultiMap<String, String> dest, String key, String val) {
 List<String> vals = dest.get(key);
 if (null == vals || !vals.contains(val)) {
  dest.add(key, val);
 }
}

代码示例来源:origin: org.glassfish.hk2/auto-depends

/**
 * Creates a copy of the map that contains the exact same key and value set.
 * Keys and values won't cloned.
 */
@Override
public MultiMap<K, V> clone() {
  return new MultiMap<K, V>(this);
}

相关文章