@Override public TopicPath getTopicPath() { return delegateAdaptable.getTopicPath(); }
/** * Returns a new {@code AdaptableBuilder} for the existing {@code existingAdaptable}. * * @param existingAdaptable the existingAdaptable to initialize the AdaptableBuilder with. * @return the builder. */ public static AdaptableBuilder newAdaptableBuilder(final Adaptable existingAdaptable) { return newAdaptableBuilder(existingAdaptable, existingAdaptable.getTopicPath()); }
/** * Returns a new {@code AdaptableBuilder} for the existing {@code existingAdaptable}. * * @param existingAdaptable the existingAdaptable to initialize the AdaptableBuilder with. * @return the builder. */ public static AdaptableBuilder newAdaptableBuilder(final Adaptable existingAdaptable) { return newAdaptableBuilder(existingAdaptable, existingAdaptable.getTopicPath()); }
protected static String thingIdFrom(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); return topicPath.getNamespace() + ":" + topicPath.getId(); }
@Override protected String getType(final Adaptable adaptable) { if (adaptable.getTopicPath().getSubject().filter(KnownMessageSubjects.CLAIM_SUBJECT::equals).isPresent()) { return SendClaimMessageResponse.TYPE; } else if (!adaptable.getHeaders().map(DittoHeaders::isResponseRequired).orElse(true)) { return SendMessageAcceptedResponse.TYPE; } else if (adaptable.getPayload().getPath().getFeatureId().isPresent()) { return SendFeatureMessageResponse.TYPE; } else { return SendThingMessageResponse.TYPE; } }
@Override protected String getType(final Adaptable adaptable) { if (adaptable.getTopicPath().getSubject().filter(KnownMessageSubjects.CLAIM_SUBJECT::equals).isPresent()) { return SendClaimMessageResponse.TYPE; } else if (!adaptable.getHeaders().map(DittoHeaders::isResponseRequired).orElse(true)) { return SendMessageAcceptedResponse.TYPE; } else if (adaptable.getPayload().getPath().getFeatureId().isPresent()) { return SendFeatureMessageResponse.TYPE; } else { return SendThingMessageResponse.TYPE; } }
@Override protected String getType(final Adaptable adaptable) { if (adaptable.getTopicPath().getSubject().filter(KnownMessageSubjects.CLAIM_SUBJECT::equals).isPresent()) { return SendClaimMessage.TYPE; } else if (adaptable.getPayload().getPath().getFeatureId().isPresent()) { return SendFeatureMessage.TYPE; } else { return SendThingMessage.TYPE; } }
private Signal<?> fromTwinAdaptable(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final Signal<?> signal = signalFromAdaptable(adaptable, topicPath); // /things/twin/(commands|events) if (signal != null) { return signal; } else { throw UnknownTopicPathException.newBuilder(topicPath).build(); } }
private Signal<?> fromTwinAdaptable(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final Signal<?> signal = signalFromAdaptable(adaptable, topicPath); // /things/twin/(commands|events) if (signal != null) { return signal; } else { throw UnknownTopicPathException.newBuilder(topicPath).build(); } }
@Override public Optional<ExternalMessage> apply(final Adaptable adaptable) { final JsonifiableAdaptable jsonifiableAdaptable = ProtocolFactory.wrapAsJsonifiableAdaptable(adaptable); final ExternalMessageBuilder messageBuilder = ExternalMessageFactory.newExternalMessageBuilder( adaptable.getHeaders().orElseGet(adaptable::getDittoHeaders)) .withTopicPath(adaptable.getTopicPath()); messageBuilder.withAdditionalHeaders(ExternalMessage.CONTENT_TYPE_HEADER, DittoConstants.DITTO_PROTOCOL_CONTENT_TYPE); messageBuilder.withText(jsonifiableAdaptable.toJsonString()); return Optional.of(messageBuilder.build()); }
@Override public Optional<ExternalMessage> apply(final Adaptable adaptable) { final JsonifiableAdaptable jsonifiableAdaptable = ProtocolFactory.wrapAsJsonifiableAdaptable(adaptable); final ExternalMessageBuilder messageBuilder = ExternalMessageFactory.newExternalMessageBuilder( adaptable.getHeaders().orElseGet(adaptable::getDittoHeaders)) .withTopicPath(adaptable.getTopicPath()); messageBuilder.withAdditionalHeaders(ExternalMessage.CONTENT_TYPE_HEADER, DittoConstants.DITTO_PROTOCOL_CONTENT_TYPE); messageBuilder.withText(jsonifiableAdaptable.toJsonString()); return Optional.of(messageBuilder.build()); }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final JsonPointer path = adaptable.getPayload().getPath(); final String eventName = PathMatcher.match(path) + getActionNameWithFirstLetterUpperCase(topicPath); return topicPath.getGroup() + "." + topicPath.getCriterion() + ":" + eventName; }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + ".responses:" + commandName; }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final JsonPointer path = adaptable.getPayload().getPath(); final String eventName = PathMatcher.match(path) + getActionNameWithFirstLetterUpperCase(topicPath); return topicPath.getGroup() + "." + topicPath.getCriterion() + ":" + eventName; }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + "." + topicPath.getCriterion() + ":" + commandName; }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); if (topicPath.isWildcardTopic()) { return RetrieveThingsResponse.TYPE; } else { final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + ".responses:" + commandName; } }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); if (topicPath.isWildcardTopic()) { return RetrieveThingsResponse.TYPE; } else { final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + ".responses:" + commandName; } }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); if (topicPath.isWildcardTopic()) { return RetrieveThings.TYPE; } else { final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + "." + topicPath.getCriterion() + ":" + commandName; } }
@Override protected String getType(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); if (topicPath.isWildcardTopic()) { return RetrieveThings.TYPE; } else { final JsonPointer path = adaptable.getPayload().getPath(); final String commandName = getAction(topicPath) + upperCaseFirst(PathMatcher.match(path)); return topicPath.getGroup() + "." + topicPath.getCriterion() + ":" + commandName; } }
@Override public Signal<?> fromAdaptable(final Adaptable adaptable) { final TopicPath topicPath = adaptable.getTopicPath(); if (TopicPath.Group.THINGS.equals(topicPath.getGroup())) { // /things final TopicPath.Channel channel = topicPath.getChannel(); if (channel.equals(TopicPath.Channel.LIVE)) { // /things/live return fromLiveAdaptable(adaptable); } else if (channel.equals(TopicPath.Channel.TWIN)) { // /things/twin return fromTwinAdaptable(adaptable); } } throw UnknownTopicPathException.newBuilder(topicPath).build(); }