Example usage for com.google.common.base Predicates not

List of usage examples for com.google.common.base Predicates not

Introduction

In this page you can find the example usage for com.google.common.base Predicates not.

Prototype

public static <T> Predicate<T> not(Predicate<T> predicate) 

Source Link

Document

Returns a predicate that evaluates to true if the given predicate evaluates to false .

Usage

From source file:com.wavemaker.tools.apidocs.tools.parser.scanner.FilterableScanner.java

public FilterableScanner excludeTypes(List<String> types) {
    if (CollectionUtil.isNotEmpty(types)) {
        for (final String type : types) {
            add(Predicates.not(getEqualClassPredicate(type)));
        }/*from w w  w .  j a v a  2 s.  c o  m*/
    }
    return this;
}

From source file:com.khs.sherpa.endpoint.SherpaEndpoint.java

@SuppressWarnings("unchecked")
//   @RolesAllowed("SHERPA_ADMIN")
@Action(mapping = "/sherpa/admin/describe/{value}")
public Object describe(@Param("value") String value) {

    List<Map<String, Object>> actions = new ArrayList<Map<String, Object>>();

    Set<Method> methods = null;

    try {/*w  w w  .  ja  v  a2  s  .  c  o m*/
        methods = Reflections.getAllMethods(applicationContext.getType(value),
                Predicates.and(Predicates.not(SherpaPredicates.withAssignableFrom(Object.class)),
                        ReflectionUtils.withModifier(Modifier.PUBLIC),
                        Predicates.not(ReflectionUtils.withModifier(Modifier.ABSTRACT)),
                        Predicates.not(SherpaPredicates.withGeneric())));
    } catch (NoSuchManagedBeanExcpetion e) {
        throw new SherpaRuntimeException(e);
    }

    for (Method method : methods) {

        Map<String, Object> action = new HashMap<String, Object>();
        actions.add(action);

        action.put("name", MethodUtil.getMethodName(method));

        if (method.isAnnotationPresent(DenyAll.class)) {
            action.put("permission", "DenyAll");
        } else if (method.isAnnotationPresent(RolesAllowed.class)) {
            action.put("permission", "RolesAllowed");
            action.put("roles", method.getAnnotation(RolesAllowed.class).value());
        } else {
            action.put("permission", "PermitAll");
        }

        Map<String, String> params = new HashMap<String, String>();

        Class<?>[] types = method.getParameterTypes();
        Annotation[][] parameters = method.getParameterAnnotations();
        for (int i = 0; i < parameters.length; i++) {
            Class<?> type = types[i];
            Param annotation = null;
            if (parameters[i].length > 0) {
                for (Annotation an : parameters[i]) {
                    if (an.annotationType().isAssignableFrom(Param.class)) {
                        annotation = (Param) an;
                        break;
                    }
                }

            }
            if (annotation != null) {
                params.put(annotation.value(), type.getName());
            }
        }

        if (params.size() > 0) {
            action.put("params", params);
        } else {
            action.put("params", null);
        }

    }

    return actions;
}

From source file:playground.michalm.util.gis.PolygonBasedFilter.java

public static Iterable<? extends SimpleFeature> filterFeaturesOutsidePolygon(
        Iterable<? extends SimpleFeature> features, Geometry polygonGeometry) {
    return Iterables.filter(features, Predicates.not(createFeatureInsidePolygonPredicate(polygonGeometry)));
}

From source file:ratpack.render.RendererSupport.java

protected RendererSupport() {
    TypeToken<T> typeToken = new TypeToken<T>(getClass()) {
    };/*from   ww w .  jav  a 2 s  .com*/

    Type type = typeToken.getType();
    if (type instanceof Class) {
        @SuppressWarnings("unchecked")
        Class<T> rawType = (Class<T>) typeToken.getRawType();
        this.type = rawType;
    } else if (type instanceof ParameterizedType) {
        Iterable<Type> typeArgs = Arrays.asList(((ParameterizedType) type).getActualTypeArguments());
        if (Iterables.any(typeArgs, Predicates.not((t) -> t.getTypeName().equals("?")))) {
            throw new IllegalArgumentException("Invalid renderable type " + type
                    + ": due to type erasure, type parameter T of RendererSupport must be a Class or a parameterized type with '?' for all type variables (e.g. List<?>)");
        }
        this.type = Types.cast(typeToken.getRawType());
    } else {
        throw new InternalRatpackError("Unhandled type for renderer support: " + type.getClass());
    }
}

From source file:com.twitter.common.net.http.handlers.TimeSeriesDataSource.java

@VisibleForTesting
String getResponse(@Nullable String metricsQuery, @Nullable String sinceQuery) throws MetricException {

    if (metricsQuery == null) {
        // Return metric listing.
        return gson.toJson(ImmutableList.copyOf(timeSeriesRepo.getAvailableSeries()));
    }//from  ww  w. j  a  v  a 2s .c om

    List<Iterable<Number>> tsData = Lists.newArrayList();
    tsData.add(timeSeriesRepo.getTimestamps());
    // Ignore requests for "time" since it is implicitly returned.
    Iterable<String> names = Iterables.filter(Splitter.on(",").split(metricsQuery),
            Predicates.not(Predicates.equalTo(TIME_METRIC)));
    for (String metric : names) {
        TimeSeries series = timeSeriesRepo.get(metric);
        if (series == null) {
            JsonObject response = new JsonObject();
            response.addProperty("error", "Unknown metric " + metric);
            throw new MetricException(gson.toJson(response));
        }
        tsData.add(series.getSamples());
    }

    final long since = Long.parseLong(Optional.fromNullable(sinceQuery).or("0"));
    Predicate<List<Number>> sinceFilter = new Predicate<List<Number>>() {
        @Override
        public boolean apply(List<Number> next) {
            return next.get(0).longValue() > since;
        }
    };

    ResponseStruct response = new ResponseStruct(
            ImmutableList.<String>builder().add(TIME_METRIC).addAll(names).build(),
            FluentIterable.from(Iterables2.zip(tsData, 0)).filter(sinceFilter).toList());
    return gson.toJson(response);
}

