@Override public Target withAddress(final String newAddress) { return new ImmutableMqttTarget(delegate.withAddress(newAddress), qos); }
@Override public Target withAddress(final String newAddress) { return new ImmutableMqttTarget(delegate.withAddress(newAddress), qos); }
/** * Apply {@link ThingPlaceholder}s to the passed {@code targets} with the passed {@code thingId}. * * @param targets {@link Target}s to apply placeholder substitution in. * @param thingId the thing ID. * @param unresolvedPlaceholderListener callback to call with unresolved placeholders. * @return Targets as result of placeholder substitution. */ public static Set<Target> filterTargets(final Set<Target> targets, final String thingId, final Consumer<String> unresolvedPlaceholderListener) { // check if we have to replace anything at all if (targets.stream().map(Target::getAddress).noneMatch(Placeholders::containsAnyPlaceholder)) { return targets; } return targets.stream() .map(target -> { final String filtered = applyThingPlaceholder(target.getAddress(), thingId, unresolvedPlaceholderListener); return filtered != null ? target.withAddress(filtered) : null; }) .filter(Objects::nonNull) .collect(Collectors.toSet()); }