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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

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 w  w .jav  a 2 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.mustbe.consulo.roots.ContentFolderScopes.java

@NotNull
public static Predicate<ContentFolderTypeProvider> productionAndTest() {
    return cacheScope(PRODUCTION_AND_TEST, new NotNullFactory<Predicate<ContentFolderTypeProvider>>() {
        @NotNull//  ww  w  . j av a  2 s .co  m
        @Override
        public Predicate<ContentFolderTypeProvider> create() {
            return Predicates.or(production(), test());
        }
    });
}

From source file:org.eclipse.buildship.ui.view.task.TaskNodeViewerFilter.java

private static Predicate<TaskNode> createTaskNodeFilter(final TaskViewState state) {
    Predicate<TaskNode> projectTasks = new Predicate<TaskNode>() {

        @Override/*  ww  w  .  j ava  2s .c om*/
        public boolean apply(TaskNode taskNode) {
            return state.isProjectTasksVisible()
                    && taskNode.getType() == TaskNode.TaskNodeType.PROJECT_TASK_NODE;
        }
    };

    Predicate<TaskNode> taskSelectors = new Predicate<TaskNode>() {

        @Override
        public boolean apply(TaskNode taskNode) {
            return state.isTaskSelectorsVisible()
                    && taskNode.getType() == TaskNode.TaskNodeType.TASK_SELECTOR_NODE;
        }
    };

    Predicate<TaskNode> privateTasks = new Predicate<TaskNode>() {

        @Override
        public boolean apply(TaskNode taskNode) {
            return state.isPrivateTasksVisible() || taskNode.isPublic();
        }
    };

    return Predicates.and(Predicates.or(projectTasks, taskSelectors), privateTasks);
}

From source file:io.druid.client.SingleServerInventoryView.java

@Override
protected DruidServer addInnerInventory(DruidServer container, String inventoryKey, DataSegment inventory) {
    Predicate<DataSegment> predicate = Predicates.or(defaultFilter, Predicates.or(segmentPredicates.values()));
    if (predicate.apply(inventory)) {
        addSingleInventory(container, inventory);
    }//from  ww w .j a  va  2  s.c om
    return container;
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.predicates.SonarPredicates.java

/**
 * Get the is Sonar Maven task {@link Predicate}
 * /*from  w w w  . j  a va 2  s .  c  o  m*/
 * @return the {@link Predicate}
 */
public static Predicate<TaskDefinition> isSonarMavenTask() {
    return Predicates.or(isSonarMaven2Task(), isSonarMaven3Task());
}

From source file:org.oruko.dictionary.DictionaryApplication.java

@Bean
public Docket dictionaryApi() {

    ApiInfo apiInfo = new ApiInfo("Dictionary Api Documentation",
            "Documentation of the rest endpoint for the dictionary application", "v1", "", // termsOfServiceUrl
            "", // contact
            "", // license
            ""); // licenseUrl
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).select()
            .apis(Predicates.or(RequestHandlerSelectors.basePackage("org.oruko.dictionary.web.rest"),
                    RequestHandlerSelectors.basePackage("org.oruko.dictionary.auth.rest")))
            .build();//w  w  w. j  av  a  2  s  . c o  m
}

From source file:io.druid.client.BatchServerInventoryView.java

@Override
protected DruidServer addInnerInventory(final DruidServer container, String inventoryKey,
        final Set<DataSegment> inventory) {
    Predicate<DataSegment> predicate = Predicates.or(defaultFilter, Predicates.or(segmentPredicates.values()));
    // make a copy of the set and not just a filtered view, in order to not keep all the segment data in memory
    Set<DataSegment> filteredInventory = Sets.newHashSet(Iterables.filter(inventory, predicate));

    zNodes.put(inventoryKey, filteredInventory);
    for (DataSegment segment : filteredInventory) {
        addSingleInventory(container, segment);
    }/*from ww w.  j a  v a2 s.  com*/
    return container;
}

From source file:uk.ac.open.kmi.iserve.discovery.util.MatchResultPredicates.java

/**
 * Generates a Predicate that only accepts the Match Results that have a Match Type lower or equal to matchType
 *
 * @param matchType the matchType that defines the boundary
 * @param <T>       a subclass of MatchResult
 * @param <S>       a subclass of MatchType
 * @return the Predicate//ww  w  .  ja v a2 s.c o  m
 */
public static <T extends MatchResult, S extends MatchType> Predicate<T> lowerOrEqualTo(S matchType) {
    return Predicates.or(lowerThan(matchType), equalTo(matchType));
}

From source file:org.apache.druid.client.SingleServerInventoryView.java

@Override
protected DruidServer addInnerInventory(DruidServer container, String inventoryKey, DataSegment inventory) {
    Predicate<Pair<DruidServerMetadata, DataSegment>> predicate = Predicates.or(defaultFilter,
            Predicates.or(segmentPredicates.values()));
    if (predicate.apply(Pair.of(container.getMetadata(), inventory))) {
        addSingleInventory(container, inventory);
    }/* ww w  . j av  a  2 s  . c o m*/
    return container;
}

From source file:com.sds.dmonitor.webapi.config.apidoc.SwaggerConfiguration.java

/**
 * Swagger Springfox configuration./*from  w w  w  .  j a  v  a 2 s  .  c o  m*/
 *
 * @param jHipsterProperties the properties of the application
 * @return the Swagger Springfox configuration
 */
@Bean
public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(jHipsterProperties.getSwagger().getContactName(),
            jHipsterProperties.getSwagger().getContactUrl(), jHipsterProperties.getSwagger().getContactEmail());

    ApiInfo apiInfo = new ApiInfo(jHipsterProperties.getSwagger().getTitle(),
            jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(),
            jHipsterProperties.getSwagger().getTermsOfServiceUrl(), contact,
            jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl());

    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class).ignoredParameterTypes(Pageable.class)
            .ignoredParameterTypes(java.sql.Date.class)
            .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select()
            .paths(Predicates.or(regex(DEFAULT_INCLUDE_PATTERN), regex(ADDITIONAL_PATTERN))).build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}