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

Fix BROOKLYN-271: Avoiding object hashcode in entities' toString. #146

Merged
merged 3 commits into from
Jun 13, 2016

Conversation

kiuby88
Copy link
Contributor

@kiuby88 kiuby88 commented May 20, 2016

Fixing BROOKLYN-271
Avoiding object references in catalog ConfigKey cards, for example:

captura de pantalla 2016-05-19 a la s 17 46 04

Last picture shows that default value of softwareProcess.lifecycleTasks config key does not contain the object hashcode @XXXXX. Then, objects toString methods are modified to avoid the hashcode.

@kiuby88
Copy link
Contributor Author

kiuby88 commented May 20, 2016

@aledsage I think it should be better than apache/brooklyn-docs#68

@kiuby88 kiuby88 changed the title Avoiding object hashcode in entities' toString. Fix BROOKLYN-271: Avoiding object hashcode in entities' toString. May 20, 2016
@aledsage
Copy link
Contributor

Thanks @kiuby88 - agreed this will improve the auto-generated entity docs (as per BROOKLYN-271).

In general, I like the toString to give more specifics about the object where possible. That is possible for some of these, and not for others. I'll comment on individual methods where I think we could include more.


@Override
public String toString(){
return getClass().getName();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd go for the code below (using com.google.common.base.Objects):

@Override
public String toString() {
    return Objects.toStringHelper(this)
            .add("minDatapoints", minDatapoints)
            .add("timeToConsider",  timeToConsider)
            .add("maxProportionFailures", maxProportionFailures)
    .toString();
}

@Override
public String toString(){
return getClass().getName();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aledsage, this tries to avoid the following entry in the catalog for JcloudsLocation.
captura de pantalla 2016-05-31 a la s 10 24 10

I think this impl is enough, maybe ordering?

@aledsage
Copy link
Contributor

LGTM, thanks @kiuby88 - merging. I incorrectly marked BROOKLYN-271 as resolved before this PR (and apache/brooklyn-library#38) were merged - sorry about that, and thanks for spotting!

@asfgit asfgit merged commit ca6d747 into apache:master Jun 13, 2016
asfgit pushed a commit that referenced this pull request Jun 13, 2016
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.

3 participants