/** * Creates a command subscription object for the given topic. When the authenticated device is given * it is used to either check given tenant and device-id from topic or fill this * fields if not given. * * @param topic The topic to subscribe for commands. * @param authenticatedDevice The authenticated device or {@code null}. * @return The CommandSubscription object or {@code null} if the topic does not match the rules. * @throws NullPointerException if topic is {@code null}. */ public static CommandSubscription fromTopic(final String topic, final Device authenticatedDevice) { try { return new CommandSubscription(topic, authenticatedDevice); } catch (final IllegalArgumentException e) { LOG.debug(e.getMessage()); return null; } }