Java Code Examples for java.util.function.Predicate#isEqual()

The following examples show how to use java.util.function.Predicate#isEqual() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazeJavaWorkspaceImporterTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void testLibraryDepsWithJdepsReportingZeroShouldNotIncludeDirectDepsIfNotInWorkingSet() {
  ProjectView projectView =
      ProjectView.builder()
          .add(
              ListSection.builder(DirectorySection.KEY)
                  .add(DirectoryEntry.include(new WorkspacePath("java/apps/example")))
                  .add(DirectoryEntry.include(new WorkspacePath("javatests/apps/example"))))
          .build();
  TargetMapBuilder targetMapBuilder = targetMapForJdepsSuite();
  workingSet =
      new JavaWorkingSet(
          workspaceRoot,
          new WorkingSet(ImmutableList.of(), ImmutableList.of(), ImmutableList.of()),
          Predicate.isEqual("BUILD"));

  BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
  assertThat(
          result
              .libraries
              .values()
              .stream()
              .map(BlazeJavaWorkspaceImporterTest::libraryFileName)
              .collect(Collectors.toList()))
      .isEmpty();
}
 
Example 2
Source File: StandardFunctionalInterfaces.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
private static void predicate(){
    Predicate<Integer> isLessThan10 = i -> i < 10;

    System.out.println(isLessThan10.test(7));  //prints: true
    System.out.println(isLessThan10.test(12)); //prints: false

    int val = 7;
    Consumer<String> printIsSmallerThan10 =
            printWithPrefixAndPostfix("Is " + val + " smaller than 10? ", " Great!");
    printIsSmallerThan10.accept(String.valueOf(isLessThan10.test(val)));         //prints: Is 7 smaller than 10? true Great!

    Predicate<Integer> isEqualOrGreaterThan10 = isLessThan10.negate();
    System.out.println(isEqualOrGreaterThan10.test(7));   //prints: false
    System.out.println(isEqualOrGreaterThan10.test(12));  //prints: true

    isEqualOrGreaterThan10 = Predicate.not(isLessThan10);
    System.out.println(isEqualOrGreaterThan10.test(7));   //prints: false
    System.out.println(isEqualOrGreaterThan10.test(12));  //prints: true

    Predicate<Integer> isGreaterThan10 = i -> i > 10;
    Predicate<Integer> is_lessThan10_OR_greaterThan10 = isLessThan10.or(isGreaterThan10);
    System.out.println(is_lessThan10_OR_greaterThan10.test(20));   //prints: true
    System.out.println(is_lessThan10_OR_greaterThan10.test(10));   //prints: false

    Predicate<Integer> isGreaterThan5 = i -> i > 5;
    Predicate<Integer> is_lessThan10_AND_greaterThan5 = isLessThan10.and(isGreaterThan5);
    System.out.println(is_lessThan10_AND_greaterThan5.test(3));  //prints: false
    System.out.println(is_lessThan10_AND_greaterThan5.test(7));  //prints: true

    Person nick = new Person(42, "Nick", "Samoylov");
    Predicate<Person> isItNick = Predicate.isEqual(nick);
    Person john = new Person(42, "John", "Smith");
    Person person = new Person(42, "Nick", "Samoylov");
    System.out.println(isItNick.test(john));      //prints: false
    System.out.println(isItNick.test(person));    //prints: true
}
 
Example 3
Source File: BlazeJavaWorkspaceImporterTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void
    testLibraryDependenciesWithJdepsReportingNothingShouldStillIncludeDirectDepsIfInWorkingSet() {
  ProjectView projectView =
      ProjectView.builder()
          .add(
              ListSection.builder(DirectorySection.KEY)
                  .add(DirectoryEntry.include(new WorkspacePath("java/apps/example")))
                  .add(DirectoryEntry.include(new WorkspacePath("javatests/apps/example"))))
          .build();
  TargetMapBuilder targetMapBuilder = targetMapForJdepsSuite();
  workingSet =
      new JavaWorkingSet(
          workspaceRoot,
          new WorkingSet(
              ImmutableList.of(new WorkspacePath("java/apps/example/Test.java")),
              ImmutableList.of(),
              ImmutableList.of()),
          Predicate.isEqual("BUILD"));

  BlazeJavaImportResult result = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
  assertThat(
          result
              .libraries
              .values()
              .stream()
              .map(BlazeJavaWorkspaceImporterTest::libraryFileName)
              .collect(Collectors.toList()))
      .containsExactly("a.jar");
}
 
Example 4
Source File: InlineCachingWithDatabaseIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Bean
InlineCachingRegionConfigurer<Customer, Long> inlineCachingForCustomersRegionConfigurer(
		CustomerRepository customerRepository) {

	return new InlineCachingRegionConfigurer<>(customerRepository, Predicate.isEqual("Customers"));
}
 
Example 5
Source File: InlineCachingWithCassandraIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Bean
InlineCachingRegionConfigurer<Customer, Long> inlineCachingForCustomersRegionConfigurer(
		CustomerRepository customerRepository) {

	return new InlineCachingRegionConfigurer<>(customerRepository, Predicate.isEqual("Customers"));
}