TopicName { public static TopicName fromQualifiedName(String qualifiedName) { if (Strings.isNullOrEmpty(qualifiedName)) { return null; } int index = qualifiedName.lastIndexOf(GROUP_SEPARATOR); if (index == -1) { throw new IllegalArgumentException("Missing group"); } String groupName = qualifiedName.substring(0, index); String topicName = qualifiedName.substring(index + 1, qualifiedName.length()); return new TopicName(groupName, topicName); } @JsonCreator  TopicName(@JsonProperty("groupName") String groupName, @JsonProperty("name") String name); String getGroupName(); String getName(); String qualifiedName(); static String toQualifiedName(TopicName topicName); static TopicName fromQualifiedName(String qualifiedName); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final char GROUP_SEPARATOR; }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenInvalidQualifiedNameProvided() { TopicName.fromQualifiedName("invalidQualifiedName"); }
@Test public void shouldBeNullSafe() { assertThat(TopicName.fromQualifiedName(null)).isNull(); }