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

Add collection method to Prefix #81

Closed
keilw opened this issue Mar 27, 2018 · 3 comments
Closed

Add collection method to Prefix #81

keilw opened this issue Mar 27, 2018 · 3 comments

Comments

@keilw
Copy link
Member

keilw commented Mar 27, 2018

While most Prefix implementations use a Java enum, its values() method is only available in the actual implementation. Can we add a method to Prefix that works like SystemOfUnits.getUnits()?

For enum based implementations, it seems rather straightforward via:
return Collections.<Prefix>unmodifiableSet(EnumSet.allOf(MetricPrefix.class));
see https://stackoverflow.com/questions/6528570/converting-from-enumseta-to-setb-when-a-inherits-from-b

Hopefully easier vote on how to call this method?

@keilw
Copy link
Member Author

keilw commented Mar 27, 2018

A) prefixes()

Inspired by the values() of enum (although Prefix implementations are not obliged to use enum)

@keilw
Copy link
Member Author

keilw commented Mar 27, 2018

B) getPrefixes()

Closer to e.g. similar methods in SystemOfUnits.

@keilw keilw added this to the 2.0 milestone Mar 27, 2018
@keilw keilw added the ready label Mar 28, 2018
@keilw keilw self-assigned this Mar 28, 2018
@keilw keilw added in progress and removed ready labels Mar 28, 2018
keilw added a commit that referenced this issue Mar 28, 2018
@keilw
Copy link
Member Author

keilw commented Mar 29, 2018

Actually a static method ended up a better option. While SystemOfUnits returns a Set of units, an instance of Prefix does not have to return all other prefixes. At the moment the SystemOfUnitsService returns the Set given the name of a Prefix enum like "MetricPrefix".

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

No branches or pull requests

1 participant