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

Change constructor of a PasswordValidator acording PECS princips. #55

Closed
foal opened this issue Mar 3, 2017 · 3 comments
Closed

Change constructor of a PasswordValidator acording PECS princips. #55

foal opened this issue Mar 3, 2017 · 3 comments

Comments

@foal
Copy link

foal commented Mar 3, 2017

From

public PasswordValidator(final List<Rule> rules)

to

public PasswordValidator(final List<? super Rule> rules)

see for more information http://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super

@dfish3r
Copy link
Member

dfish3r commented May 9, 2017

My reading of that thread lends me to believe that we're got a producer.
And the pattern should be List<? extends Rule>.

Is there a specific compile time problem you're trying to solve?

@foal
Copy link
Author

foal commented May 9, 2017

Easy :)

private static final List<CharacterRule> RULES = ImmutableList.of(ucimpRule);
//...
validator = new PasswordValidator(StreamEx.of(RULES).map(r -> (Rule) r).toList());

@foal
Copy link
Author

foal commented May 9, 2017

And looks like you are right. It is a producer. So List<? extends Rule>.

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