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

Support Enums in CaseBuilder #635

Closed
dmitrygusev opened this issue Jan 21, 2014 · 1 comment
Closed

Support Enums in CaseBuilder #635

dmitrygusev opened this issue Jan 21, 2014 · 1 comment
Milestone

Comments

@dmitrygusev
Copy link

@dmitrygusev dmitrygusev commented Jan 21, 2014

This is similar to #574 but for enums. Supporting enums allows ordering and aggregation on EnumExpression, that are not available for SimpleExpression.

Something like this may work:

public <T extends Enum<T>> Cases<T,EnumExpression<T>> then(EnumExpression<T> expr) {
    return thenEnum(expr);
}

@SuppressWarnings("unchecked")
private <T extends Enum<T>> Cases<T,EnumExpression<T>> thenEnum(EnumExpression<T> expr) {

    Class<T> enumClass = (Class<T>) expr.getType();

    return new Cases<T,EnumExpression<T>>(enumClass) {
        @Override
        protected EnumExpression<T> createResult(Class<T> type, Expression<T> last)
        {
            return EnumOperation.create(type, Ops.CASE, last);
        }
    }.addCase(when, expr);
}
timowest added a commit that referenced this issue Jan 21, 2014
@timowest
Copy link
Member

@timowest timowest commented Feb 8, 2014

Released in 3.3.1

@timowest timowest closed this Feb 8, 2014
@timowest timowest added this to the 3.3.1 milestone Apr 13, 2014
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