/** * Get the message type for a received message. * * @param message byte array representing the message. * @return type of the message. */ public static MessageType getMessageType(byte[] message) { for (MessageType type : MessageType.values()) { if (isType(message, type)) { return type; } } throw new UnsupportedOperationException("could not find type for message m" + message + " v" + new String(message, StandardCharsets.UTF_8)); }