TextUtils { public static boolean isNumericKey(String key) { if (key == null) { return false; } int length = key.length(); if (length == 0) { return false; } int i = 0; if (key.charAt(0) == '-') { if (length == 1) { return false; } i = 1; } for (; i < length; i++) { char c = key.charAt(i); if (c <= '/' || c >= ':') { return false; } } return true; }  static String replacePlaceholders(final String template, Map<Placeholder, String> values); static String getPlaceholder(Placeholder placeholder); static String underscoreToUpperCamel(String input); static boolean containsPlaceholder(final String template, Placeholder placeholder); static String enumerateValues(Collection<String> values); static String enumerateValues(Collection<String> values, String delimiter); static String joinLines(Collection<String> values); static String humanizedDuration(ZonedDateTime zonedDateTime); static String createAssignment(Map<String, Set<String>> data); static Map<String, Set<String>> parseAssignment(String data); static Set<Integer> parseRange(String range); static boolean isRange(String value); static Set<String> parseEnumeration(String data); static Set<String> parseEnumeration(String data, String delimiter); static boolean isRangeDelimiter(String key); static boolean isFirstElementKey(String key); static boolean isLastElementKey(String key); static boolean isNextElementKey(String key); static boolean isPrevElementKey(String key); static boolean isExitKey(String key); static boolean isSkipKey(String key); static boolean isYesKey(String key); static boolean isNoKey(String key); static boolean isRepeatKey(String key); static boolean isNumericKey(String key); static boolean isPositiveInt(String key); static String quoteIfNeeded(String value); static String getAsExactMatch(String value); static Collection<String> removeSuffixes(Collection<String> input, Collection<String> suffixes); static Optional<T> routeByKey(Map<Predicate<String>, Function<String, T>> routes); static Optional<T> routeByKey(Map<Predicate<String>, Function<String, T>> routes, Consumer<String> onInvalidKey); static Optional<T> routeByKey(Map<Predicate<String>, Function<String, T>> routes, Consumer<String> onInvalidKey, Consumer<Exception> onException); static String getVersion(); static final String YES; static final String NO; static final String QUIT; static final String DASH; }
@Test public void testIsNumericKey() { assertThat(isNumericKey("1"), is(true)); assertThat(isNumericKey("a"), is(false)); assertThat(isNumericKey(" "), is(false)); assertThat(isNumericKey(""), is(false)); assertThat(isNumericKey("-"), is(false)); }