Improve v6 for better Generics usage
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Beginne damit, die GetRequestConfiguration-Implementierungen in den Builder-Klassen zu lesen, und untersuche anschließend BaseCollectionPaginationCountResponse, UserCollectionResponse und die Verwendung von PageIterator. Das vorgeschlagene Ergebnis des Issues sind generische Konfigurator-Unterstützung, typisierte Collection-Antworten und weniger manuelle Behandlung von Discriminatoren; es werden keine bestimmten Dateien oder Tests genannt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Is your feature request related to a problem? Please describe the problem.
We are trying to use v6 with generic methods to reduce duplicate boiler plate code, but struggle to do this efficiently. We struggled with the following:
- GetRequestConfiguration
This class seems to be part of each Builder class and there is not one abstract parent implementation for all Builder classes. We can't write a generic method handling each entity because there are hundreds of seperate GetRequestConfiguration implementations, e.g. one for UsersRequestBuilder and this method now can only be used for UsersRequestBuilder:
public static Consumer<UsersRequestBuilder.GetRequestConfiguration> addAdvancedQueryCapabilities() {
return cust -> {
Objects.requireNonNull(cust.queryParameters).count = true;
cust.headers.add("ConsistencyLevel", "eventual");
};
}
The same applies for PostRequestConfiguration and all other classes.
- BaseCollectionPaginationCountResponse
Here we see some problems:
- This class is not typed at all. In v5 there is a generic return type of the response class which determines the correct class for the actual item values in the page collection.
- After the typing you could add getValue to the base class and not implement it in each subclass which should help to determine the actual return type in v6 as well.
- Also we think as improvement createFromDiscriminatorValue should be overwritten in each subclass with it's correct implementation (I think this is already done), but we don't understand why we have the need to manually pass the correct descriminator to the PageIterator. We believe this can be done automatically without manual interaction.
Our call currently looks like this using a similar PageIterator as seen in here:
UserCollectionResponse page = userCollectionRequest.get(customizer);
List<User> users = RequestUtils.collectListFromAllPages(this.graphClient.getGraphServiceClient(), page,
UserCollectionResponse::createFromDiscriminatorValue, this.getClass());
We already pass a UserCollectionResponse but we don't understand why the PageIterator does not get it's discriminator automatically and we have to set it manually by passing the explicit discriminator.
Also we can't use var users = ..., because we need to declare the return type as Entity and can't get it from UserCollectionResponse since that class is not typed.
What do you think about this?
Describe the solution you'd like.
For 1)
Use interfaces for the Configurators, such that generic implementations can be done using these interfaces.
For 2:
Already proposed above
Additional context?
No response
- Vorherrschende Sprache
- Java
- Sterne
- 444
- Forks
- 154
- Ø Merge
- 18 Std. 28 Min.
- Gemergte PRs (30 T.)
- 4
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoftgraph/msgraph-sdk-java
-
status:waiting-for-triage type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoftgraph/msgraph-sdk-java#2610 ·
-
status:waiting-for-triage type:bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
microsoftgraph/msgraph-sdk-java#2656 ·
-
status:waiting-for-triage type:bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
microsoftgraph/msgraph-sdk-java#2654 ·
-
status:waiting-for-triage
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
microsoftgraph/msgraph-sdk-java#2639 ·
-
status:waiting-for-triage type:bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
microsoftgraph/msgraph-sdk-java#2589 · 1 Kommentar ·
Alle Issues in microsoftgraph/msgraph-sdk-java
Ähnliche Issues
-
Bug Java Platform: Java
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-java#6138 · 1 Kommentar ·
-
bug needs triage p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 Kommentar ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/rocketmq-dashboard#4654 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100