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

Make public API setters fluent #294

Merged
merged 11 commits into from
Dec 13, 2018
Merged

Conversation

felixbarny
Copy link
Member

@felixbarny felixbarny commented Nov 9, 2018

depends on #293

@codecov-io
Copy link

codecov-io commented Nov 9, 2018

Codecov Report

Merging #294 into master will increase coverage by 0.21%.
The diff coverage is 55.76%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #294      +/-   ##
============================================
+ Coverage     71.43%   71.65%   +0.21%     
+ Complexity     1202     1197       -5     
============================================
  Files           133      132       -1     
  Lines          4631     4568      -63     
  Branches        474      471       -3     
============================================
- Hits           3308     3273      -35     
+ Misses         1108     1080      -28     
  Partials        215      215
Impacted Files Coverage Δ Complexity Δ
...m/agent/plugin/api/TransactionInstrumentation.java 52.38% <ø> (-4.38%) 3 <0> (-2)
.../agent/plugin/api/AbstractSpanInstrumentation.java 53.19% <100%> (ø) 3 <2> (ø) ⬇️
...pm/agent/plugin/api/LegacySpanInstrumentation.java 51.06% <51.06%> (ø) 2 <2> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dea72f3...117009e. Read the comment docs.

@ngourley
Copy link

This is pretty awesome. To support method chaining in 0.7 I was creating extension methods in Kotlin.

@felixbarny
Copy link
Member Author

Ideally, we should also remove the set prefix but so far I don't think it justifies a breaking change or deprecating the set methods and introducing others without the prefix.

@alvarolobato alvarolobato added this to the current milestone Nov 19, 2018
@felixbarny felixbarny self-assigned this Nov 19, 2018
Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

Add test that ensures chaining calls are working as expected

return null;
}

void doSetName(String name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe protected would be a more accurate accessor to these methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so, as package private is more restrictive. IntelliJ suggests removing the protected qualifier.

@ngourley
Copy link

ngourley commented Dec 6, 2018

Any update on this?

@felixbarny
Copy link
Member Author

It needs some changes to be compatible with the old API which has void return types. After the changes it can be merged :)

@felixbarny
Copy link
Member Author

thanks for the ping btw

@felixbarny
Copy link
Member Author

I have confirmed that this also works when using version 1.1.0 of the API

Copy link
Contributor

@eyalkoren eyalkoren left a comment

Choose a reason for hiding this comment

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

Great. Just go over all comments and make sure you submit it with the new package names, e.g. co.elastic.apm.agent.plugin instead of co.elastic.apm.plugin, and watch out not to add the agent package to co.elastic.apm.api


@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
return named("co.elastic.apm.api.SpanImpl").and(not(hasSuperType(named("co.elastic.apm.api.AbstractSpanImpl"))));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@felixbarny felixbarny merged commit f2a89b3 into elastic:master Dec 13, 2018
@felixbarny felixbarny deleted the fluent-public-api branch December 13, 2018 13:01
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.

5 participants