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

Factorize code with ErrorsWrapper and Utils.nullToEmpty #25

Merged
merged 7 commits into from
Dec 14, 2016

Conversation

Gawen-pjr
Copy link
Contributor

@Gawen-pjr Gawen-pjr commented Dec 14, 2016

Just propagated usage of ErrorsWrapper interface and Utils.nullToEmpty static method for all domain classes.

@cdancy cdancy self-assigned this Dec 14, 2016
@cdancy cdancy added this to the v0.0.11 milestone Dec 14, 2016
@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

Have you run the mockTests locally (./gradlew clean build mockTest)? You should see failures.

Branch() {
}

@SerializedNames({ "id", "displayId", "type", "latestCommit", "latestChangeset", "isDefault", "errors" })
public static Branch create(String id, String displayId, String type,
String latestCommit, String latestChangeset, boolean isDefault, List<Error> errors) {
return new AutoValue_Branch(id, displayId, type, latestCommit, latestChangeset, isDefault,
errors != null ? ImmutableList.copyOf(errors) : ImmutableList.<Error> of());
return new AutoValue_Branch(Utils.nullToEmpty(errors), id, displayId, type, latestCommit, latestChangeset, isDefault);
Copy link
Owner

Choose a reason for hiding this comment

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

The Utils.nullToEmpty(errors) should be the last arg.

Copy link
Owner

Choose a reason for hiding this comment

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

Or maybe not if your implementing from super class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AutoValue generated class imposes me to pass errors as first argument.

Copy link
Owner

Choose a reason for hiding this comment

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

Fair enough and wasn't aware of that.


import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

public class Utils {
Copy link
Owner

Choose a reason for hiding this comment

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

Can we move this class to say src/main/java/com/cdancy/bitbucket/rest/util/Utils.java? Think it makes more sense there vs putting it under the domain folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I agree

@Gawen-pjr
Copy link
Contributor Author

All MockTests pass when I build locally. Travis also seems happy.

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr disregard that comment. It was in response to where you placed the Utils.toNull in the AutoValue constructor.

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr very awesome and glad you tackled this next. I was hoping your next PR was going to be this otherwise I was going to hop in and finish the work you started ;)

@Gawen-pjr
Copy link
Contributor Author

I'm currently factorizing classes with "Links" field which is also widely used. If you can wait 10 minutes before merging, I'll push the changes.

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr still reviewing on this end. I'll stop until I have the go-ahead from you that you're finished.

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr actually ... if you're looking to factor out other variables best to send that in a separate PR. It will make backing out potential changes in less problematic should the need arise.

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr I like this PullRequest as-is. Lets not add anything else unless it pertains to these changes.

Thoughts?

@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

@Gawen-pjr we can do these but no more in this PR!!! ;) I'll allow it because it cleans things up but I generally don't like to review large PR's. They should be as small as possible and address a single issue.

@Gawen-pjr
Copy link
Contributor Author

Aw, just pushed last changes. I'll rollback with a reverse commit

@Gawen-pjr
Copy link
Contributor Author

OK. I leave this PR as is. Starting a new PR for Links factorization. Sorry for the disturbances.

@cdancy cdancy merged commit 2b7441f into cdancy:master Dec 14, 2016
@cdancy
Copy link
Owner

cdancy commented Dec 14, 2016

Merged. Thanks for the code-cleanup/refactoring/PR @Gawen-pjr !!!

@Gawen-pjr
Copy link
Contributor Author

OK. See you in next PR ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants