Skip to content

Add support for wildcards on the CustomClassMapper. #792

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

Merged
merged 4 commits into from
Sep 13, 2019
Merged

Conversation

rlazo
Copy link
Collaborator

@rlazo rlazo commented Sep 12, 2019

CustomClassMapper can now handle GenericTypeIndicators with wildcards, instead of strictly requiring the type specified.

CustomClassMapper can now handle GenericTypeIndicators with wildcards, instead of strictly requiring the type specified.
@@ -1763,6 +1763,15 @@ public void subclassingGenericTypeIndicatorIsAllowed() {
assertEquals("foo", bean.value);
}

@Test
public void usingWildcardInGenericTypeIndicatorIsAllowed() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add tests for:

  1. wildcard with lowerbound throws
  2. wildcard with multiple upperBounds uses the first one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL.

// that this array always has at least one element, since the unbounded wildcard <?> always
// has at least an upper bound of Object.
Type[] upperBounds = ((WildcardType) type).getUpperBounds();
hardAssert(upperBounds.length > 0, "Unexpected type bounds on wildcard " + type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assert message doesn't seem to match what is being asserted. While this problem exists in the original implementation, we could still want to take a stab at improving it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL.

An additional fix from Firestore for handling TypeVariables.
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Please do add a changelog.

@rlazo
Copy link
Collaborator Author

rlazo commented Sep 12, 2019

@schmidt-sebastian Added entry to the changelog. PTAL

Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks!

@rlazo
Copy link
Collaborator Author

rlazo commented Sep 13, 2019

/test new-smoke-tests

@rlazo rlazo merged commit 6571c9c into master Sep 13, 2019
@rlazo rlazo deleted the rl.rtdb-wildcard branch September 13, 2019 16:01
@firebase firebase locked and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Override cla size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants