/** * Returns a new {@code TargetMetrics}. * * @param addressMetrics the AddressMetrics of all addresses in the target * @param publishedMessages the amount of published messages * @return a new SourceMetrics which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code connectionStatus} is {@code null}. */ public static TargetMetrics newTargetMetrics(final Map<String, AddressMetric> addressMetrics, final long publishedMessages) { return ImmutableTargetMetrics.of(addressMetrics, publishedMessages); }
/** * Returns a new {@code TargetMetrics}. * * @param addressMetrics the AddressMetrics of all addresses in the target * @param publishedMessages the amount of published messages * @return a new SourceMetrics which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code connectionStatus} is {@code null}. */ public static TargetMetrics newTargetMetrics(final Map<String, AddressMetric> addressMetrics, final long publishedMessages) { return ImmutableTargetMetrics.of(addressMetrics, publishedMessages); }
/** * Creates a new {@code TargetMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the TargetMetrics to be created. * @return a new TargetMetrics 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 TargetMetrics fromJson(final JsonObject jsonObject) { final Map<String, AddressMetric> readAddressMetrics = jsonObject.getValue(JsonFields.ADDRESS_METRICS) .map(obj -> obj.stream() .collect(Collectors.toMap( f -> f.getKey().toString(), f -> ConnectivityModelFactory.addressMetricFromJson(f.getValue().asObject())))) .orElse(Collections.emptyMap()); final long readPublishedMessages = jsonObject.getValueOrThrow(JsonFields.PUBLISHED_MESSAGES); return ImmutableTargetMetrics.of(readAddressMetrics, readPublishedMessages); }
/** * Creates a new {@code TargetMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the TargetMetrics to be created. * @return a new TargetMetrics 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 TargetMetrics fromJson(final JsonObject jsonObject) { final Map<String, AddressMetric> readAddressMetrics = jsonObject.getValue(JsonFields.ADDRESS_METRICS) .map(obj -> obj.stream() .collect(Collectors.toMap( f -> f.getKey().toString(), f -> ConnectivityModelFactory.addressMetricFromJson(f.getValue().asObject())))) .orElse(Collections.emptyMap()); final long readPublishedMessages = jsonObject.getValueOrThrow(JsonFields.PUBLISHED_MESSAGES); return ImmutableTargetMetrics.of(readAddressMetrics, readPublishedMessages); }