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

Abstract swap conventions #1533

Merged
merged 2 commits into from Jul 25, 2017
Merged

Abstract swap conventions #1533

merged 2 commits into from Jul 25, 2017

Conversation

@jodastephen
Copy link
Member

@jodastephen jodastephen commented Jul 24, 2017

All single currency swap conventions are similar, so this creates an abstraction.

Additional Guavate method to simulate Optional.or.

All single currency swap conventions are similar
Add additional Guavate method for Optional.or
@jodastephen jodastephen requested a review from cjkent Jul 24, 2017
@cjkent
cjkent approved these changes Jul 25, 2017
* The Java 8 {@link Optional} class does not have an {@code or} method,
* so this provides an alternative.
*
* @param <T> the type of element in the iterable

This comment has been minimized.

@cjkent

cjkent Jul 25, 2017
Member

Copy-paste error

*
* @param <T> the type of element in the iterable
* @param suppliers the suppliers to combine
* @return the list that combines the inputs

This comment has been minimized.

@cjkent

cjkent Jul 25, 2017
Member

Copy-paste error

*/
@SuppressWarnings("unchecked")
@SafeVarargs
public static <T> Optional<T> firstNotEmpty(Supplier<Optional<? extends T>>... suppliers) {

This comment has been minimized.

@cjkent

cjkent Jul 25, 2017
Member

The equivalent Guava method for null is called firstNonNull (note "non" instead of "not"). Would it be better to be consistent with that?

*/
@SuppressWarnings("unchecked")
@SafeVarargs
public static <T> Optional<T> firstNotEmpty(Supplier<Optional<? extends T>>... suppliers) {

This comment has been minimized.

@cjkent

cjkent Jul 25, 2017
Member

This method is useful for the use cases in this PR, but would it be worth adding an overload with the signature:

Optional<T> firstNotEmpty(Optional<? extends T>... optionals)

That might be more generally useful.

@jodastephen jodastephen merged commit f2be48d into master Jul 25, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@jodastephen jodastephen deleted the topic/swap-convention branch Jul 25, 2017
@jodastephen jodastephen modified the milestone: v1.4 Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants