0

I have a class like this.

public class Event {

public Event(String objectName, Integer moduleId, Integer actionId) {

  if (StringUtils.nullOrEmpty(objectName)) {
     throw new IllegalArgumentException("The objectName field is not supplied");
  }
  if (0 > moduleId || null == moduleId) {
     throw new IllegalArgumentException("The moduleId field is invalid");
  }
  if (0 > actionId || null == actionId) {
     throw new IllegalArgumentException("The actionId field is invalid");
  }

  objectName = objectName;
  moduleId = moduleId;
  actionId = actionId;
 }
}

When I test the null value for moduleId and actionId I got the null pointer exception. But it's fine for the objectName. Did I do something wrong?

HenlenLee
  • 435
  • 1
  • 11
  • 30

0 Answers0