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

Remove StripeAPIResourceCollection #294

Merged
merged 1 commit into from May 23, 2016

Conversation

brandur
Copy link
Contributor

@brandur brandur commented May 20, 2016

The current implementation has two collection implementations:

  • StripeAPIResourceCollection: Extends APIResource; used when a
    collection needs access to either request or requestCollection.
  • StripeAPICollection: Used in all other situations.

The two collection implementations are functionally identical except for
their parent class. This is somewhat error prone because as seen in #292,
it's easy to add something to one and forget about the other.

This pull eliminates StripeAPIResourceCollection and moves all
collections over to just extend StripeCollection, solving the
duplication problem and reducing code complexity.

The downside is that I've moved visibility of request and
requestCollection on APIResource to public so that they can be
called into from collection classes. It would be better if these had
something like internal visibility (a la C#), but Java doesn't really
support anything like that. IMO, it's still a reasonable trade-off and
we should still consider those request* methods "effectively" private
to the package and not part of the public API.

Fixes #292.

/cc @olivierbellone Thoughts on this one? Thanks!

The current implementation has two collection implementations:

* `StripeAPIResourceCollection`: Extends `APIResource`; used when a
  collection needs access to either `request` or `requestCollection`.
* `StripeAPICollection`: Used in all other situations.

The two collection implementations are functionally identical except for
their parent class. This is somewhat error prone because as seen in #292,
it's easy to add something to one and forget about the other.

This pull eliminates `StripeAPIResourceCollection` and moves all
collections over to just extend `StripeCollection`, solving the
duplication problem and reducing code complexity.

The downside is that I've moved visibility of `request` and
`requestCollection` on `APIResource` to public so that they can be
called into from collection classes. It would be better if these had
something like `internal` visibility (a la C#), but Java doesn't really
support anything like that. IMO, it's still a reasonable trade-off and
we should still consider those `request*` methods "effectively" private
to the package and not part of the public API.

Fixes #292.
@olivierbellone
Copy link
Contributor

This looks good!

Re. visibility, would omitting the modifier altogether (i.e. making the methods package-private) work?

@brandur
Copy link
Contributor Author

brandur commented May 20, 2016

Re. visibility, would omitting the modifier altogether (i.e. making the methods package-private) work?

Good question! So the problem with that one is that the APIResource implementation is in com.stripe.net while we need to make calls to those request methods in com.stripe.model. It may be possible to shuffle some of these types around a bit to share a package, but that would probably be a breaking change so probably best to leave as is :/

@olivierbellone
Copy link
Contributor

Ah, I knew I was missing something. I agree that this change is not worth breaking the current namespace structure. Let's 🚢 this!

@brandur
Copy link
Contributor Author

brandur commented May 23, 2016

@olivierbellone Cool! Thanks for taking a look.

@brandur brandur merged commit 3149d1b into master May 23, 2016
@brandur brandur deleted the brandur-remove-stripe-api-resource-collection branch May 23, 2016 13:46
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

Successfully merging this pull request may close these issues.

None yet

2 participants