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

Pimp instanceOf() with varargs #126

Closed
marcelstoer opened this issue Apr 11, 2012 · 4 comments
Closed

Pimp instanceOf() with varargs #126

marcelstoer opened this issue Apr 11, 2012 · 4 comments

Comments

@marcelstoer
Copy link

Reference:
https://groups.google.com/forum/#!topic/querydsl/5iXuogWxNYE

Use case:
Type A has numerous sub types K, L, M, etc. I need to query for a subset of sub types.

To add comfort it'd be really helpful if com.mysema.query.types.path.BeanPath.instanceOf(Class<B>) offered something like an overloaded method instanceOf(Class<B>...).

Currently I use something like

private BooleanExpression buildTypePredicateFor(Class<? extends A>... types) {
  BooleanExpression predicate = QA.a.instanceOf(types[0]);
  for (int i = 1; i < types.length; i++) {
    predicate = predicate.or(QA.a.instanceOf(types[i]));
  }
  return predicate;
}
@timowest
Copy link
Member

I'd prefer instanceOfAny(Class<?>... types) since it could be also interpreted wrongly.

@marcelstoer
Copy link
Author

Sure, sounds good. And for the inverse I can simply add .not(), right?

@timowest
Copy link
Member

Yes

timowest added a commit that referenced this issue Apr 11, 2012
@timowest
Copy link
Member

Released in 2.5.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
Development

No branches or pull requests

2 participants