Skip to content

Conversation

@bitwiseman
Copy link
Member

@bitwiseman bitwiseman commented Feb 25, 2020

Description

Jackson can do binding of injected values for us rather than needing to special case them.

A continuation of this change would be to remove most of the initialization wrapUp(root) methods and add a binding for GitHub member.

Before submitting a PR:

We love getting PRs, but we hate asking people for the same basic changes every time.

  • Push your changes to a branch other than master. Create your PR from that branch.
  • Add JavaDocs and other comments
  • Write tests that run and pass in CI. See CONTRIBUTING.md for details on how to capture snapshot data.
  • Run mvn -D enable-ci clean install site locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.

@bitwiseman bitwiseman force-pushed the task/inject-response branch 2 times, most recently from 73d3c6c to 9d7e796 Compare February 25, 2020 03:48
* @param <T>
* type of the object
*/
private static <T> void setResponseHeaders(GitHubResponse.ResponseInfo responseInfo, T readValue) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the special case code that we had before.

* the {@link GitHubResponse.ResponseInfo} to get headers from.
*/
@JacksonInject
protected void setResponseHeaderFields(@CheckForNull GitHubResponse.ResponseInfo responseInfo) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what we do instead of the special case.

Record(@JsonProperty(value = "limit", required = true) int limit,
@JsonProperty(value = "remaining", required = true) int remaining,
@JsonProperty(value = "reset", required = true) long resetEpochSeconds,
@JacksonInject @CheckForNull GitHubResponse.ResponseInfo responseInfo) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Also, since we now have the the responseInfo injected during binding, we can make Record fully immutable. We don't have "recalculate" after creation.

@bitwiseman bitwiseman merged commit eb3ebdb into hub4j:master Feb 25, 2020
@bitwiseman bitwiseman deleted the task/inject-response branch March 5, 2020 00:53
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.

1 participant