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

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

Introduction

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

Prototype

public static <T> Predicate<T> and(Predicate<? super T> first, Predicate<? super T> second) 

Source Link

Document

Returns a predicate that evaluates to true if both of its components evaluate to true .

Usage

From source file:com.anathema_roguelike.characters.abilities.targetingstrategies.TargetingStrategy.java

public void addTargetValidator(Predicate<Character> validator) {
    targetValidator = Predicates.and(targetValidator, validator);
}

From source file:org.n52.sos.request.operator.TransactionalRequestChecker.java

public void add(Predicate<RequestContext> p) {
    this.predicate = Predicates.and(this.predicate, p);
}

From source file:lodsve.springfox.config.SpringFoxDocket.java

private Predicate<RequestHandler> combine(Predicate<RequestHandler> requestHandlerSelector,
        Predicate<String> pathSelector) {
    return Predicates.and(requestHandlerSelector, transform(pathSelector));
}

From source file:org.caleydo.view.bicluster.elem.AMultiClusterElement.java

/**
 * @return/*  www. j  a  va  2  s  . c o m*/
 */
protected final ClusterContentElement createContent(Predicate<? super String> filter) {
    Builder builder = GLElementFactoryContext.builder();
    builder.withData(data);
    builder.put(EDetailLevel.class, EDetailLevel.MEDIUM);
    ClusterContentElement c = new ClusterContentElement(builder, Predicates.and(filter, notSingle));

    // trigger a scale event on vis change
    c.onActiveChanged(new GLElementFactorySwitcher.IActiveChangedCallback() {
        @Override
        public void onActiveChanged(int active) {
            relayoutParent();
        }
    });
    c.setMinSizeProvider(new IHasMinSize() {
        @Override
        public Vec2f getMinSize() {
            return getLayoutDataAs(Vec2f.class, AMultiClusterElement.this.getMinSize());
        }
    });
    return c;
}

From source file:org.apache.brooklyn.core.location.access.PortForwardManagerLocationResolver.java

@Override
public Location newLocationFromString(Map locationFlags, String spec, LocationRegistry registry) {
    ConfigBag config = extractConfig(locationFlags, spec, registry);
    Map globalProperties = registry.getProperties();
    String namedLocation = (String) locationFlags.get(LocationInternal.NAMED_SPEC_NAME.getName());
    String scope = config.get(PortForwardManager.SCOPE);

    Optional<Location> result = Iterables.tryFind(managementContext.getLocationManager().getLocations(),
            Predicates.and(Predicates.instanceOf(PortForwardManager.class),
                    LocationPredicates.configEqualTo(PortForwardManager.SCOPE, scope)));

    if (result.isPresent()) {
        return result.get();
    } else {//from  w  ww.  j  a  v a  2  s  .  com
        PortForwardManager loc = managementContext.getLocationManager()
                .createLocation(LocationSpec.create(PortForwardManagerImpl.class)
                        .configure(config.getAllConfig()).configure(LocationConfigUtils
                                .finalAndOriginalSpecs(spec, locationFlags, globalProperties, namedLocation)));

        if (LOG.isDebugEnabled())
            LOG.debug("Created " + loc + " for scope " + scope);
        return loc;
    }
}

From source file:com.facebook.litho.testing.viewtree.ViewPredicates.java

public static Predicate<View> hasVisibleText(final String text) {
    return Predicates.and(isVisible(), hasText(text));
}

From source file:com.ardor3d.input.android.AndroidFirstPersonControl.java

protected void setupMouseTriggers(final LogicalLayer lLayer) {
    // Mouse look
    final Predicate<TwoInputStates> someMouseDown = Predicates.or(TriggerConditions.leftButtonDown(),
            TriggerConditions.rightButtonDown());
    final Predicate<TwoInputStates> dragged = Predicates.and(TriggerConditions.mouseMoved(), someMouseDown);
    final TriggerAction dragAction = 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) {
            // ignore initial press to prevent "hopping"
            if (!inputStates.getPrevious().getMouseState().hasButtonState(ButtonState.DOWN)) {
                return;
            }/*from w ww .ja v a2  s  . c o  m*/

            final MouseState mouse = inputStates.getCurrent().getMouseState();
            if (mouse.getDx() != 0 || mouse.getDy() != 0) {
                if (!firstPing) {
                    rotate(source.getCanvasRenderer().getCamera(), -mouse.getDx(), -mouse.getDy());
                } else {
                    firstPing = false;
                }
            }
        }
    };

    lLayer.registerTrigger(new InputTrigger(dragged, dragAction));

    // pinch / zoom control
    final Predicate<TwoInputStates> pinched = new Predicate<TwoInputStates>() {
        public boolean apply(final TwoInputStates states) {
            return states.getCurrent().getMouseState().getDwheel() != states.getPrevious().getMouseState()
                    .getDwheel();
        }
    };

    final TriggerAction moveAction = new TriggerAction() {
        public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
            final Camera camera = source.getCanvasRenderer().getCamera();
            final Vector3 loc = new Vector3(camera.getDirection());
            loc.normalizeLocal()
                    .multiplyLocal(_zoomSpeed * tpf * inputStates.getCurrent().getMouseState().getDwheel())
                    .addLocal(camera.getLocation());
            camera.setLocation(loc);
        }
    };

    lLayer.registerTrigger(new InputTrigger(pinched, moveAction));
}

From source file:org.obeonetwork.dsl.uml2.design.tests.automation.common.ModelChangeRecorder.java

public Iterable<EObject> detachedObjects() {
    return Iterables.concat(Iterables.transform(
            Iterables.filter(changes, Predicates.and(Notifications.containmentRef, Notifications.deletion)),
            Notifications.toObjectValue));
}

From source file:com.twitter.aurora.scheduler.filter.AttributeFilter.java

/**
 * Tests whether an attribute matches a limit constraint.
 *
 * @param attributes Attributes to match against.
 * @param jobKey Key of the job with the limited constraint.
 * @param limit Limit value.//from   www .j  av  a 2  s  .c  o m
 * @param activeTasks All active tasks in the system.
 * @param attributeFetcher Interface for fetching attributes for hosts in the system.
 * @return {@code true} if the limit constraint is satisfied, {@code false} otherwise.
 */
static boolean matches(final Set<Attribute> attributes, final IJobKey jobKey, int limit,
        Iterable<IScheduledTask> activeTasks, final AttributeLoader attributeFetcher) {

    Predicate<IScheduledTask> sameJob = Predicates.compose(Predicates.equalTo(jobKey),
            Tasks.SCHEDULED_TO_JOB_KEY);

    Predicate<IScheduledTask> hasAttribute = new Predicate<IScheduledTask>() {
        @Override
        public boolean apply(IScheduledTask task) {
            Iterable<Attribute> hostAttributes = attributeFetcher.apply(task.getAssignedTask().getSlaveHost());
            return Iterables.any(hostAttributes, Predicates.in(attributes));
        }
    };

    return limit > Iterables.size(Iterables.filter(activeTasks, Predicates.and(sameJob, hasAttribute)));
}

From source file:com.facebook.litho.testing.viewtree.ViewPredicates.java

public static Predicate<View> hasVisibleTextWithTag(final String text, final int tagId, final Object tagValue) {
    return Predicates.and(hasVisibleText(text), hasTag(tagId, tagValue));
}