PalindromeChecker.java
package ch.hslu.exercises.sw01.ex7;
import org.apache.commons.lang3.StringUtils;
public final class PalindromeChecker {
private PalindromeChecker() {
}
public static boolean isPalindrome(final String number) {
if (number == null || !number.matches("[0-9]+")) {
return false;
}
return number.equals(StringUtils.reverse(number));
}
public static String getNextPalindrome(final String number) {
if (isPalindrome(number)) {
return number;
}
int nextNumber = Integer.parseInt(number) + 1;
return getNextPalindrome(Integer.toString(nextNumber));
}
}