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

Object[] property causing: has bad 'toString' method implementation in Intellij #235

Open
raspacorp opened this issue Jun 10, 2019 · 0 comments

Comments

@raspacorp
Copy link

There is already a similar issue about Intellij IDEA generated toString, however that one is very specific about a String property, so I opted to create a new one for this:

public class SearchResult
{
    private final Object[] lastRecordSortValues;
    private final int pageTotal;

    public Object[] getLastRecordSortValues()
    {
        return lastRecordSortValues;
    }

    public int getPageTotal()
    {
        return pageTotal;
    }

    @Override
    public boolean equals(final Object o)
    {
...
    }

    @Override
    public int hashCode()
    {
...
    }

    @Override
    public String toString()
    {
        return "SearchResult{" +
                "lastRecordSortValues=" + Arrays.toString(lastRecordSortValues) +
                ", pageTotal=" + pageTotal +
                '}';
    }
}

It seems it dislikes this: lastRecordSortValues=" + Arrays.toString(lastRecordSortValues)

This is the full message I get:

Class com.myapp.SearchResult has bad 'toString' method implementation.
The toString method should contain:
lastRecordSortValues=[Ljava.lang.Object;@26f09a1c
But does not.
Result of toString:
SearchResult{lastRecordSortValues=[], pageTotal=0}
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

No branches or pull requests

1 participant