Sometimes you come accross some nice snippets of code. Another hint that copy/paste is getting more used than brains. Some developers do not really care about what they write. I could wish they could suffered a lack of OO knowledge, but come on even a first-year student is supposed to understand polymorphism, isn’t he?
Enjoy this piece of code. Note the delicate use of Vector.
public static boolean isEqualDates(Date s1, Date s2) {
if (s1 == null && s2 != null)
return false;
if (s2 == null && s1 != null)
return false;
if (s2 == null)
return true;
return s1.equals(s2);
}
public static boolean isEqualString(String s1, String s2) {
if (s1 == null && s2 != null)
return false;
if (s2 == null && s1 != null)
return false;
if (s2 == null)
return true;
return s1.equals(s2);
}
public static boolean isEqualVectors(Vector s1, Vector s2) {
if (s1 == null && s2 != null)
return false;
if (s2 == null && s1 != null)
return false;
if (s2 == null)
return true;
return s1.equals(s2);
}
ps: of course these methods were hold by a class named ‘Util’, along with 300 other methods…