class Topic {

    public static void validate(String topic) {
        if (topic.isEmpty())
            throw new InvalidTopicException("Topic name is illegal, it can't be empty");
        if (topic.equals(".") || topic.equals(".."))
            throw new InvalidTopicException("Topic name cannot be \".\" or \"..\"");
        if (topic.length() > MAX_NAME_LENGTH)
            throw new InvalidTopicException("Topic name is illegal, it can't be longer than " + MAX_NAME_LENGTH +
                    " characters, topic name: " + topic);
        if (!containsValidPattern(topic))
            throw new InvalidTopicException("Topic name \"" + topic + "\" is illegal, it contains a character other than " +
                    "ASCII alphanumerics, '.', '_' and '-'");
    }

}