Пример #1
0
 /**
  * Returns a combined map of user and group permissions, with group names prefixed by {@link
  * AccessControlLists#GROUP_PREFIX}.
  */
 public ListMultimap<String, T> getAllPermissions() {
   ListMultimap<String, T> tmp = ArrayListMultimap.create();
   tmp.putAll(userCache);
   for (String group : groupCache.keySet()) {
     tmp.putAll(AccessControlLists.GROUP_PREFIX + group, groupCache.get(group));
   }
   return tmp;
 }
Пример #2
0
 public Builder addRelations(String parentQualifier, String... childrenQualifiers) {
   Preconditions.checkNotNull(parentQualifier);
   Preconditions.checkNotNull(childrenQualifiers);
   Preconditions.checkArgument(
       childrenQualifiers.length > 0, "childrenQualifiers can't be empty");
   relations.putAll(parentQualifier, Arrays.asList(childrenQualifiers));
   return this;
 }
  /**
   * Merge with another validation report
   *
   * @param other the report to merge with
   */
  public void mergeWith(final ValidationReport other) {
    if (fatal) return;

    if (other.fatal) {
      msgMap.clear();
      fatal = true;
    }

    msgMap.putAll(other.msgMap);
  }
  @Override
  protected boolean performRefinementForState(BooleanFormula pInterpolant, ARGState pState)
      throws InterruptedException, SolverException {
    checkState(newPredicates != null);
    checkArgument(!bfmgr.isTrue(pInterpolant));

    predicateCreation.start();
    newPredicates.putAll(extractLocation(pState), convertInterpolant(pInterpolant));
    predicateCreation.stop();

    return false;
  }
  /**
   * Returns a map of the data items.
   *
   * @return a map of items.
   * @see DataMap
   */
  @NonNull
  @Override
  public ListMultimap<String, I> getDataMap() {
    // put all the sets in a multimap. The result is that for each key,
    // there is a sorted list of items from all the layers, including removed ones.
    ListMultimap<String, I> fullItemMultimap = ArrayListMultimap.create();

    for (S resourceSet : mDataSets) {
      ListMultimap<String, I> map = resourceSet.getDataMap();
      for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) {
        fullItemMultimap.putAll(entry.getKey(), entry.getValue());
      }
    }

    return fullItemMultimap;
  }
Пример #6
0
  // Register the methods of a class.
  private void registerMethods(Class<?> clazz, Method parent, Object obj) {
    for (Method method : clazz.getMethods()) {
      if (!method.isAnnotationPresent(Command.class)) continue;
      // We want to be able invoke with an instance
      if (!Modifier.isStatic(method.getModifiers())) {
        // Can't register this command if we don't have an instance
        if (obj == null) continue;
        instances.put(method, obj);
      }

      Command cmd = method.getAnnotation(Command.class);
      // Cache the aliases too
      for (String alias : cmd.aliases()) {
        for (String modifier : cmd.modifiers()) {
          commands.put(alias + " " + modifier, method);
        }
        if (!commands.containsKey(alias + " help")) {
          commands.put(alias + " help", null);
        }
      }

      List<Annotation> annotations = Lists.newArrayList();
      for (Annotation annotation : method.getDeclaringClass().getAnnotations()) {
        Class<? extends Annotation> annotationClass = annotation.annotationType();
        if (annotationProcessors.containsKey(annotationClass)) annotations.add(annotation);
      }
      for (Annotation annotation : method.getAnnotations()) {
        Class<? extends Annotation> annotationClass = annotation.annotationType();
        if (!annotationProcessors.containsKey(annotationClass)) continue;
        Iterator<Annotation> itr = annotations.iterator();
        while (itr.hasNext()) {
          Annotation previous = itr.next();
          if (previous.annotationType() == annotationClass) {
            itr.remove();
          }
        }
        annotations.add(annotation);
      }

      if (annotations.size() > 0) registeredAnnotations.putAll(method, annotations);

      Class<?>[] parameterTypes = method.getParameterTypes();
      if (parameterTypes.length <= 1 || parameterTypes[1] == CommandSender.class)
        serverCommands.add(method);
    }
  }
  /**
   * Sets the post blob load state to TOUCHED.
   *
   * <p>After a load from the blob file, all items have their state set to nothing. If the load mode
   * is not set to incrementalState then we want the items that are in the current merge result to
   * have their state be TOUCHED.
   *
   * <p>This will allow the first use of {@link #mergeData(MergeConsumer, boolean)} to add these to
   * the consumer as if they were new items.
   *
   * @see #loadFromBlob(java.io.File, boolean)
   * @see DataItem#isTouched()
   */
  private void setPostBlobLoadStateToTouched() {
    ListMultimap<String, I> itemMap = ArrayListMultimap.create();

    // put all the sets into list per keys. The order is important as the lower sets are
    // overridden by the higher sets.
    for (S dataSet : mDataSets) {
      ListMultimap<String, I> map = dataSet.getDataMap();
      for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) {
        itemMap.putAll(entry.getKey(), entry.getValue());
      }
    }

    // the items that represent the current state is the last item in the list for each key.
    for (String key : itemMap.keySet()) {
      List<I> itemList = itemMap.get(key);
      itemList.get(itemList.size() - 1).resetStatusToTouched();
    }
  }
 @Override
 public void putAll(final Map<? extends K, ? extends List<V>> m) {
   for (Entry<? extends K, ? extends List<V>> entry : m.entrySet()) {
     backingMap.putAll(entry.getKey(), entry.getValue());
   }
 }
Пример #9
0
 /**
  * Sets this BindsConfig to be identical to other
  *
  * @param other The BindsConfig to copy
  */
 public void setBinds(BindsConfig other) {
   data.clear();
   data.putAll(other.data);
 }