@Test public void testFindSecondTextToken(){ CliToken textCliToken = new CliTokenImpl(true,"textCliToken"); CliToken nonTextCliToken = new CliTokenImpl(false,"nonTextCliToken"); Assert.assertEquals(null, TokenUtils.findSecondTokenText(null)); Assert.assertEquals(null, TokenUtils.findSecondTokenText(new ArrayList<CliToken>())); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{null}))); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{null, textCliToken}))); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{null, nonTextCliToken, textCliToken}))); Assert.assertEquals(textCliToken.value(), TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{null, nonTextCliToken, textCliToken, textCliToken}))); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{textCliToken}))); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{nonTextCliToken}))); Assert.assertEquals(null, TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{nonTextCliToken, textCliToken}))); Assert.assertEquals(textCliToken.value(), TokenUtils.findSecondTokenText(newCliTokenList(new CliToken[]{textCliToken, nonTextCliToken, textCliToken}))); }
public static String findSecondTokenText(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } boolean first = true; for (CliToken token : tokens) { if (token != null && token.isText()) { if (first) { first = false; } else { return token.value(); } } } return null; }
TokenUtils { public static String findSecondTokenText(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } boolean first = true; for (CliToken token : tokens) { if (token != null && token.isText()) { if (first) { first = false; } else { return token.value(); } } } return null; } }
TokenUtils { public static String findSecondTokenText(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } boolean first = true; for (CliToken token : tokens) { if (token != null && token.isText()) { if (first) { first = false; } else { return token.value(); } } } return null; }  }
TokenUtils { public static String findSecondTokenText(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } boolean first = true; for (CliToken token : tokens) { if (token != null && token.isText()) { if (first) { first = false; } else { return token.value(); } } } return null; }  static CliToken findFirstTextToken(List<CliToken> tokens); static CliToken findLastTextToken(List<CliToken> tokens); static String findSecondTokenText(List<CliToken> tokens); static CliToken getLast(List<CliToken> tokens); static String retrievePreviousArg(List<CliToken> tokens, String lastToken); }
TokenUtils { public static String findSecondTokenText(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } boolean first = true; for (CliToken token : tokens) { if (token != null && token.isText()) { if (first) { first = false; } else { return token.value(); } } } return null; }  static CliToken findFirstTextToken(List<CliToken> tokens); static CliToken findLastTextToken(List<CliToken> tokens); static String findSecondTokenText(List<CliToken> tokens); static CliToken getLast(List<CliToken> tokens); static String retrievePreviousArg(List<CliToken> tokens, String lastToken);  }