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

Expose class information for TypeReference<T> #24568

Merged
merged 5 commits into from
Oct 20, 2021
Merged

Conversation

samvaity
Copy link
Member

@samvaity samvaity commented Oct 5, 2021

Fixes #23745

@ghost ghost added the Azure.Core azure-core label Oct 5, 2021
@samvaity samvaity self-assigned this Oct 5, 2021
@azure-sdk
Copy link
Collaborator

API changes have been detected in com.azure:azure-core. You can review API changes here

API changes

+         public Class<T> getClazz() 

@samvaity samvaity requested a review from alzimmermsft October 15, 2021 18:24
final TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() {};
final Map<String, Object> expectedJavaType = new HashMap<String, Object>() {};
assertEquals(expectedJavaType.getClass().getGenericSuperclass(), typeReference.getJavaType());
assertNull(typeReference.getClazz());
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should return the non-generic HashMap.class

* @return The {@link Class} representing instance of the {@link TypeReference} created
* using the {@link TypeReference#createInstance(Class)}, otherwise returns {@code null}.
*/
public Class<T> getClazz() {
Copy link
Member

Choose a reason for hiding this comment

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

To follow the other API maybe rename this to getJavaClass

@samvaity samvaity marked this pull request as ready for review October 18, 2021 17:44
@azure-sdk
Copy link
Collaborator

API changes have been detected in com.azure:azure-core. You can review API changes here

API changes

+     public interface ReferenceManager {
+         ReferenceManager INSTANCE = new ReferenceManagerImpl();
+         void register(Object object, Runnable cleanupAction) 
+     }
-         public Class<T> getClazz() 
+         public Class<T> getJavaClass() 

@samvaity samvaity requested a review from alzimmermsft October 18, 2021 21:08
@samvaity samvaity merged commit a980583 into Azure:main Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exposing getClass() for TypeReference<T>
3 participants