@Test public void testFindLastTextToken(){ CliToken textCliToken = new CliTokenImpl(true,"textCliToken"); CliToken nonTextCliToken = new CliTokenImpl(false,"nonTextCliToken"); Assert.assertEquals(null, TokenUtils.findLastTextToken(null)); Assert.assertEquals(null, TokenUtils.findLastTextToken(new ArrayList<CliToken>())); Assert.assertEquals(null, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{null}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{null, textCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{null, nonTextCliToken, textCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{nonTextCliToken, null, textCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{textCliToken, null, nonTextCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{textCliToken}))); Assert.assertEquals(null, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{nonTextCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{nonTextCliToken, textCliToken}))); Assert.assertEquals(textCliToken, TokenUtils.findLastTextToken(newCliTokenList(new CliToken[]{textCliToken, nonTextCliToken}))); }
public static CliToken findLastTextToken(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } for (int i = tokens.size() - 1; i >= 0; i--) { CliToken token = tokens.get(i); if (token != null && token.isText()) { return token; } } return null; }
TokenUtils { public static CliToken findLastTextToken(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } for (int i = tokens.size() - 1; i >= 0; i--) { CliToken token = tokens.get(i); if (token != null && token.isText()) { return token; } } return null; } }
TokenUtils { public static CliToken findLastTextToken(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } for (int i = tokens.size() - 1; i >= 0; i--) { CliToken token = tokens.get(i); if (token != null && token.isText()) { return token; } } return null; }  }
TokenUtils { public static CliToken findLastTextToken(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } for (int i = tokens.size() - 1; i >= 0; i--) { CliToken token = tokens.get(i); if (token != null && token.isText()) { return token; } } 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 CliToken findLastTextToken(List<CliToken> tokens) { if (tokens == null || tokens.isEmpty()) { return null; } for (int i = tokens.size() - 1; i >= 0; i--) { CliToken token = tokens.get(i); if (token != null && token.isText()) { return token; } } 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);  }