@Test public void testSequenceLength() { VariableNameGenerator gen = new VariableNameGenerator(); int count = 0; while (gen.get().isPresent()) count++; assertEquals(VariableNameGenerator.LENGTH, count); }
@Override public Optional<String> get() { try { if (n >= 0 && n < LENGTH) { return Optional.of(String.format("%s%s", CHAR1.charAt(n % CHAR1.length()), CHAR2.charAt(n / CHAR1.length()) ).trim()); } return Optional.empty(); } finally { n += 1; } }
VariableNameGenerator implements Supplier<Optional<String>> { @Override public Optional<String> get() { try { if (n >= 0 && n < LENGTH) { return Optional.of(String.format("%s%s", CHAR1.charAt(n % CHAR1.length()), CHAR2.charAt(n / CHAR1.length()) ).trim()); } return Optional.empty(); } finally { n += 1; } } }
VariableNameGenerator implements Supplier<Optional<String>> { @Override public Optional<String> get() { try { if (n >= 0 && n < LENGTH) { return Optional.of(String.format("%s%s", CHAR1.charAt(n % CHAR1.length()), CHAR2.charAt(n / CHAR1.length()) ).trim()); } return Optional.empty(); } finally { n += 1; } }  }
VariableNameGenerator implements Supplier<Optional<String>> { @Override public Optional<String> get() { try { if (n >= 0 && n < LENGTH) { return Optional.of(String.format("%s%s", CHAR1.charAt(n % CHAR1.length()), CHAR2.charAt(n / CHAR1.length()) ).trim()); } return Optional.empty(); } finally { n += 1; } }  @Override Optional<String> get(); }
VariableNameGenerator implements Supplier<Optional<String>> { @Override public Optional<String> get() { try { if (n >= 0 && n < LENGTH) { return Optional.of(String.format("%s%s", CHAR1.charAt(n % CHAR1.length()), CHAR2.charAt(n / CHAR1.length()) ).trim()); } return Optional.empty(); } finally { n += 1; } }  @Override Optional<String> get(); static final String CHAR1; static final String CHAR2; static final int LENGTH; }