Package com.google.common.base

Examples of com.google.common.base.Predicate


            }
        } else {
            // filtering by group name included in query -> enforce offset
            // and limit on the result set.
            Iterator<Authorizable> result = findAuthorizables(statement.toString(), Long.MAX_VALUE, 0, null);
            Predicate groupFilter = new GroupPredicate(userManager,
                    groupId,
                    builder.isDeclaredMembersOnly());
            return ResultIterator.create(builder.getOffset(), builder.getMaxCount(),
                    Iterators.filter(result, groupFilter));
        }
View Full Code Here


            return findAuthorizables(statement.toString(), builder.getMaxCount(), offset, null);
        } else {
            // filtering by group name included in query -> enforce offset
            // and limit on the result set.
            Iterator<Authorizable> result = findAuthorizables(statement.toString(), Long.MAX_VALUE, 0, null);
            Predicate groupFilter = new GroupPredicate(userManager,
                    builder.getGroupID(),
                    builder.isDeclaredMembersOnly());
            return ResultIterator.create(builder.getOffset(), builder.getMaxCount(),
                    Iterators.filter(result, groupFilter));
        }
View Full Code Here

        for (int i=0; i<attributes.length; i++) {
            String attName = (String)attributes[i];
            if (i+1<attributes.length) {
                Object operand = attributes[i+1];
                if (operand instanceof Predicate) {
                    Predicate p = (Predicate) operand;
                    allowAttributes(attName).matching(p).onElements(tags);
                    i++;
                    continue;
                }
View Full Code Here

    private int getPromotedBuildNumber(final String project, final String promoted) {
        BuildableItemWithBuildWrappers item = getProject(project);


        Iterable<AbstractBuild> promotedItems = Iterables.filter(item.asProject().getBuilds(), new Predicate() {
            public boolean apply(Object o) {
                AbstractBuild abstractBuild = (AbstractBuild)o;

                PromotedBuildAction pba = abstractBuild.getAction(PromotedBuildAction.class);
                return ( pba != null && pba.getPromotion(promoted) != null );
View Full Code Here

    @Test
    public void shouldFindObjectInCollection() throws Exception {

        // given
        Predicate elevenInCollectionPredicate = Predicates.in(Arrays.asList(11L, 22L, 33L, 44L));

        // then
        assertThat(elevenInCollectionPredicate.apply(11L)).isTrue();
    }
View Full Code Here

    Iterator<MarkerRange.Builder> current = start(new MarkerRange.Builder(cmp));

    // primarily loop over sources because the logical constraints are there
    for (String source : partitioners.keySet()) {
      Predicate constraint = predicates.get(source);
      List<FieldPartitioner> fps = partitioners.get(source);
      FieldPartitioner first = fps.get(0);
      if (first instanceof CalendarFieldPartitioner) {
        current = TimeDomain.get(strategy, source)
            .addStackedIterator(constraint, current);
View Full Code Here

    PartitionStrategy strategy = key.getPartitionStrategy();
    Set<String> timeFields = Sets.newHashSet();
    int i = 0;
    for (FieldPartitioner fp : strategy.getFieldPartitioners()) {
      String partition = fp.getName();
      Predicate partitionPredicate = unsatisfied.get(partition);
      if (partitionPredicate != null && partitionPredicate.apply(key.get(i))) {
        unsatisfied.remove(partition);
        LOG.debug("removing " + partition + " satisfied by " + key.get(i));
      }

      String source = fp.getSourceName();
      if (fp instanceof CalendarFieldPartitioner) {
        // keep track of time fields to consider
        timeFields.add(source);
      }
      // remove the field if it is satisfied by the StorageKey
      Predicate original = unsatisfied.get(source);
      if (original != null) {
        Predicate isSatisfiedBy = fp.projectStrict(original);
        LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
        if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key.get(i))) {
          LOG.debug("removing " + source + " satisfied by " + key.get(i));
          unsatisfied.remove(source);
        }
      }
      i += 1;
    }
    // remove fields satisfied by the time predicates
    for (String timeField : timeFields) {
      Predicate<Long> original = unsatisfied.get(timeField);
      if (original != null) {
        Predicate<Marker> isSatisfiedBy = TimeDomain.get(strategy, timeField)
            .projectStrict(original);
        LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
        if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key)) {
          LOG.debug("removing " + timeField + " satisfied by " + key);
          unsatisfied.remove(timeField);
        }
      }
    }
View Full Code Here

      if (fps.isEmpty()) {
        LOG.debug("No field partitioners for key {}", entry.getKey());
        return false;
      }

      Predicate predicate = entry.getValue();
      if (!(predicate instanceof Exists)) {
        boolean satisfied = false;
        for (FieldPartitioner fp : fps) {
          if (fp instanceof CalendarFieldPartitioner) {
            TimeDomain domain = TimeDomain.get(strategy, entry.getKey());
            Predicate strict = domain.projectStrict(predicate);
            Predicate permissive = domain.project(predicate);
            LOG.debug("Time predicate strict: {}", strict);
            LOG.debug("Time predicate permissive: {}", permissive);
            satisfied = strict != null && strict.equals(permissive);
            break;
          } else {
            Predicate strict = fp.projectStrict(predicate);
            Predicate permissive = fp.project(predicate);
            if (strict != null && strict.equals(permissive)) {
              satisfied = true;
              break;
            }
          }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void checkContained(String name, Object... values) {
    for (Object value : values) {
      if (constraints.containsKey(name)) {
        Predicate current = constraints.get(name);
        Preconditions.checkArgument(current.apply(value),
            "%s does not match %s", current, value);
      }
    }
  }
View Full Code Here

    Map<String, Object> provided = Maps.newHashMap();
    for (Map.Entry<String, String> entry : query.entrySet()) {
      String name = entry.getKey();
      if (SchemaUtil.isField(schema, strategy, name)) {
        Schema fieldSchema = SchemaUtil.fieldSchema(schema, strategy, name);
        Predicate predicate = Predicates.fromString(
            entry.getValue(), fieldSchema);
        constraints.put(name, predicate);
        if (predicate instanceof In) {
          Set values = Predicates.asSet((In) predicate);
          if (values.size() == 1) {
View Full Code Here

TOP

Related Classes of com.google.common.base.Predicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.