List of usage examples for com.google.common.base Predicates or
public static <T> Predicate<T> or(Predicate<? super T> first, Predicate<? super T> second)
From source file:org.broad.igv.cbio.GeneNetwork.java
/** * Applies this predicate only to the genes. Any nodes * which are NOT genes are automatically kept. * <p/>/*from w w w . j a va 2s . com*/ * There is an override here, where we never filter out a Node which * is marked as being part of the query * * @param predicate * @return */ public int filterGenes(Predicate<Node> predicate) { Predicate<Node> genePredicate = Predicates.or(predicate, isNotGene); Predicate<Node> finalPredicate = Predicates.or(genePredicate, inQuery); return this.filterNodes(finalPredicate); }
From source file:com.twitter.aurora.scheduler.periodic.Preempter.java
/** * Creates a static filter that will identify tasks that may preempt the provided task. * A task may preempt another task if the following conditions hold true: * - The resources reserved for {@code preemptableTask} are sufficient to satisfy the task. * - The tasks are owned by the same user and the priority of {@code preemptableTask} is lower * OR {@code preemptableTask} is non-production and the compared task is production. * * @param preemptableTask Task to possibly preempt. * @return A filter that will compare the priorities and resources required by other tasks * with {@code preemptableTask}./*from w ww. jav a2 s.c om*/ */ private Predicate<AssignedTask> preemptionFilter(AssignedTask preemptableTask) { Predicate<AssignedTask> preemptableIsProduction = preemptableTask.getTask().isProduction() ? Predicates.<AssignedTask>alwaysTrue() : Predicates.<AssignedTask>alwaysFalse(); Predicate<AssignedTask> priorityFilter = greaterPriorityFilter(GET_PRIORITY.apply(preemptableTask)); return Predicates.or(Predicates.and(Predicates.not(preemptableIsProduction), IS_PRODUCTION), Predicates.and(isOwnedBy(getRole(preemptableTask)), priorityFilter)); }
From source file:com.github.rinde.rinsim.pdptw.common.DynamicPDPTWProblem.java
/** * Adds a {@link StopConditions} which indicates when the simulation has to * stop. The condition is added in an OR fashion to the predefined stop * condition of the scenario. So after this method is called the simulation * stops if the scenario stop condition is true OR new condition is true. * Subsequent invocations of this method will just add more conditions in the * same way.//from ww w . j ava2 s .c om * @param condition The stop condition to add. */ public void addStopCondition(Predicate<Simulator> condition) { stopCondition = Predicates.or(stopCondition, condition); }
From source file:uk.co.unclealex.executable.generator.scan.ExecutableAnnotationInformationFinderImpl.java
/** * Check to see if the command class is instantiable and return any declared * Guice Modules./*w w w .ja va 2s. c o m*/ * * @param clazz * The command class. * @param executable * The {@link Executable} annotation that has been found. * @return The array of Guice modules declared by the annotation. * @throws CommandNotInstantiableExecutableScanException * Thrown if the command class cannot be instantiatied. * @throws NonGuiceModulesReferencedException Thrown if non-Guice {@link Module}s are found. */ @SuppressWarnings("unchecked") protected Class<? extends Module>[] extractGuiceModules(Class<?> clazz, Method annotatedMethod, Executable executable) throws CommandNotInstantiableExecutableScanException, NonGuiceModulesReferencedException { Class<?>[] guiceModules = executable.value(); List<Class<?>> nonGuiceModules = Lists.newArrayList( Iterables.filter(Arrays.asList(guiceModules), Predicates.not(new IsGuiceModulePredicate()))); if (!nonGuiceModules.isEmpty()) { throw new NonGuiceModulesReferencedException(clazz, annotatedMethod, nonGuiceModules); } Predicate<Constructor<?>> isInstantiablePredicate = new IsDefaultConstructor(); if (guiceModules.length != 0) { isInstantiablePredicate = Predicates.or(isInstantiablePredicate, IsConstructorAnnotated.with(javax.inject.Inject.class)); isInstantiablePredicate = Predicates.or(isInstantiablePredicate, IsConstructorAnnotated.with(com.google.inject.Inject.class)); } if (!Iterables.any(Arrays.asList(clazz.getConstructors()), isInstantiablePredicate)) { throw new CommandNotInstantiableExecutableScanException(clazz); } return (Class<? extends Module>[]) guiceModules; }
From source file:org.apache.druid.client.HttpServerInventoryView.java
@Override public void registerSegmentCallback(Executor exec, SegmentCallback callback, Predicate<Pair<DruidServerMetadata, DataSegment>> filter) { if (lifecycleLock.isStarted()) { throw new ISE("Lifecycle has already started."); }//from w w w . j a v a 2 s . c o m SegmentCallback filteringSegmentCallback = new SingleServerInventoryView.FilteringSegmentCallback(callback, filter); segmentCallbacks.put(filteringSegmentCallback, exec); segmentPredicates.put(filteringSegmentCallback, filter); finalPredicate = Predicates.or(defaultFilter, Predicates.or(segmentPredicates.values())); }
From source file:com.ardor3d.input.control.OrbitCamControl.java
public void setupMouseTriggers(final LogicalLayer layer, final boolean dragOnly) { // Mouse look final Predicate<TwoInputStates> someMouseDown = Predicates.or(TriggerConditions.leftButtonDown(), Predicates.or(TriggerConditions.rightButtonDown(), TriggerConditions.middleButtonDown())); final Predicate<TwoInputStates> scrollWheelMoved = new MouseWheelMovedCondition(); final Predicate<TwoInputStates> dragged = Predicates.and(TriggerConditions.mouseMoved(), someMouseDown); final TriggerAction mouseAction = new TriggerAction() { // Test boolean to allow us to ignore first mouse event. First event can wildly vary based on platform. private boolean firstPing = true; public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { final MouseState mouse = inputStates.getCurrent().getMouseState(); if (mouse.getDx() != 0 || mouse.getDy() != 0) { if (!firstPing) { move(_xSpeed * mouse.getDx(), _ySpeed * mouse.getDy()); } else { firstPing = false;/*from w ww.j a va 2s.c o m*/ } } if (mouse.getDwheel() != 0) { zoom(_zoomSpeed * mouse.getDwheel()); } } }; final Predicate<TwoInputStates> predicate = Predicates.or(scrollWheelMoved, dragOnly ? dragged : TriggerConditions.mouseMoved()); _mouseTrigger = new InputTrigger(predicate, mouseAction); layer.registerTrigger(_mouseTrigger); }
From source file:forge.deck.generation.DeckGeneratorBase.java
protected Iterable<PaperCard> selectCardsOfMatchingColorForPlayer(boolean forAi) { // start with all cards // remove cards that generated decks don't like Predicate<CardRules> canPlay = forAi ? AI_CAN_PLAY : HUMAN_CAN_PLAY; Predicate<CardRules> hasColor = new MatchColorIdentity(colors); if (useArtifacts) { hasColor = Predicates.or(hasColor, COLORLESS_CARDS); }//from w ww . ja v a2 s . com return Iterables.filter(pool.getAllCards(), Predicates.compose(Predicates.and(canPlay, hasColor), PaperCard.FN_GET_RULES)); }
From source file:io.druid.client.HttpServerInventoryView.java
@Override public void registerSegmentCallback(Executor exec, SegmentCallback callback, Predicate<Pair<DruidServerMetadata, DataSegment>> filter) { SegmentCallback filteringSegmentCallback = new SingleServerInventoryView.FilteringSegmentCallback(callback, filter);//from ww w . jav a 2s . c o m segmentCallbacks.put(filteringSegmentCallback, exec); segmentPredicates.put(filteringSegmentCallback, filter); finalPredicate = Predicates.or(defaultFilter, Predicates.or(segmentPredicates.values())); }
From source file:com.google.errorprone.dataflow.nullnesspropagation.NullnessPropagationTransfer.java
/** * Constructs a {@link NullnessPropagationTransfer} instance with additional non-null returning * methods. The additional predicate is or'ed with the predicate for the built-in set of non-null * returning methods./*from w w w . j av a 2s.c om*/ */ public NullnessPropagationTransfer(Predicate<MethodInfo> additionalNonNullReturningMethods) { this(NULLABLE, Predicates.or(new ReturnValueIsNonNull(), additionalNonNullReturningMethods)); }
From source file:brooklyn.networking.sdn.SdnProviderImpl.java
@Override public void provisionNetwork(VirtualNetwork network) { // Call provisionNetwork on one of the agents to create it SdnAgent agent = (SdnAgent) (getAgents().getMembers().iterator().next()); String networkId = agent.provisionNetwork(network); // Create a DynamicGroup with all attached entities EntitySpec<DynamicGroup> networkSpec = EntitySpec.create(DynamicGroup.class) .configure(DynamicGroup.ENTITY_FILTER, Predicates.and( Predicates.not(Predicates.or(Predicates.instanceOf(DockerContainer.class), Predicates.instanceOf(DelegateEntity.class))), EntityPredicates.attributeEqualTo(DockerContainer.DOCKER_INFRASTRUCTURE, getAttribute(DOCKER_INFRASTRUCTURE)), SdnAttributes.attachedToNetwork(networkId))) .configure(DynamicGroup.MEMBER_DELEGATE_CHILDREN, true).displayName(network.getDisplayName()); DynamicGroup subnet = getAttribute(SDN_APPLICATIONS).addMemberChild(networkSpec); Entities.manage(subnet);/*from ww w .ja v a 2s. c o m*/ ((EntityLocal) subnet).setAttribute(VirtualNetwork.NETWORK_ID, networkId); ((EntityLocal) network).setAttribute(VirtualNetwork.NETWORKED_APPLICATIONS, subnet); getAttribute(SDN_NETWORKS).addMember(network); }