My confined to Java features that will work inside the tMap component of Talend Open Studio.
I hate dealing with NullPointerExceptions. I have to clutter my code often with checks instead of just a.equals(b)
.
I created some sample functions and realized I can't be the only person who thought of this:
public static Integer toInt(Double d){
return (d == null) ? 0 : d.intValue();
}
public static Integer toInt(String d){
return (d == null) ? 0 : Integer.parseInt(d);
}
// equals without nullpointer exceptions
public static Boolean eq(Object a, Object b){
// no nullpointerexception
if (a == null && b == null) { return true;}
if (a == null ^ b == null) { return false;}
return a.equals(b);
}
Should my project keep accumulating such general methods, which many others probably need as well, or can I use an existing library as a dependency? I mean a lib of convenience methods in Java that just work.