In the first class I have:
package example.identification;
import example.common.InvalidDataException;
public class IdentifiableImpl implements Identifiable {
private String identifier;
public IdentifiableImpl(String id) throws InvalidDataException {
setIdentifier(id);
}
@Override
public String getIdentifier() {
return identifier;
}
public final void setIdentifier(String id) throws InvalidDataException {
if (id == null || id.length() == 0) {
throw new InvalidDataException("Null or empty ID passed to setIdentifier");
}
identifier = id;
}
}
In the second class I have:
package example.identification;
public class IdentifiableTest {
@Test
public void testGetIdentifier() {
IdentifiableImpl instance = new IdentifiableImpl();
instance.setIdentifier("Test");
}
The problem is in the second class with the line instance.setIdentifier("Test");
There is an error reported by the IDE on that line that says "Cannot find symbol."
My question is, why can I not call the setIdentifier("Test")
method on instance
?