/** * Creates a new {@code ImmutableSourceMetrics} instance. * * @param addressMetrics the AddressMetrics for each source * @param consumedMessages the total count of consumed messages on this source * @return a new instance of ImmutableSourceMetrics */ public static ImmutableSourceMetrics of(final Map<String, AddressMetric> addressMetrics, final long consumedMessages) { return new ImmutableSourceMetrics(addressMetrics, consumedMessages); }
/** * Creates a new {@code SourceMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the Connection to be created. * @return a new SourceMetrics 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 SourceMetrics sourceMetricsFromJson(final JsonObject jsonObject) { return ImmutableSourceMetrics.fromJson(jsonObject); }
/** * Returns a new {@code SourceMetrics}. * * @param addressMetrics the AddressMetrics of all addresses in the source * @param consumedMessages the amount of consumed 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 SourceMetrics newSourceMetrics(final Map<String, AddressMetric> addressMetrics, final long consumedMessages) { return ImmutableSourceMetrics.of(addressMetrics, consumedMessages); }
/** * Returns a new {@code SourceMetrics}. * * @param addressMetrics the AddressMetrics of all addresses in the source * @param consumedMessages the amount of consumed 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 SourceMetrics newSourceMetrics(final Map<String, AddressMetric> addressMetrics, final long consumedMessages) { return ImmutableSourceMetrics.of(addressMetrics, consumedMessages); }
/** * Creates a new {@code SourceMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the Connection to be created. * @return a new SourceMetrics 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 SourceMetrics sourceMetricsFromJson(final JsonObject jsonObject) { return ImmutableSourceMetrics.fromJson(jsonObject); }
/** * Creates a new {@code ImmutableSourceMetrics} instance. * * @param addressMetrics the AddressMetrics for each source * @param consumedMessages the total count of consumed messages on this source * @return a new instance of ImmutableSourceMetrics */ public static ImmutableSourceMetrics of(final Map<String, AddressMetric> addressMetrics, final long consumedMessages) { return new ImmutableSourceMetrics(addressMetrics, consumedMessages); }
/** * Creates a new {@code SourceMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the SourceMetrics to be created. * @return a new SourceMetrics 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 SourceMetrics 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 readConsumedMessages = jsonObject.getValueOrThrow(JsonFields.CONSUMED_MESSAGES); return ImmutableSourceMetrics.of(readAddressMetrics, readConsumedMessages); }
/** * Creates a new {@code SourceMetrics} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the SourceMetrics to be created. * @return a new SourceMetrics 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 SourceMetrics 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 readConsumedMessages = jsonObject.getValueOrThrow(JsonFields.CONSUMED_MESSAGES); return ImmutableSourceMetrics.of(readAddressMetrics, readConsumedMessages); }