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

There is no default method to generate String #3

Closed
caelcs opened this issue Oct 28, 2014 · 2 comments
Closed

There is no default method to generate String #3

caelcs opened this issue Oct 28, 2014 · 2 comments

Comments

@caelcs
Copy link

caelcs commented Oct 28, 2014

I tried to generate a String like this

RDG.string(20).next()

But I always have to set the size, and also there is a static field which contain a default. I think that it should be consistent like integer like this:

RDG.String().next()

mileswilson pushed a commit to mileswilson/fyodor that referenced this issue Oct 29, 2014
@mileswilson
Copy link

This makes sense to me. See a quick pull request I've thrown together.

@IanEsling
Copy link
Collaborator

makes sense to me too (was actually surprised we didn't do this!) good catch, thank you.

I think the proper solution though is for all the no-arg methods to return next() from a private static default Generator.

So we'd add a new method string() that would return the string field (that is/should be private final) that is currently there (as per the original issue), but I think we should also add private final static members for Generator<Integer>, Generator<Long>, Generator<Boolean> etc that are used by the relevant no-arg methods rather than creating new generators each time they're called, I think that should just be the standard way to implement a method returning a default generator.

Does that make sense?

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

3 participants