当前位置: 首页>>代码示例>>Java>>正文


Java Sets.filter方法代码示例

本文整理汇总了Java中com.google.common.collect.Sets.filter方法的典型用法代码示例。如果您正苦于以下问题:Java Sets.filter方法的具体用法?Java Sets.filter怎么用?Java Sets.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Sets的用法示例。


在下文中一共展示了Sets.filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notExisted

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public Set<String> notExisted(String queueID, Set<String> resourceItemKeys) {
    if (!lockQueue(queueID)) {
        return Collections.emptySet();
    }
    Jedis jedis = jedisPool.getResource();
    try {
        final Set<String> hkeys = jedis.hkeys(makeDataKey(queueID));
        return Sets.filter(resourceItemKeys, new Predicate<String>() {
            @Override
            public boolean apply(String input) {
                return !hkeys.contains(input);
            }
        });
    } finally {
        IOUtils.closeQuietly(jedis);
        unLockQueue(queueID);
    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:20,代码来源:JedisQueueStore.java

示例2: existing

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<File> existing(Set<File> files) {
    return Sets.filter(files, new Predicate<File>() {
        @Override
        public boolean apply(File file) {
            return file.exists();
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:IdeaModule.java

示例3: checkLinkingValidity

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private void checkLinkingValidity(final Symbol docID, final ArgumentOutput docOutput,
    final Optional<LinkingStore> linkingStore) throws IOException {
  final Optional<ResponseLinking> responseLinking = linkingStore.get().read(docOutput);
  if (!responseLinking.isPresent()) {
    throw new RuntimeException("Linking missing for " + docID);
  }
  final Set<Response> allLinkedResponses = ImmutableSet
      .copyOf(Iterables.concat(responseLinking.get().responseSets()));
  final Set<Response> nonGenericArgumentResponses = Sets
      .filter(docOutput.responses(), NOT_GENERIC);
  if (!allLinkedResponses.equals(nonGenericArgumentResponses)) {
    final StringBuilder msg = new StringBuilder();
    msg.append(
        "The set of linked responses should exactly equal the set of non-generic argument responses. However, ");
    final Set<Response> linkingOnly =
        Sets.difference(allLinkedResponses, nonGenericArgumentResponses);
    final Set<Response> argumentOnly =
        Sets.difference(nonGenericArgumentResponses, allLinkedResponses);

    if (!linkingOnly.isEmpty()) {
      msg.append("\nThe following are in the linking only:\n ")
          .append(StringUtils.NewlineJoiner.join(linkingOnly));
    }
    if (!argumentOnly.isEmpty()) {
      msg.append("\nThe following are in the argument output only:\n")
          .append(StringUtils.NewlineJoiner.join(argumentOnly));
    }
    throw new RuntimeException(msg.toString());
  }
  if (!linkingValidator.validate(responseLinking.get())) {
    throw new RuntimeException(String.format("Validation failed for %s with validator %s", docID,
        linkingValidator.getClass().toString()));
  }
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:35,代码来源:ValidateSystemOutput.java

示例4: copyWithFilteredResponses

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public ResponseLinking copyWithFilteredResponses(final Predicate<Response> toKeepCondition) {
  final Set<Response> newIncompletes = Sets.filter(incompleteResponses(), toKeepCondition);
  final ImmutableSet.Builder<ResponseSet> newResponseSetsB = ImmutableSet.builder();
  final ImmutableBiMap.Builder<String, ResponseSet> responseSetsIdB = ImmutableBiMap.builder();
  // to account for ResponseSets merging due to lost annotation
  final Set<ResponseSet> alreadyAdded = Sets.newHashSet();
  for (final ResponseSet responseSet : responseSets()) {
    final ImmutableSet<Response> okResponses = FluentIterable.from(responseSet.asSet())
        .filter(toKeepCondition).toSet();
    if (!okResponses.isEmpty()) {
      final ResponseSet newResponseSet = ResponseSet.from(okResponses);
      if(alreadyAdded.contains(newResponseSet)) {
        continue;
      }
      alreadyAdded.add(newResponseSet);
      newResponseSetsB.add(newResponseSet);
      if (responseSetIds().isPresent()) {
        responseSetsIdB.put(responseSetIds().get().inverse().get(responseSet), newResponseSet);
      }
    }
  }

  final ImmutableSet<ResponseSet> newResponseSets = newResponseSetsB.build();
  final ResponseLinking.Builder ret = ResponseLinking.builder().docID(docID())
      .responseSets(newResponseSets).incompleteResponses(newIncompletes);
  if (responseSetIds().isPresent()) {
    ret.responseSetIds(responseSetsIdB.build());
  }
  return ret.build();
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:31,代码来源:_ResponseLinking.java

示例5: notExisted

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public Set<String> notExisted(String queueID, Set<String> resourceItemKeys) {
    final Map<String, ResourceItem> maps = createOrGet(queueID).maps;
    return Sets.filter(resourceItemKeys, new Predicate<String>() {
        @Override
        public boolean apply(String input) {
            return !maps.containsKey(input);
        }
    });
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:11,代码来源:RamQueueStore.java

示例6: getChildren

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<? extends RenderableDependency> getChildren(RenderableDependency node) {
    return Sets.filter(node.getChildren(), showDependentPredicate);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:DependentComponentsGraphRenderer.java

示例7: registerObserver

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * 注册事件观察者,通过注解的事件观察者
 *
 * @param observer 观察者对象
 */
public void registerObserver(Object observer) {
    final Class<?> observerClass = observer.getClass();

    // 这个观察者的接口类,可能有多个
    Set<Class> allSupperClass = Sets.filter(allAutoEventMap.keySet(), new Predicate<Class>() {
        @Override
        @SuppressWarnings("unchecked")
        public boolean apply(Class input) {
            return input.isAssignableFrom(observerClass);
        }
    });

    if (allSupperClass.size() == 0) {
        log.warn("can not registry observer:{} , observer class must implement a event interface", observer);
        return;
    }

    Method[] declaredMethods = observerClass.getDeclaredMethods();
    for (Method method : declaredMethods) {
        String topic = "";
        if (method.getAnnotation(AutoEventHandler.class) != null) {
            AutoEventHandler autoEventHandler = method.getAnnotation(AutoEventHandler.class);
            topic = autoEventHandler.topic();
        }

        // find auto Topic
        for (Class supperClazz : allSupperClass) {
            Method[] supperClazzDeclaredMethods = supperClazz.getDeclaredMethods();
            for (Method supperClazzMethod : supperClazzDeclaredMethods) {
                if (!supperClazzMethod.getName().equals(method.getName())
                        || supperClazzMethod.getAnnotation(AutoEvent.class) == null) {
                    continue;
                }
                AutoEvent annotation = supperClazzMethod.getAnnotation(AutoEvent.class);
                String eventTopic = annotation.topic();

                if (StringUtils.isEmpty(eventTopic)) {// 父类指定过topic,那么子类必须指定topic
                    eventTopic = supperClazz.getName() + "#" + method.getName();
                }
                if (StringUtils.isEmpty(topic) || topic.equals(eventTopic)) {
                    // 注册一个topic为eventTopic的事件观察者
                    registerMethod(observer, method, eventTopic);
                }
            }
        }

    }
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:54,代码来源:AutoEventRegistry.java

示例8: doPrincipalAttributesAllowServiceAccess

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Verify presence of service required attributes.
 * <ul>
 *     <li>If no required attributes are specified, authz is granted.</li>
 *     <li>If ALL required attributes must be present, and the principal contains all and there is
 *     at least one attribute value that matches the required, authz is granted.</li>
 *     <li>If ALL required attributes don't have to be present, and there is at least
 *     one principal attribute present whose value matches the required, authz is granted.</li>
 *     <li>Otherwise, access is denied</li>
 * </ul>
 * Note that comparison of principal/required attributes is case-sensitive. Exact matches are required
 * for any individual attribute value.
 */
@Override
public boolean doPrincipalAttributesAllowServiceAccess(final String principal, final Map<String, Object> principalAttributes) {
    if (this.requiredAttributes.isEmpty()) {
        LOGGER.debug("No required attributes are specified");
        return true;
    }
    if (principalAttributes.isEmpty()) {
        LOGGER.debug("No principal attributes are found to satisfy attribute requirements");
        return false;
    }

    if (principalAttributes.size() < this.requiredAttributes.size()) {
        LOGGER.debug("The size of the principal attributes that are [{}] does not match requirements, "
                + "which means the principal is not carrying enough data to grant authorization",
                principalAttributes);
        return false;
    }

    final Map<String, Set<String>> requiredAttrs = this.getRequiredAttributes();
    LOGGER.debug("These required attributes [{}] are examined against [{}] before service can proceed.",
            requiredAttrs, principalAttributes);

    final Sets.SetView<String> difference = Sets.intersection(requiredAttrs.keySet(), principalAttributes.keySet());
    final Set<String> copy = difference.immutableCopy();

    if (this.requireAllAttributes && copy.size() < this.requiredAttributes.size()) {
        LOGGER.debug("Not all required attributes are available to the principal");
        return false;
    }

    for (final String key : copy) {
        final Set<String> requiredValues = this.requiredAttributes.get(key);
        final Set<String> availableValues;

        final Object objVal = principalAttributes.get(key);
        if (objVal instanceof Collection) {
            final Collection valCol = (Collection) objVal;
            availableValues = Sets.newHashSet(valCol.iterator());
        } else {
            availableValues = Sets.newHashSet(objVal.toString());
        }

        final Set<?> differenceInValues;
        final Pattern pattern = RegexUtils.concatenate(requiredValues, this.caseInsensitive);
        if (pattern != null) {
            differenceInValues = Sets.filter(availableValues, Predicates.contains(pattern));
        } else {
            differenceInValues = Sets.intersection(availableValues, requiredValues);
        }

        if (!differenceInValues.isEmpty()) {
            LOGGER.info("Principal is authorized to access the service");
            return true;
        }
    }
    LOGGER.info("Principal is denied access as the required attributes for the registered service are missing");
    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:74,代码来源:DefaultRegisteredServiceAccessStrategy.java

示例9: getTestClasses

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private static Set<Class<? extends GWTTestCase>> getTestClasses() {
    return Sets.filter(getAllTestClasses(), unsupportedClazzFilter);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:4,代码来源:GWTTestCaseSuite.java

示例10: idpsFilteredBy

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<IdentityProviderConfigEntityData> idpsFilteredBy(Set<Predicate<IdentityProviderConfigEntityData>> predicatesForTransactionEntity) {
    return Sets.filter(identityProviderConfigEntityDataRepository.getAllData(), Predicates.and(predicatesForTransactionEntity));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:4,代码来源:IdentityProviderResource.java

示例11: getFilteredIdps

import com.google.common.collect.Sets; //导入方法依赖的package包/类
static Set<IdentityProviderConfigEntityData> getFilteredIdps(Set<IdentityProviderConfigEntityData> idpSet,
                                                             Set<Predicate<IdentityProviderConfigEntityData>> predicateSet) {
    return Sets.filter(idpSet, Predicates.and(predicateSet));
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:5,代码来源:PredicateTestHelper.java

示例12: instancesOf

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public static <T> Set<T> instancesOf(Set<? super T> set, Class<T> type) {
    return (Set<T>) Sets.filter(set, type::isInstance);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:IterableUtils.java

示例13: rowKeySet

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public Set<R> rowKeySet() {
    return Sets.filter(map.keySet(), this::containsRow);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:TableView.java

示例14: keysAssignableTo

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * Return all keys within the given bounds
 */
public Set<TypeToken<? extends K>> keysAssignableTo(TypeToken<? extends K> bounds) {
    return Sets.filter(keySet(), bounds::isAssignableFrom);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:TypeMap.java

示例15: keysAssignableFrom

import com.google.common.collect.Sets; //导入方法依赖的package包/类
/**
 * Return all keys that bound the given type
 */
public Set<TypeToken<? extends K>> keysAssignableFrom(TypeToken<? extends K> type) {
    return Sets.filter(keySet(), bounds -> bounds.isAssignableFrom(type));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:TypeMap.java


注:本文中的com.google.common.collect.Sets.filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。