In my class three instance variables which are all final. However, when I try to do something like this.inputsRelated = inputsRelated
in the setter method, I get an understandable error which says final field cannot be assigned. But what would the approach in setter methods/how should I handle the methods public void setInputsRelated(boolean inputsRelated)
and public void setExpected(int expected)
? Thanks in advance!
public class ExceptionLogicParameters extends RuntimeException {
public final boolean inputsRelated;
public final int expected;
public final int found;
public ExceptionLogicParameters(boolean inputsRelated, int expected, int found)
{
this.inputsRelated = inputsRelated;
this.expected = expected;
this.found = found;
}
@Override
public String toString()
{
return "Get the the hell out of here!";
}
public boolean getInputsRelated()
{
return this.inputsRelated;
}
public int getExpected()
{
return this.expected;
}
public int getFound()
{
return this.found;
}
public void setInputsRelated(boolean inputsRelated)
{
this.inputsRelated = inputsRelated;
}
public void setExpected(int expected)
{
this.expected = expected;
}
}