@Test public void testExtractIndex() { assertThat(DefaultValueUtilities.extractIndex("", PREFIX)).isNotPresent(); assertThat(DefaultValueUtilities.extractIndex("1", PREFIX)).isNotPresent(); assertThat(DefaultValueUtilities.extractIndex("a", PREFIX)).isNotPresent(); assertThat(DefaultValueUtilities.extractIndex(PREFIX + "a", PREFIX)).isNotPresent(); assertThat(DefaultValueUtilities.extractIndex(PREFIX + "1", PREFIX)).isPresent().hasValue(1); assertThat(DefaultValueUtilities.extractIndex(PREFIX + "55", PREFIX)).isPresent().hasValue(55); }
public static Optional<Integer> extractIndex(final String text, final String prefix) { if (text == null) { return Optional.empty(); } if (!text.startsWith(prefix)) { return Optional.empty(); } final String suffix = text.substring(prefix.length()); try { return Optional.of(Integer.parseInt(suffix)); } catch (NumberFormatException nfe) { return Optional.empty(); } }
DefaultValueUtilities { public static Optional<Integer> extractIndex(final String text, final String prefix) { if (text == null) { return Optional.empty(); } if (!text.startsWith(prefix)) { return Optional.empty(); } final String suffix = text.substring(prefix.length()); try { return Optional.of(Integer.parseInt(suffix)); } catch (NumberFormatException nfe) { return Optional.empty(); } } }
DefaultValueUtilities { public static Optional<Integer> extractIndex(final String text, final String prefix) { if (text == null) { return Optional.empty(); } if (!text.startsWith(prefix)) { return Optional.empty(); } final String suffix = text.substring(prefix.length()); try { return Optional.of(Integer.parseInt(suffix)); } catch (NumberFormatException nfe) { return Optional.empty(); } }  }
DefaultValueUtilities { public static Optional<Integer> extractIndex(final String text, final String prefix) { if (text == null) { return Optional.empty(); } if (!text.startsWith(prefix)) { return Optional.empty(); } final String suffix = text.substring(prefix.length()); try { return Optional.of(Integer.parseInt(suffix)); } catch (NumberFormatException nfe) { return Optional.empty(); } }  static void updateNewNodeName(final Graph<?, Node> graph,
                                         final DMNModelInstrumentedBase dmnModel); static Optional<Integer> extractIndex(final String text,
                                                 final String prefix); static int getMaxUnusedIndex(final Collection<String> values,
                                        final String prefix); }
DefaultValueUtilities { public static Optional<Integer> extractIndex(final String text, final String prefix) { if (text == null) { return Optional.empty(); } if (!text.startsWith(prefix)) { return Optional.empty(); } final String suffix = text.substring(prefix.length()); try { return Optional.of(Integer.parseInt(suffix)); } catch (NumberFormatException nfe) { return Optional.empty(); } }  static void updateNewNodeName(final Graph<?, Node> graph,
                                         final DMNModelInstrumentedBase dmnModel); static Optional<Integer> extractIndex(final String text,
                                                 final String prefix); static int getMaxUnusedIndex(final Collection<String> values,
                                        final String prefix);  }