List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:com.yatu.config.SwaggerConfig.java
private Predicate<String> paths() { return Predicates.not(PathSelectors.regex("/error")); }
From source file:com.github.jeluard.extend.PluginLoader.java
/** * Load the implementation of T.//from w w w . j av a 2 s .c o m * Expects to detect a single {@link Plugin.Default} and a single alternative implementation. * * @param <T> * @param type * @return the implementation of T * @throws IllegalArgumentException if does not detect a single {@link Plugin.Default} and a single alternative implementation */ public <T extends Plugin.Alternative> T load(final Class<T> type) { Preconditions.checkNotNull(type, "null type"); final List<T> plugins = Lists.newArrayList(this.loader.load(type)); if (plugins.isEmpty()) { throw new IllegalArgumentException("No implementation for " + type); } final Predicate<T> defautPluginPredicate = new PluginLoader.DefaultPluginPredicate<T>(); final Collection<T> defaults = Collections2.filter(plugins, defautPluginPredicate); final Collection<T> alternatives = Collections2.filter(plugins, Predicates.not(defautPluginPredicate)); if (defaults.isEmpty()) { throw new IllegalArgumentException( "No default implementation for " + type + " among <" + Iterables.toString(plugins) + ">"); } if (defaults.size() > 1) { throw new IllegalArgumentException("Found multiple default implementation for " + type + ": <" + Iterables.toString(defaults) + ">"); } if (plugins.size() == 1) { //Plugins consist of a single default return defaults.iterator().next(); } else if (alternatives.size() > 1) { throw new IllegalArgumentException("Found multiple non-default implementation for " + type + ": <" + Iterables.toString(alternatives) + ">"); } else { //Only one alternative return alternatives.iterator().next(); } }
From source file:com.facebook.buck.core.cell.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/*w ww .j a va2 s .co m*/ */ public ImmutableMap<Path, RawConfig> getOverridesByPath(ImmutableMap<CellName, Path> pathMapping) throws InvalidCellOverrideException { ImmutableSet<CellName> relativeNamesOfCellsWithOverrides = FluentIterable.from(getValues().keySet()) .filter(Predicates.not(CellName.ALL_CELLS_SPECIAL_NAME::equals)).toSet(); ImmutableSet.Builder<Path> pathsWithOverrides = ImmutableSet.builder(); for (CellName cellWithOverride : relativeNamesOfCellsWithOverrides) { if (!pathMapping.containsKey(cellWithOverride)) { throw new InvalidCellOverrideException( String.format("Trying to override settings for unknown cell %s", cellWithOverride)); } pathsWithOverrides.add(pathMapping.get(cellWithOverride)); } ImmutableMultimap<Path, CellName> pathToRelativeName = Multimaps.index(pathMapping.keySet(), Functions.forMap(pathMapping)); for (Path pathWithOverrides : pathsWithOverrides.build()) { ImmutableList<CellName> namesForPath = RichStream.from(pathToRelativeName.get(pathWithOverrides)) .filter(name -> name.getLegacyName().isPresent()).toImmutableList(); if (namesForPath.size() > 1) { throw new InvalidCellOverrideException( 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<CellName, Path> entry : pathMapping.entrySet()) { CellName cellRelativeName = entry.getKey(); Path cellPath = entry.getValue(); RawConfig configFromOtherRelativeName = overridesByPath.get(cellPath); RawConfig config = getForCell(cellRelativeName); if (configFromOtherRelativeName != null) { // Merge configs RawConfig mergedConfig = RawConfig.builder().putAll(configFromOtherRelativeName).putAll(config) .build(); overridesByPath.put(cellPath, mergedConfig); } else { overridesByPath.put(cellPath, config); } } return ImmutableMap.copyOf(overridesByPath); }
From source file:org.apache.jackrabbit.oak.plugins.index.aggregate.AggregationCursor.java
private void fetchNext() { if (aggregates != null && aggregates.hasNext()) { currentPath = aggregates.next(); init = true;/*w w w.j ava 2 s.c o m*/ return; } aggregates = null; if (cursor.hasNext()) { currentRow = cursor.next(); if (!currentRow.isVirtualRow()) { String path = currentRow.getPath(); aggregates = Iterators.filter( Iterators.concat(Iterators.singletonIterator(path), aggregator.getParents(rootState, path)), Predicates.not(Predicates.in(seenPaths))); } fetchNext(); return; } closed = true; }
From source file:us.eharning.atomun.mnemonic.spi.electrum.v2.MnemonicBuilderSpiImpl.java
/** * Checks that the given extension parameter is valid. * * @param parameter//from w w w.j av a2 s. com * instance containing extension parameters. * * @throws IllegalArgumentException * if the parameter contains unknown parameters. */ private static void checkExtensionNames(ExtensionBuilderParameter parameter) { Map<String, Object> extensions = parameter.getExtensions(); if (!KNOWN_EXTENSION_NAMES.containsAll(extensions.keySet())) { Iterable<String> unknownNames = Iterables.filter(extensions.keySet(), Predicates.not(Predicates.in(KNOWN_EXTENSION_NAMES))); throw new IllegalArgumentException( "Found unhandled extension names: " + Iterables.toString(unknownNames)); } }
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.DefaultMessageCreationValidator.java
private boolean checkTargetLifelineNotExplicitlyCreatedAtUpperTime() { boolean valid = true; SequenceDiagram sequenceDiagram = sequenceElementSource.getDiagram(); SequenceDiagramQuery sequenceDiagramQuery = new SequenceDiagramQuery(sequenceDiagram); for (ISequenceEvent sequenceEvent : Iterables.filter( sequenceDiagramQuery.getAllSequenceEventsUpperThan(firstClickLocation.y), Predicates.not(Predicates.instanceOf(Lifeline.class)))) { if (isCreateMessageFor(sequenceEvent, sequenceElementTarget.getLifeline().get().getInstanceRole())) { valid = false;/* w w w . j a v a 2 s .c o m*/ break; } } return valid; }
From source file:org.apache.druid.sql.calcite.rule.DruidSemiJoinRule.java
private DruidSemiJoinRule() { super(operand(Project.class, operand(Join.class, null, IS_LEFT_OR_INNER, some(operand(DruidRel.class, null, Predicates.and(DruidRules.CAN_BUILD_ON, Predicates.not(IS_GROUP_BY)), any()), operand(DruidRel.class, null, IS_GROUP_BY, any()))))); }
From source file:ezbake.data.graph.blueprints.visibility.VisibilityFilterQuery.java
@Override public Query hasNot(final String key, final Object value) { predicates.add(Predicates.not(blueprintsPredicate(key, com.tinkerpop.blueprints.Compare.EQUAL, value))); return this; }
From source file:org.apache.brooklyn.core.location.geo.LocalhostExternalIpLoader.java
@VisibleForTesting static List<String> getIpAddressWebsites() { String file = new ResourceUtils(LocalhostExternalIpLoader.class).getResourceAsString( "classpath://org/apache/brooklyn/location/geo/external-ip-address-resolvers.txt"); Iterable<String> lines = Splitter.on('\n').omitEmptyStrings().trimResults().split(file); List<String> urls = Lists .newArrayList(Iterables.filter(lines, Predicates.not(StringPredicates.startsWith("#")))); Collections.shuffle(urls);/* ww w . j av a2s. c om*/ return urls; }
From source file:org.n52.iceland.util.activation.Activatables.java
public static <K, T> Map<K, T> deactivatedMap(Map<K, T> map, ActivationProvider<? super K> provider) { return Maps.filterKeys(map, Predicates.not(asPredicate(provider))); }