List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.manager.ModelingProjectManagerImpl.java
private void loadAndOpenRepresentationsFiles(final List<URI> representationsFilesURIs, boolean user) { // Add the specific sessions listener (if not already added). SessionManager.INSTANCE.addSessionsListener(sessionManagerListener); // List only the representations files that are not already loaded or // that are not currently in loading. Iterator<URI> representationsFilesURIsToLoadIterator = Iterators.filter(representationsFilesURIs.iterator(), Predicates.not(Predicates.or(Predicates.in(sessionFileLoading), isAlreadyLoadedPredicate))); if (!representationsFilesURIsToLoadIterator.hasNext()) { return;//from w w w . ja v a 2 s .c om } // We add the representationsFilesURIs to the list of representations // files that are currently loading because the event // SessionListener.OPENING comes too late (after loading of the // representations file that can be very long). List<URI> tempRepresentationsFilesURIs = Lists.newArrayList(representationsFilesURIsToLoadIterator); sessionFileLoading.addAll(tempRepresentationsFilesURIs); // Launch the silently job to open the representations files for (URI representationsFilesURI : tempRepresentationsFilesURIs) { OpenRepresentationsFileJob.scheduleNewWhenPossible(representationsFilesURI, user); } }
From source file:gg.uhc.uhc.modules.death.DeathStandsModule.java
@EventHandler(priority = EventPriority.HIGH) public void on(PlayerDeathEvent event) { if (!isEnabled()) return;// w w w. ja v a2 s . co m Player player = event.getEntity(); // make the player invisible for the duration of their death animation player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 18, 1)); Location location = player.getLocation(); // create an armour stand at the player ArmorStand stand = player.getWorld().spawn(location.clone().add(0, .2D, 0), ArmorStand.class); stand.setBasePlate(false); stand.setArms(true); // give the armour stand the death message as a name stand.setCustomName(STAND_PREFIX + event.getDeathMessage()); stand.setCustomNameVisible(true); // face the same direction as the player stand.getLocation().setDirection(location.getDirection()); // set the armour stand helmet to be looking at the same yaw stand.setHeadPose(new EulerAngle(Math.toRadians(location.getPitch()), 0, 0)); // use the player's velocity as a base and apply it to the stand stand.setVelocity(player.getVelocity().clone().multiply(1.5D).add(new Vector(0D, .2D, 0D))); // start with player's existing items in each slot (if exists) Map<EquipmentSlot, ItemStack> toSet = getItems(player.getInventory()); // overide with any saved items in the metadata toSet.putAll(getSavedSlots(player)); // filter out the invalid items toSet = Maps.filterValues(toSet, Predicates.not(EMPTY_ITEM)); List<ItemStack> drops = event.getDrops(); for (Map.Entry<EquipmentSlot, ItemStack> entry : toSet.entrySet()) { ItemStack stack = entry.getValue(); if (stack == null) continue; // remove the first matching stack in the drop list removeFirstEquals(drops, stack); // set the item on the armour stand in the correct slot switch (entry.getKey()) { case HAND: stand.setItemInHand(stack); break; case HEAD: stand.setHelmet(stack); break; case CHEST: stand.setChestplate(stack); break; case LEGS: stand.setLeggings(stack); break; case FEET: stand.setBoots(stack); break; } } }
From source file:org.apache.helix.controller.rebalancer.strategy.CrushRebalanceStrategy.java
/** * Use the predicate to reject already selected zones or nodes. *//* w w w.j a v a2s. co m*/ private Predicate<Node> nodeAlreadySelected(Set<Node> selectedNodes) { return Predicates.not(Predicates.in(selectedNodes)); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.util.EventFinder.java
/** * Returns the deepest event in the hierarchy of sub-event starting from * this finder's context which includes completely the specified range. * /* w ww . j a va 2 s. c o m*/ * @param range * the range to look for. * @return the deepest event, starting from this finder's context, which * includes the specified range, or <code>null</code>. */ public ISequenceEvent findMostSpecificEvent(Range range) { if (context instanceof Message) { return null; } ISequenceEvent result = null; if (contextIncludesRange(range)) { if (context != null && !shouldIgnore().apply(context)) { boolean okForReconnection = !isReconnection() || !Message.NO_RECONNECTABLE_EVENTS.apply(context); boolean okForReparent = !isReparent() || !AbstractNodeEvent.NO_REPARENTABLE_EVENTS.apply(context); if (okForReconnection && okForReparent) { result = context; } } } if (contextIncludesRange(range) || isReparent()) { Predicate<ISequenceEvent> sameLifeline = new SameLifelinePredicate(lifeline); List<ISequenceEvent> eventsToInspect = Lists.newArrayList(); if ((reconnect || reparent) && (context instanceof AbstractNodeEvent || context instanceof Lifeline)) { for (View view : Iterables.filter(context.getNotationView().getChildren(), View.class)) { Option<ISequenceEvent> ise = ISequenceElementAccessor.getISequenceEvent(view); if (ise != null && ise.some() && !reparented.containsKey(ise.get())) { eventsToInspect.add(ise.get()); } } // handle reparented events // look for new child for (Entry<AbstractNodeEvent, ISequenceEvent> entry : reparented.entrySet()) { if (entry.getValue() == context) { eventsToInspect.add(entry.getKey()); } } } else { eventsToInspect.addAll(context.getSubEvents()); } for (ISequenceEvent child : Iterables.filter(eventsToInspect, Predicates.and(sameLifeline, Predicates.not(shouldIgnore())))) { EventFinder childFinder = new EventFinder(child, lifeline); childFinder.setReconnection(isReconnection()); childFinder.setReparent(isReparent()); childFinder.setEventsToIgnore(eventsToIgnore); childFinder.setExpansionZone(expansionZone); childFinder.setVerticalRangefunction(verticalRangeFunction); childFinder.setReparented(reparented); ISequenceEvent moreSpecific = childFinder.findMostSpecificEvent(range); if (moreSpecific != null) { result = moreSpecific; break; } } } return result; }
From source file:com.google.devtools.build.android.dexer.DexFileMerger.java
@VisibleForTesting static void buildMergedDexFiles(Options options, Dexing.DexingOptions dexingOptions) throws IOException { ImmutableSet<String> classesInMainDex = options.mainDexListFile != null ? ImmutableSet.copyOf(Files.readAllLines(options.mainDexListFile, UTF_8)) : null;/*from ww w .ja va2 s .c o m*/ PrintStream originalStdOut = System.out; try (ZipFile zip = new ZipFile(options.inputArchive.toFile()); DexFileAggregator out = createDexFileAggregator(options)) { if (!options.verbose) { // com.android.dx.merge.DexMerger prints tons of debug information to System.out that we // silence here unless it was explicitly requested. System.setOut(DxConsole.noop); } MergingDexer dexer = new MergingDexer(new Dexing(dexingOptions), out, options.multidexMode.isMultidexAllowed(), options.maxNumberOfIdxPerDex); if (classesInMainDex == null) { processClassAndDexFiles(zip, out, dexer, Predicates.<ZipEntry>alwaysTrue()); } else { // Options parser should be making sure of this but let's be extra-safe as other modes // might result in classes from main dex list ending up in files other than classes.dex checkArgument(options.multidexMode == MultidexStrategy.MINIMAL, "Only minimal multidex " + "mode is supported with --main_dex_list, but mode is: %s", options.multidexMode); // To honor --main_dex_list make two passes: // 1. process only the classes listed in the given file // 2. process the remaining files Predicate<ZipEntry> classFileFilter = ZipEntryPredicates.classFileFilter(classesInMainDex); processClassAndDexFiles(zip, out, dexer, classFileFilter); dexer.flush(); // Add any main dex list classes we had to convert on-the-fly // Fail if main_dex_list is too big, following dx's example checkState(out.getDexFilesWritten() == 0, "Too many classes listed in main dex list file " + "%s, main dex capacity exceeded", options.mainDexListFile); if (options.minimalMainDex) { out.flush(); // Start new .dex file if requested } processClassAndDexFiles(zip, out, dexer, Predicates.not(classFileFilter)); } // Add any classes to output archive that we had to convert on-the-fly dexer.finish(); } finally { System.setOut(originalStdOut); } // Use input's timestamp for output file so the output file is stable. Files.setLastModifiedTime(options.outputArchive, Files.getLastModifiedTime(options.inputArchive)); }
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.policy.SequenceInteractionFeedBackBuilder.java
private void feedBackMovedElements(Collection<Figure> feedbacks) { for (ISequenceEvent movedElement : Iterables.filter(validator.getMovedElements(), Predicates.not(Predicates.in(validator.getEventsInError())))) { addFeedBack(movedElement, ISE_FEEDBACK_COLOR, false, feedbacks, validator.getRangeFunction().apply(movedElement)); }//from ww w . ja v a2s . c o m }
From source file:forge.game.card.CardLists.java
public static CardCollection getNotColor(Iterable<Card> cardList, byte color) { return CardLists.filter(cardList, Predicates.not(CardPredicates.isColor(color))); }
From source file:com.isotrol.impe3.pms.core.obj.RoutingDomainsObject.java
public List<RoutingDomainSelDTO> map2sel(boolean includeDefault) { final Predicate<RoutingDomainObject> p; if (includeDefault) { p = Predicates.alwaysTrue();//w ww .j a va 2s . c o m } else { p = Predicates.not(OBJ_DEFAULT); } return newArrayList(transform(Iterables.filter(byName.values(), p), RD2SEL)); }
From source file:jflowmap.views.flowstrates.MapLayer.java
private void createCentroids() { nodeIdsToCentroids = Maps.newLinkedHashMap(); FlowMapGraph flowMapGraph = flowstratesView.getFlowMapGraph(); // sort centroids so that more important are shown first Iterable<Node> nodes = CollectionUtils.sort(flowMapGraph.nodesHavingEdges(endpoint.dir()), Collections .reverseOrder(FlowMapNodeTotals.createMaxNodeWeightTotalsComparator(flowMapGraph, endpoint.dir()))); centroidMouseListener = createCentroidMouseListener(); Iterable<Node> nodesWithCoords = Iterables.filter(nodes, haveCoordsPredicate()); Iterable<Node> nodesWithoutCoords = flowMapGraph.sortByAttr( Iterables.filter(nodes, Predicates.not(haveCoordsPredicate())), flowMapGraph.getNodeLabelAttr()); createCentroidsForNodesWithCoords(nodesWithCoords); createCentroidsAndAreasForNodesWithoutCoords(nodesWithoutCoords); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.providers.decorators.SubDiagramDecorator.java
private boolean shouldHaveSubDiagDecoration(DRepresentationElement node) { EObject target = node.getTarget();/*from w w w . j a va2 s.co m*/ boolean shouldHaveSubDiagramDecorator = false; if (target != null && target.eResource() != null) { if (session != null && !parentHasSameSemanticElement(node)) { // Does the target element has any representation on it? Exclude // the current representation itself to avoid redundant markers. DRepresentation representation = new DRepresentationElementQuery(node).getParentRepresentation(); Predicate<DRepresentation> otherReperesentation = Predicates .not(Predicates.equalTo(representation)); shouldHaveSubDiagramDecorator = Iterables .any(DialectManager.INSTANCE.getRepresentations(target, session), otherReperesentation); if (node.getMapping() != null && !shouldHaveSubDiagramDecorator) { shouldHaveSubDiagramDecorator = checkRepresentationNavigationDescriptions(node); } } } return shouldHaveSubDiagramDecorator; }