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

ENUM case insensitive #489

Open
mhagnumdw opened this issue Jan 7, 2019 · 1 comment
Open

ENUM case insensitive #489

mhagnumdw opened this issue Jan 7, 2019 · 1 comment

Comments

@mhagnumdw
Copy link
Member

Is there another less verbose way of converting a request parameter to an ENUM with case-insensitive?

The only way I saw it was implementing a convert, like this:

import ro.pippo.core.ParameterValue;
import ro.pippo.core.converters.Converter;

public final class TypeOrderIgnoreCaseConverter implements Converter<TypeOrder> {

    @Override
    public TypeOrder getAsObject(String[] values, Locale locale, String pattern) {
        final ParameterValue parameterValue = new ParameterValue(values);
        return parameterValue.toEnum(TypeOrder.class, null, false);
    }

}

Boring: for each ENUM it is necessary to have a specific converter.

My TypeOrder ENUM:

public enum TypeOrder {

    ASC("asc"), DESC("desc");

    // omitted for brevity

}
@decebals
Copy link
Member

decebals commented Jan 9, 2019

I don't use enum as request parameter. I cannot help you. I prefer to use plain variant with ParameterValue.

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