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

Comments

Projects
None yet
2 participants
@marcelstoer

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 11, 2012

Member

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

Member

timowest commented Apr 11, 2012

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

@marcelstoer

This comment has been minimized.

Show comment
Hide comment
@marcelstoer

marcelstoer Apr 11, 2012

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

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

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 11, 2012

Member

Yes

Member

timowest commented Apr 11, 2012

Yes

timowest added a commit that referenced this issue Apr 11, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Apr 20, 2012

Member

Released in 2.5.0

Member

timowest commented Apr 20, 2012

Released in 2.5.0

@timowest timowest closed this Apr 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment