@Test public void shouldGetAgentRollupParent() { assertThat(AgentRollupIds.getParent("aaa")).isNull(); assertThat(AgentRollupIds.getParent("aaa::")).isNull(); assertThat(AgentRollupIds.getParent("aaa::bbb")).isEqualTo("aaa::"); assertThat(AgentRollupIds.getParent("aaa::bbb::")).isEqualTo("aaa::"); assertThat(AgentRollupIds.getParent("aaa::bbb::ccc")).isEqualTo("aaa::bbb::"); assertThat(AgentRollupIds.getParent("aaa::bbb::ccc::")).isEqualTo("aaa::bbb::"); assertThat(AgentRollupIds.getParent("aaa:::")).isNull(); assertThat(AgentRollupIds.getParent("aaa:::bbb")).isEqualTo("aaa:::"); assertThat(AgentRollupIds.getParent("aaa:::bbb:::")).isEqualTo("aaa:::"); assertThat(AgentRollupIds.getParent("aaa:::bbb:::ccc")).isEqualTo("aaa:::bbb:::"); assertThat(AgentRollupIds.getParent("aaa:::bbb:::ccc:::")).isEqualTo("aaa:::bbb:::"); assertThat(AgentRollupIds.getParent("aaa::::")).isNull(); assertThat(AgentRollupIds.getParent("aaa::::bbb")).isEqualTo("aaa::::"); assertThat(AgentRollupIds.getParent("aaa::::bbb::::")).isEqualTo("aaa::::"); assertThat(AgentRollupIds.getParent("aaa::::bbb::::ccc")).isEqualTo("aaa::::bbb::::"); assertThat(AgentRollupIds.getParent("aaa::::bbb::::ccc::::")).isEqualTo("aaa::::bbb::::"); assertThat(AgentRollupIds.getParent("aaa:::::")).isEqualTo("aaa::"); assertThat(AgentRollupIds.getParent("aaa:::::bbb")).isEqualTo("aaa:::::"); assertThat(AgentRollupIds.getParent("aaa:::::bbb:::::")).isEqualTo("aaa:::::bbb::"); assertThat(AgentRollupIds.getParent("aaa:::::bbb:::::ccc")).isEqualTo("aaa:::::bbb:::::"); assertThat(AgentRollupIds.getParent("aaa:::::bbb:::::ccc:::::")) .isEqualTo("aaa:::::bbb:::::ccc::"); assertThat(AgentRollupIds.getParent(":")).isNull(); assertThat(AgentRollupIds.getParent("::")).isNull(); assertThat(AgentRollupIds.getParent(":::")).isNull(); assertThat(AgentRollupIds.getParent("::::")).isNull(); assertThat(AgentRollupIds.getParent(":::::")).isNull(); assertThat(AgentRollupIds.getParent("::::::")).isEqualTo(":::"); }
static @Nullable String getParent(String agentRollupId) { int index; if (agentRollupId.endsWith("::")) { index = agentRollupId.lastIndexOf("::", agentRollupId.length() - 5); } else { index = agentRollupId.lastIndexOf("::"); } if (index == -1 || index == 0) { return null; } return agentRollupId.substring(0, index + 2); }
AgentRollupIds { static @Nullable String getParent(String agentRollupId) { int index; if (agentRollupId.endsWith("::")) { index = agentRollupId.lastIndexOf("::", agentRollupId.length() - 5); } else { index = agentRollupId.lastIndexOf("::"); } if (index == -1 || index == 0) { return null; } return agentRollupId.substring(0, index + 2); } }
AgentRollupIds { static @Nullable String getParent(String agentRollupId) { int index; if (agentRollupId.endsWith("::")) { index = agentRollupId.lastIndexOf("::", agentRollupId.length() - 5); } else { index = agentRollupId.lastIndexOf("::"); } if (index == -1 || index == 0) { return null; } return agentRollupId.substring(0, index + 2); } private  AgentRollupIds(); }
AgentRollupIds { static @Nullable String getParent(String agentRollupId) { int index; if (agentRollupId.endsWith("::")) { index = agentRollupId.lastIndexOf("::", agentRollupId.length() - 5); } else { index = agentRollupId.lastIndexOf("::"); } if (index == -1 || index == 0) { return null; } return agentRollupId.substring(0, index + 2); } private  AgentRollupIds(); static List<String> getAgentRollupIds(String agentRollupId); }
AgentRollupIds { static @Nullable String getParent(String agentRollupId) { int index; if (agentRollupId.endsWith("::")) { index = agentRollupId.lastIndexOf("::", agentRollupId.length() - 5); } else { index = agentRollupId.lastIndexOf("::"); } if (index == -1 || index == 0) { return null; } return agentRollupId.substring(0, index + 2); } private  AgentRollupIds(); static List<String> getAgentRollupIds(String agentRollupId);  }