highfive.utils.Utl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of highfive Show documentation
Show all versions of highfive Show documentation
HighFive reads the data in the tables of a database schema and hashes it all with the aim of comparing it to a destination
database, where this data has been migrated. It only succeeds if all data fields of all data rows
of all (or selected) tables in both schemas produce the exact same SHA-1 hash value. It currently
supports the Oracle, DB2 LUW, PostgreSQL, SQL Server, MySQL and MariaDB databases.
The newest version!
package highfive.utils;
public class Utl {
private static final char[] DIGITS = "0123456789abcdef".toCharArray();
public static boolean distinct(final String a, final String b) {
return a == null ? b != null : !a.equals(b);
}
public static boolean empty(final String s) {
return s == null || s.trim().isEmpty();
}
public static String toHex(final byte[] bytes) {
char[] result = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
result[j * 2] = DIGITS[v >>> 4];
result[j * 2 + 1] = DIGITS[v & 0x0F];
}
return new String(result);
}
public static String coalesce(final String... strings) {
for (String s : strings) {
if (s != null) {
return s;
}
}
return null;
}
}