@Test public void ignoreMalformed() { assertThat(StringUtil.splitToIntList("-4,a,5,7"), is(asList(-4, 5, 7))); }
@Nullable public static List<Integer> splitToIntList(@Nullable String input) { if (input == null) { return null; } List<Integer> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(input, ","); while (tokenizer.hasMoreElements()) { final String item = tokenizer.nextToken(); try { result.add(Integer.parseInt(item)); } catch (NumberFormatException ex) { Log.e("ROOM", "Malformed integer list", ex); } } return result; }
StringUtil { @Nullable public static List<Integer> splitToIntList(@Nullable String input) { if (input == null) { return null; } List<Integer> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(input, ","); while (tokenizer.hasMoreElements()) { final String item = tokenizer.nextToken(); try { result.add(Integer.parseInt(item)); } catch (NumberFormatException ex) { Log.e("ROOM", "Malformed integer list", ex); } } return result; } }
StringUtil { @Nullable public static List<Integer> splitToIntList(@Nullable String input) { if (input == null) { return null; } List<Integer> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(input, ","); while (tokenizer.hasMoreElements()) { final String item = tokenizer.nextToken(); try { result.add(Integer.parseInt(item)); } catch (NumberFormatException ex) { Log.e("ROOM", "Malformed integer list", ex); } } return result; }  }
StringUtil { @Nullable public static List<Integer> splitToIntList(@Nullable String input) { if (input == null) { return null; } List<Integer> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(input, ","); while (tokenizer.hasMoreElements()) { final String item = tokenizer.nextToken(); try { result.add(Integer.parseInt(item)); } catch (NumberFormatException ex) { Log.e("ROOM", "Malformed integer list", ex); } } return result; }  static StringBuilder newStringBuilder(); static void appendPlaceholders(StringBuilder builder, int count); @Nullable static List<Integer> splitToIntList(@Nullable String input); @Nullable static String joinIntoString(@Nullable List<Integer> input); }
StringUtil { @Nullable public static List<Integer> splitToIntList(@Nullable String input) { if (input == null) { return null; } List<Integer> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(input, ","); while (tokenizer.hasMoreElements()) { final String item = tokenizer.nextToken(); try { result.add(Integer.parseInt(item)); } catch (NumberFormatException ex) { Log.e("ROOM", "Malformed integer list", ex); } } return result; }  static StringBuilder newStringBuilder(); static void appendPlaceholders(StringBuilder builder, int count); @Nullable static List<Integer> splitToIntList(@Nullable String input); @Nullable static String joinIntoString(@Nullable List<Integer> input); static final String[] EMPTY_STRING_ARRAY; }