@Override public MqttSource build() { if (delegate == null) { delegate = delegateBuilder.build(); } return new ImmutableMqttSource(delegate, qos); } }
@Test public void fromJsonReturnsExpected() { final Source actual = ImmutableMqttSource.fromJson(SOURCE_JSON, 0); assertThat(actual).isEqualTo(MQTT_SOURCE); }
/** * Creates a new {@code Source} object from the specified JSON object. Decides which specific {@link Source} * implementation to choose depending on the given {@link ConnectionType}. * * @param jsonObject a JSON object which provides the data for the Source to be created. * @param index the index to distinguish between sources that would otherwise be different * @param type the connection type required to decide which iplementation of {@link Source} to choose * @return a new Source which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object. */ public static Source sourceFromJson(final JsonObject jsonObject, final int index, final ConnectionType type) { switch (type) { case AMQP_091: case AMQP_10: return ImmutableSource.fromJson(jsonObject, index); case MQTT: return ImmutableMqttSource.fromJson(jsonObject, index); default: throw ConnectionConfigurationInvalidException .newBuilder("Unexpected connection type <" + type + ">") .build(); } }
/** * Creates a new {@code Source} object from the specified JSON object. Decides which specific {@link Source} * implementation to choose depending on the given {@link ConnectionType}. * * @param jsonObject a JSON object which provides the data for the Source to be created. * @param index the index to distinguish between sources that would otherwise be different * @param type the connection type required to decide which iplementation of {@link Source} to choose * @return a new Source which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object. */ public static Source sourceFromJson(final JsonObject jsonObject, final int index, final ConnectionType type) { switch (type) { case AMQP_091: case AMQP_10: return ImmutableSource.fromJson(jsonObject, index); case MQTT: return ImmutableMqttSource.fromJson(jsonObject, index); default: throw ConnectionConfigurationInvalidException .newBuilder("Unexpected connection type <" + type + ">") .build(); } }
@Override public MqttSource build() { if (delegate == null) { delegate = delegateBuilder.build(); } return new ImmutableMqttSource(delegate, qos); } }