We have the following enumeration:
public enum ComponentTypes {
PDIFF(301),
TDIFF(302),
TADJ(303);
private long componentTypeId;
private ComponentTypes(long componentTypeId){
this.componentTypeId = componentTypeId;
}
public Long getId(){
return this.componentTypeId;
}
}
In one of our tests setup we do c.setComponentTypeId(ComponentTypes.TADJ.getId())
but when c.getComponentTypeId()
is invoked in the test it throws NullPointerException
, yet c.setComponentTypeId(303L)
works as expected. What am I missing with use of the enum to set the value?
EDIT
Looks like @Tom was straight on with the long/Long inconsistency. Now that getId()
returns long
not Long
it works as expected.
EDIT
Looks like what I said earlier was wrong autoboxing does work there as expected is no issue after I refreshed the system jvm etc -- which doesn't make any sense to me!