-
Notifications
You must be signed in to change notification settings - Fork 289
Fix CreateRequest chaining and provider ID extraction. #399
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty solid. A few ideas for improvement.
@@ -56,45 +62,52 @@ public boolean isEnabled() { | |||
* <p>Set the initial attributes of the new provider by calling various setter methods available | |||
* in this class. | |||
*/ | |||
public abstract static class CreateRequest { | |||
public abstract static class CreateRequest<T extends CreateRequest<T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets call this AbstractCreateRequest
or ProviderConfigCreateRequest
and reduce overusing the name CreateRequest
. This also doesn't need to be a nested class. Might be cleaner to put it elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of calling it AbstractCreateRequest instead of CreateRequest. However, I don't think we should move this into a separate class. Keeping it together is more consistent with all of our other CreateRequest/UpdateRequest classes.
On a somewhat related note, should AuthProviderConfig be renamed to AbstractProviderConfig? (Of course, the decision here might be influenced by our generics decision in #400.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the shorter name ProviderConfig
for this type (it's already nested in the auth
package so the "Auth" part is kind of redundant). Also may be this doesn't need to be an abstract class at all? Is there any behavior that child classes are expected to implement, or are they just adding more attributes to the parent type?
Perhaps we can just make it a regular class with a package-protected constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think renaming to ProviderConfig
makes sense given that "Auth" is redundant.
However, I think we should keep it abstract for 2 reasons:
- We never want to instantiate it on its own since it can't be used for anything.
- If we make it concrete then we will be forced to implement
getThis
inAuthProvider.AbstractCreateRequest
. The issue with this is that we then lose the ability to force its subclasses to implementgetThis
. If subclasses forget to overridegetThis
then it would break how the chaining works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does 2 actually apply here? Why would the outer class be required to implement a method of an abstract nested class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you're correct. However, I think keeping it abstract makes it more clear that we do not intend on instantiating it on its own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a suggestion, and a comment on the naming and abstract-ness. Feel free to address the latter in separate PRs.
This makes the base `CreateRequest` setters return the proper instance type, so that methods can be chained. This also makes it so that the provider ID can be parsed from the resource name. A package private `getProviderId()` method was also added, which will be needed by the `FirebaseUserManager` class when the provider config operations are added there. Also renamed `AuthProviderConfig` to `ProviderConfig` since "Auth" is redundant with the package name. This work is part of adding multi-tenancy support (see issue #332).
This makes the base CreateRequest setters return the proper instance type, so that methods can be chained. This also makes it so that the provider ID can be parsed from the resource name.
A package private getProviderId() method was also added, which will be needed by the FirebaseUserManager class when the provider config operations are added there.
This work is part of adding multi-tenancy support (see issue #332).