From source file:org.eclipse.emf.compare.rcp.internal.match.MatchEngineFactoryRegistryWrapper.java

/**
 * Return a Collection of enabled {@link IMatchEngine.Factory}.
 * /*from  w  ww.  j av a2 s . c o  m*/
 * @return Collection<IMatchEngine.Factory>
 */
private Collection<IMatchEngine.Factory> getEnabledFactories() {
    Function<IItemDescriptor<Factory>, Factory> toFactoryFunction = AbstractItemDescriptor.getItemFunction();

    Collection<IItemDescriptor<Factory>> enableFactories = Collections2.filter(registry.getItemDescriptors(),
            Predicates.not(Predicates.in(getDisabledEngines())));
    return Collections2.transform(enableFactories, toFactoryFunction);
}

From source file:io.cloudsoft.versiondiffer.JavaFileComparer.java

private String strippedJavaSource(Path path) throws IOException {
    List<String> lines = Files.readAllLines(path);
    if (startsWithLicenseHeader(lines)) {
        lines = lines.subList(LICENSE_HEADER.size(), lines.size());
    }/* ww  w.j  a  v a  2  s .  c o  m*/
    return Joiner.on("\n")
            .join(FluentIterable.from(lines).filter(Predicates.not(StringPredicates.startsWith("import "))));
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.actions.admin.ViewSonarServerMatrix.java

/**
 * Getter for buildables/*ww  w .ja v a2s.  co m*/
 *
 * @return the buildables
 */
public Collection<Buildable> getBuildables() {
    if (buildables == null) {
        buildables = Collections2.filter(planManager.getAllPlans(Buildable.class), Predicates.and(
                Predicates.not(PlanPredicates.isSuspendedFromBuilding()), SonarPredicates.hasSonarTasks()));
    }
    return buildables;
}

From source file:com.facebook.buck.config.AbstractCellConfig.java

/**
 * Translates the 'cell name'->override map into a 'Path'->override map.
 * @param pathMapping a map containing paths to all of the cells we want to query.
 * @return 'Path'->override map/*from w  w w.j av  a2  s  .  c om*/
 */
public ImmutableMap<Path, RawConfig> getOverridesByPath(ImmutableMap<RelativeCellName, Path> pathMapping)
        throws MalformedOverridesException {

    ImmutableSet<RelativeCellName> relativeNamesOfCellsWithOverrides = FluentIterable.from(getValues().keySet())
            .filter(Predicates.not(ALL_CELLS_OVERRIDE::equals)).toSet();
    ImmutableSet.Builder<Path> pathsWithOverrides = ImmutableSet.builder();
    for (RelativeCellName cellWithOverride : relativeNamesOfCellsWithOverrides) {
        if (!pathMapping.containsKey(cellWithOverride)) {
            throw new MalformedOverridesException(
                    String.format("Trying to override settings for unknown cell %s", cellWithOverride));
        }
        pathsWithOverrides.add(pathMapping.get(cellWithOverride));
    }

    ImmutableMultimap<Path, RelativeCellName> pathToRelativeName = Multimaps.index(pathMapping.keySet(),
            Functions.forMap(pathMapping));

    for (Path pathWithOverrides : pathsWithOverrides.build()) {
        ImmutableCollection<RelativeCellName> namesForPath = pathToRelativeName.get(pathWithOverrides);
        if (namesForPath.size() > 1) {
            throw new MalformedOverridesException(
                    String.format("Configuration override is ambiguous: cell rooted at %s is reachable "
                            + "as [%s]. Please override the config by placing a .buckconfig.local file in the "
                            + "cell's root folder.", pathWithOverrides, Joiner.on(',').join(namesForPath)));
        }
    }

    Map<Path, RawConfig> overridesByPath = new HashMap<>();
    for (Map.Entry<RelativeCellName, Path> entry : pathMapping.entrySet()) {
        RelativeCellName cellRelativeName = entry.getKey();
        Path cellPath = entry.getValue();
        RawConfig configFromOtherRelativeName = overridesByPath.get(cellPath);
        RawConfig config = getForCell(cellRelativeName);
        if (configFromOtherRelativeName != null) {
            Preconditions.checkState(configFromOtherRelativeName.equals(config),
                    "Attempting to create cell %s at %s with conflicting overrides [%s] vs [%s].",
                    cellRelativeName, cellPath, configFromOtherRelativeName, config);
        } else {
            overridesByPath.put(cellPath, config);
        }
    }

    return ImmutableMap.copyOf(overridesByPath);
}

From source file:edu.umn.msi.tropix.client.directory.impl.UserIterableImpl.java

public Iterator<GridUser> iterator() {
    final Collection<GridUser> users = new LinkedList<GridUser>();
    final Multimap<String, Person> persons = personSupplier.get();
    for (String institution : persons.keySet()) {
        Iterables.addAll(users,/*  w w  w  .j a va 2 s.c  om*/
                Iterables.filter(
                        Collections2.transform(persons.get(institution), new PersonFunction(institution)),
                        Predicates.not(Predicates.isNull())));
    }
    for (final GridUser user : users) {
        gridUserMap.put(user.getGridId(), user);
    }
    return users.iterator();
}