List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:com.palantir.ptoss.cinch.core.BindingContext.java
private List<Field> getBindableModelFields() { List<Field> allModelFields = Reflections.getFieldsOfTypeForClassHierarchy(object.getClass(), BindableModel.class); List<Field> notBindableFields = Reflections.getAnnotatedFieldsForClassHierarchy(object.getClass(), NotBindable.class); allModelFields = ImmutableList/* w w w .j a v a 2 s . c o m*/ .copyOf(Iterables.filter(allModelFields, Predicates.not(Predicates.in(notBindableFields)))); List<Field> nonFinalModelFields = ImmutableList .copyOf(Iterables.filter(allModelFields, Predicates.not(Reflections.IS_FIELD_FINAL))); if (!nonFinalModelFields.isEmpty()) { throw new BindingException("All BindableModels have to be final or marked with @NotBindable, but " + Iterables.transform(nonFinalModelFields, Reflections.FIELD_TO_NAME) + " are not."); } return allModelFields; }
From source file:com.google.devtools.build.lib.rules.cpp.LinkBuildVariables.java
private static Iterable<String> removePieIfCreatingSharedLibrary(boolean isCreatingSharedLibrary, List<String> flags) { if (isCreatingSharedLibrary) { return Iterables.filter(flags, Predicates.not(Predicates.equalTo("-pie"))); } else {//w w w . ja v a2s .c o m return flags; } }
From source file:com.google.devtools.build.lib.runtime.BlazeOptionHandler.java
/** * Parses the options from .rc files for a command invocation. It works in one of two modes; * either it loads the non-config options, or the config options that are specified in the {@code * configs} parameter./*from w ww . j a v a 2s . co m*/ * * <p>This method adds every option pertaining to the specified command to the options parser. To * do that, it needs the command -> option mapping that is generated from the .rc files. * * <p>It is not as trivial as simply taking the list of options for the specified command because * commands can inherit arguments from each other, and we have to respect that (e.g. if an option * is specified for 'build', it needs to take effect for the 'test' command, too). * * <p>Note that the order in which the options are parsed is well-defined: all options from the * same rc file are parsed at the same time, and the rc files are handled in the order in which * they were passed in from the client. * * @param rcfileNotes note message that would be printed during parsing * @param commandAnnotation the command for which options should be parsed. * @param optionsParser parser to receive parsed options. * @param optionsMap .rc files in structured format: a list of pairs, where the first part is the * name of the rc file, and the second part is a multimap of command name (plus config, if * present) to the list of options for that command * @param configs the configs for which to parse options; if {@code null}, non-config options are * parsed * @param unknownConfigs optional; a collection that the method will populate with the config * values in {@code configs} that none of the .rc files had entries for * @throws OptionsParsingException */ protected static void parseOptionsForCommand(List<String> rcfileNotes, Command commandAnnotation, OptionsParser optionsParser, List<Pair<String, ListMultimap<String, String>>> optionsMap, @Nullable Collection<String> configs, @Nullable Collection<String> unknownConfigs) throws OptionsParsingException { Set<String> knownConfigs = new HashSet<>(); for (String commandToParse : getCommandNamesToParse(commandAnnotation)) { for (Pair<String, ListMultimap<String, String>> entry : optionsMap) { String rcFile = entry.first; List<String> allOptions = new ArrayList<>(); if (configs == null) { Collection<String> values = entry.second.get(commandToParse); if (!values.isEmpty()) { allOptions.addAll(entry.second.get(commandToParse)); String inherited = commandToParse.equals(commandAnnotation.name()) ? "" : "Inherited "; String source = rcFile.equals("client") ? "Options provided by the client" : String.format("Reading rc options for '%s' from %s", commandAnnotation.name(), rcFile); rcfileNotes.add(String.format("%s:\n %s'%s' options: %s", source, inherited, commandToParse, Joiner.on(' ').join(values))); } } else { for (String config : configs) { String configDef = commandToParse + ":" + config; Collection<String> values = entry.second.get(configDef); if (!values.isEmpty()) { allOptions.addAll(values); knownConfigs.add(config); rcfileNotes.add(String.format("Found applicable config definition %s in file %s: %s", configDef, rcFile, String.join(" ", values))); } } } processOptionList(optionsParser, rcFile, allOptions); } } if (unknownConfigs != null && configs != null && configs.size() > knownConfigs.size()) { configs.stream().filter(Predicates.not(Predicates.in(knownConfigs))) .forEachOrdered(unknownConfigs::add); } }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.operation.SynchronizeISequenceEventsSemanticOrderingOperation.java
private EventEnd findEndPredecessor(EObject semanticElement, boolean startingEnd, List<EventEnd> eventEnds, Set<EventEnd> toIgnore) { EventEnd result = null;/* www .ja v a 2 s. com*/ for (EventEnd end : Iterables.filter(eventEnds, Predicates.not(Predicates.in(toIgnore)))) { if (isLookedEnd(semanticElement, startingEnd, end)) { break; } else { result = end; } } return result; }
From source file:clocker.docker.location.DockerContainerLocation.java
@Override public int copyFrom(final Map<String, ?> props, final String remote, final String local) { Map<String, ?> nonPortProps = Maps.filterKeys(props, Predicates.not(Predicates.containsPattern("port"))); boolean entitySsh = Boolean.TRUE.equals(entity.config().get(DockerContainer.DOCKER_USE_SSH)); boolean dockerSsh = Boolean.TRUE.equals(getOwner().config().get(DockerContainer.DOCKER_USE_SSH)); if (entitySsh && dockerSsh) { return super.copyFrom(nonPortProps, remote, local); } else {/*from w ww.ja v a 2 s . co m*/ String tmp = Os.mergePaths("/tmp", Joiner.on('-').join(dockerContainer.getId(), Urls.getBasename(local), Strings.makeRandomId(4))); String cp = String.format("cp %s:%s %s", dockerContainer.getContainerId(), remote, tmp); String output = getOwner().getDockerHost().runDockerCommand(cp); hostMachine.copyFrom(nonPortProps, tmp, local); LOG.info("Copying from {}:{} to {} - result: {}", new Object[] { dockerContainer.getContainerId(), remote, local, output }); return 0; } }
From source file:com.xebialabs.deployit.ci.server.DeployitDescriptorRegistryImpl.java
@Override public List<String> getDeployableResourceTypes() { Predicate<Descriptor> predicate = Predicates .not(Predicates.<Descriptor>or(new DescriptorPredicate(typeForName(UDM_ARTIFACT)), new DescriptorPredicate(typeForName(UDM_EMBEDDED_DEPLOYABLE)))); return toSortedDeployableTypeListing(predicate); }
From source file:edu.udo.scaffoldhunter.gui.dataimport.ImportMappingsDialog.java
private JComboBox getMergeToComboBox(final ImportJob job, JTable table, JComboBox mergeByCombobox) { Iterable<PropertyDefinition> existingPropDefsIt = Iterables.filter( sources.getDataset().getPropertyDefinitions().values(), Predicates.not(SHPredicates.IS_SCAFFOLD_PROPDEF)); final Vector<PropertyDefinition> existingPropDefs = new Vector<PropertyDefinition>(); Iterables.addAll(existingPropDefs, existingPropDefsIt); JComboBox mergeToComboBox = new JComboBox(); final MergeToModel mergeToModel = new MergeToModel(existingPropDefs, mergeToComboBox, mergeByCombobox); mergeToComboBox.setModel(mergeToModel); mergeToComboBox.addActionListener(new ActionListener() { @Override/*from w w w . j ava2s . c om*/ public void actionPerformed(ActionEvent e) { updateOkState(); job.setInternalMergeBy((PropertyDefinition) mergeToModel.getSelectedItem()); } }); return mergeToComboBox; }
From source file:com.eucalyptus.cluster.ClusterEndpoint.java
public DescribeAvailabilityZonesResponseType DescribeAvailabilityZones(DescribeAvailabilityZonesType request) throws EucalyptusCloudException { final DescribeAvailabilityZonesResponseType reply = (DescribeAvailabilityZonesResponseType) request .getReply();//from www . j a v a 2 s. c o m final List<String> args = request.getAvailabilityZoneSet(); final Filter filter = Filters.generate(request.getFilterSet(), Cluster.class); if (Contexts.lookup().hasAdministrativePrivileges()) { for (String keyword : describeKeywords.keySet()) { if (args.remove(keyword)) { reply.getAvailabilityZoneInfo().addAll(describeKeywords.get(keyword).get()); return reply; } } } else { for (String keyword : describeKeywords.keySet()) { args.remove(keyword); } } final Clusters clusterRegistry = Clusters.getInstance(); final List<Cluster> clusters; if (args.isEmpty()) { clusters = Lists.newArrayList(clusterRegistry.listValues()); Iterables.addAll(clusters, Iterables.filter(clusterRegistry.listDisabledValues(), Predicates.not(CollectionUtils.propertyPredicate( Collections2.transform(clusters, CloudMetadatas.toDisplayName()), CloudMetadatas.toDisplayName())))); } else { clusters = Lists.newArrayList(); for (final String partitionName : request.getAvailabilityZoneSet()) { try { clusters.add(Iterables.find(clusterRegistry.listValues(), new Predicate<Cluster>() { @Override public boolean apply(Cluster input) { return partitionName.equals(input.getConfiguration().getPartition()); } })); } catch (NoSuchElementException e) { try { clusters.add(clusterRegistry.lookup(partitionName)); } catch (NoSuchElementException ex) { try { clusters.add(clusterRegistry.lookupDisabled(partitionName)); } catch (NoSuchElementException ex2) { } } } } } for (final Cluster c : Iterables.filter(clusters, filter.asPredicate())) { reply.getAvailabilityZoneInfo().addAll(this.getDescriptionEntry(c)); } return reply; }
From source file:com.google.errorprone.fixes.SuggestedFixes.java
/** Deletes the given exceptions from a method's throws clause. */ public static Fix deleteExceptions(MethodTree tree, final VisitorState state, List<ExpressionTree> toDelete) { List<? extends ExpressionTree> trees = tree.getThrows(); if (toDelete.size() == trees.size()) { return SuggestedFix.replace(getThrowsPosition(tree, state), state.getEndPosition(getLast(trees)), ""); }//from ww w . j av a 2 s . c o m String replacement = FluentIterable.from(tree.getThrows()).filter(Predicates.not(Predicates.in(toDelete))) .transform(new Function<ExpressionTree, String>() { @Override @Nullable public String apply(ExpressionTree input) { return state.getSourceForNode(input); } }).join(Joiner.on(", ")); return SuggestedFix.replace(((JCTree) tree.getThrows().get(0)).getStartPosition(), state.getEndPosition(getLast(tree.getThrows())), replacement); }
From source file:forge.ai.AiController.java
public CardCollection getLandsToPlay() { final CardCollection hand = new CardCollection(player.getCardsIn(ZoneType.Hand)); hand.addAll(player.getCardsIn(ZoneType.Exile)); CardCollection landList = CardLists.filter(hand, Presets.LANDS); CardCollection nonLandList = CardLists.filter(hand, Predicates.not(CardPredicates.Presets.LANDS)); //filter out cards that can't be played landList = CardLists.filter(landList, new Predicate<Card>() { @Override// w w w . j av a2 s . co m public boolean apply(final Card c) { if (!c.getSVar("NeedsToPlay").isEmpty()) { final String needsToPlay = c.getSVar("NeedsToPlay"); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), needsToPlay.split(","), c.getController(), c); if (list.isEmpty()) { return false; } } return player.canPlayLand(c); } }); final CardCollection landsNotInHand = new CardCollection(player.getCardsIn(ZoneType.Graveyard)); landsNotInHand.addAll(game.getCardsIn(ZoneType.Exile)); if (!player.getCardsIn(ZoneType.Library).isEmpty()) { landsNotInHand.add(player.getCardsIn(ZoneType.Library).get(0)); } for (final Card crd : landsNotInHand) { if (!(crd.isLand() || (crd.isFaceDown() && crd.getState(CardStateName.Original).getType().isLand()))) { continue; } if (crd.hasKeyword("May be played") || crd.mayPlay(player) != null) { landList.add(crd); } } if (landList.isEmpty()) { return null; } if (landList.size() == 1 && nonLandList.size() < 3) { CardCollectionView cardsInPlay = player.getCardsIn(ZoneType.Battlefield); CardCollection landsInPlay = CardLists.filter(cardsInPlay, Presets.LANDS); CardCollection allCards = new CardCollection(player.getCardsIn(ZoneType.Graveyard)); allCards.addAll(player.getCardsIn(ZoneType.Command)); allCards.addAll(cardsInPlay); int maxCmcInHand = Aggregates.max(hand, CardPredicates.Accessors.fnGetCmc); int max = Math.max(maxCmcInHand, 6); // consider not playing lands if there are enough already and an ability with a discard cost is present if (landsInPlay.size() + landList.size() > max) { for (Card c : allCards) { for (SpellAbility sa : c.getSpellAbilities()) { if (sa.getPayCosts() != null) { for (CostPart part : sa.getPayCosts().getCostParts()) { if (part instanceof CostDiscard) { return null; } } } } } } } landList = CardLists.filter(landList, new Predicate<Card>() { @Override public boolean apply(final Card c) { canPlaySpellBasic(c); if (c.getType().isLegendary() && !c.getName().equals("Flagstones of Trokair")) { final CardCollectionView list = player.getCardsIn(ZoneType.Battlefield); if (Iterables.any(list, CardPredicates.nameEquals(c.getName()))) { return false; } } // don't play the land if it has cycling and enough lands are available final FCollectionView<SpellAbility> spellAbilities = c.getSpellAbilities(); final CardCollectionView hand = player.getCardsIn(ZoneType.Hand); CardCollection lands = new CardCollection(player.getCardsIn(ZoneType.Battlefield)); lands.addAll(hand); lands = CardLists.filter(lands, CardPredicates.Presets.LANDS); int maxCmcInHand = Aggregates.max(hand, CardPredicates.Accessors.fnGetCmc); for (final SpellAbility sa : spellAbilities) { if (sa.isCycling()) { if (lands.size() >= Math.max(maxCmcInHand, 6)) { return false; } } } return true; } }); return landList; }