0

On applying check style i am getting " hides a field" if the name of formal and actual parameters are same.

private String limitedDimensionId;

 /**
 * Sets the limited dimension id.
 * 
 * @param limitedDimensionId
 *            the new limited dimension id
 */
public void setLimitedDimensionId(final String limitedDimensionId) {
    this.limitedDimensionId = limitedDimensionId;
}

However i am not getting the same issue in the following case:

private boolean fallBack;

 /**
 * @param isFallBack
 *            the isFallBack to set
 */
public void setFallBack(final boolean isFallBack) {
    this.fallBack = isFallBack;
}

Both the conditions appear same to me. Still the discrepancy. Usually i change the name of the parameter variable to resolve this check style issue. But looking at the other case i am getting a hint that a more elegant solution is available. Any insights?

4

2 回答 2

1

The variable names are different:

fallBack vs isFallBack

Usually i change the name of the parameter variable to resolve this check style issue

That's correct solution.

于 2013-03-06T07:05:44.903 回答
0

I would agree that giving them different names is more appropriate, however the "this" keyword in the "this.limitedDimensionid" should avoid the "hides a field" error. That's what it's for...

于 2013-03-06T07:19:09.300 回答