I have written a below routine in Java, I need to know that the code is Null Pointer Safe or not:
public class TRM_Fields {
public static String returnActualValue(String Staffing_Event,
String CurrentValue, String PriorValue) {
String returnValue;
returnValue = null;
if ("TRM".equalsIgnoreCase(Staffing_Event) && CurrentValue == null
&& PriorValue != null && !"".equalsIgnoreCase(PriorValue)) {
returnValue = PriorValue;
} else {
returnValue = CurrentValue;
}
return returnValue;
}
}
Any of the parameter Staffing_Event, CurrentValue and PriorValue may be null.
If it is not Null Pointer Safe what should I do to achieve that?
"".equalsIgnoreCase(null)do not throw aNullPointerException