public static ElkMessage deserialize(String message) { Matcher matcher = PATTERN_.matcher(message); if (matcher.find()) { // the first group is the type, the second is the body. this should // hold no matter which pattern we use. String type = matcher.group(1); String body = matcher.group(2); return new ElkMessage(body, type); } return null; }