Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide adapters for Guava Predicates #172

Closed
odrotbohm opened this issue Jun 12, 2012 · 2 comments
Closed

Provide adapters for Guava Predicates #172

odrotbohm opened this issue Jun 12, 2012 · 2 comments

Comments

@odrotbohm
Copy link

@odrotbohm odrotbohm commented Jun 12, 2012

Writing Guava Predicates one usually ends up writing quite a few anonymous inner classes. This could be significantly improved by providing adapters of Querydsl predicates to Guava ones.

@timowest
Copy link
Member

@timowest timowest commented Jun 12, 2012

You hade something like this in mind?

@Test
public void Predicate() {
    Predicate<Cat> predicate = GuavaHelpers.wrap(QCat.cat.name.startsWith("Ann"));
    assertTrue(predicate.apply(new Cat("Ann")));
    assertFalse(predicate.apply(new Cat("Bob")));
}

@Test
public void Function() {
    Function<Cat, String> function = GuavaHelpers.wrap(QCat.cat.name);
    assertEquals("Ann", function.apply(new Cat("Ann")));
    assertEquals("Bob", function.apply(new Cat("Bob")));
}
@timowest
Copy link
Member

@timowest timowest commented Jun 28, 2012

Released in 2.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants