@Test public void shouldGetAgentRollupIdsFromRollup() { assertThat(AgentRollupIds.getAgentRollupIds("aaa::")).containsExactly("aaa::"); assertThat(AgentRollupIds.getAgentRollupIds("aaa::bbb::")).containsExactly("aaa::bbb::", "aaa::"); assertThat(AgentRollupIds.getAgentRollupIds("aaa::bbb::ccc::")) .containsExactly("aaa::bbb::ccc::", "aaa::bbb::", "aaa::"); assertThat(AgentRollupIds.getAgentRollupIds("a::")).containsExactly("a::"); assertThat(AgentRollupIds.getAgentRollupIds("a::b::")).containsExactly("a::b::", "a::"); assertThat(AgentRollupIds.getAgentRollupIds("a::b::c::")).containsExactly("a::b::c::", "a::b::", "a::"); assertThat(AgentRollupIds.getAgentRollupIds("a:b:c::")).containsExactly("a:b:c::"); assertThat(AgentRollupIds.getAgentRollupIds("a:::b:::")).containsExactly("a:::b:::", "a:::"); assertThat(AgentRollupIds.getAgentRollupIds("a:::b:::c:::")).containsExactly("a:::b:::c:::", "a:::b:::", "a:::"); assertThat(AgentRollupIds.getAgentRollupIds("a::::b::::")).containsExactly("a::::b::::", "a::::"); assertThat(AgentRollupIds.getAgentRollupIds("a::::b::::c::::")).containsExactly( "a::::b::::c::::", "a::::b::::", "a::::"); assertThat(AgentRollupIds.getAgentRollupIds("a:::::b:::::")).containsExactly("a:::::b:::::", "a:::::b::", "a:::::", "a::"); assertThat(AgentRollupIds.getAgentRollupIds("a:::::b:::::c:::::")).containsExactly( "a:::::b:::::c:::::", "a:::::b:::::c::", "a:::::b:::::", "a:::::b::", "a:::::", "a::"); }
public static List<String> getAgentRollupIds(String agentRollupId) { List<String> agentRollupIds = new ArrayList<>(); agentRollupIds.add(agentRollupId); int separatorLen = "::".length(); int lastFoundIndex; if (agentRollupId.endsWith("::")) { lastFoundIndex = agentRollupId.length() - separatorLen; } else { lastFoundIndex = agentRollupId.length(); } int nextFoundIndex; while ((nextFoundIndex = agentRollupId.lastIndexOf("::", lastFoundIndex - separatorLen - 1)) != -1) { if (nextFoundIndex == 0) { break; } agentRollupIds.add(agentRollupId.substring(0, nextFoundIndex + separatorLen)); lastFoundIndex = nextFoundIndex; } return agentRollupIds; }
AgentRollupIds { public static List<String> getAgentRollupIds(String agentRollupId) { List<String> agentRollupIds = new ArrayList<>(); agentRollupIds.add(agentRollupId); int separatorLen = "::".length(); int lastFoundIndex; if (agentRollupId.endsWith("::")) { lastFoundIndex = agentRollupId.length() - separatorLen; } else { lastFoundIndex = agentRollupId.length(); } int nextFoundIndex; while ((nextFoundIndex = agentRollupId.lastIndexOf("::", lastFoundIndex - separatorLen - 1)) != -1) { if (nextFoundIndex == 0) { break; } agentRollupIds.add(agentRollupId.substring(0, nextFoundIndex + separatorLen)); lastFoundIndex = nextFoundIndex; } return agentRollupIds; } }
AgentRollupIds { public static List<String> getAgentRollupIds(String agentRollupId) { List<String> agentRollupIds = new ArrayList<>(); agentRollupIds.add(agentRollupId); int separatorLen = "::".length(); int lastFoundIndex; if (agentRollupId.endsWith("::")) { lastFoundIndex = agentRollupId.length() - separatorLen; } else { lastFoundIndex = agentRollupId.length(); } int nextFoundIndex; while ((nextFoundIndex = agentRollupId.lastIndexOf("::", lastFoundIndex - separatorLen - 1)) != -1) { if (nextFoundIndex == 0) { break; } agentRollupIds.add(agentRollupId.substring(0, nextFoundIndex + separatorLen)); lastFoundIndex = nextFoundIndex; } return agentRollupIds; } private  AgentRollupIds(); }
AgentRollupIds { public static List<String> getAgentRollupIds(String agentRollupId) { List<String> agentRollupIds = new ArrayList<>(); agentRollupIds.add(agentRollupId); int separatorLen = "::".length(); int lastFoundIndex; if (agentRollupId.endsWith("::")) { lastFoundIndex = agentRollupId.length() - separatorLen; } else { lastFoundIndex = agentRollupId.length(); } int nextFoundIndex; while ((nextFoundIndex = agentRollupId.lastIndexOf("::", lastFoundIndex - separatorLen - 1)) != -1) { if (nextFoundIndex == 0) { break; } agentRollupIds.add(agentRollupId.substring(0, nextFoundIndex + separatorLen)); lastFoundIndex = nextFoundIndex; } return agentRollupIds; } private  AgentRollupIds(); static List<String> getAgentRollupIds(String agentRollupId); }
AgentRollupIds { public static List<String> getAgentRollupIds(String agentRollupId) { List<String> agentRollupIds = new ArrayList<>(); agentRollupIds.add(agentRollupId); int separatorLen = "::".length(); int lastFoundIndex; if (agentRollupId.endsWith("::")) { lastFoundIndex = agentRollupId.length() - separatorLen; } else { lastFoundIndex = agentRollupId.length(); } int nextFoundIndex; while ((nextFoundIndex = agentRollupId.lastIndexOf("::", lastFoundIndex - separatorLen - 1)) != -1) { if (nextFoundIndex == 0) { break; } agentRollupIds.add(agentRollupId.substring(0, nextFoundIndex + separatorLen)); lastFoundIndex = nextFoundIndex; } return agentRollupIds; } private  AgentRollupIds(); static List<String> getAgentRollupIds(String agentRollupId);  }