class ImmutableAddressMetric implements AddressMetric {

    public static AddressMetric fromJson(final JsonObject jsonObject) {
        final Set<Measurement> readMeasurements = new HashSet<>();
        jsonObject.stream()
                .filter(field -> field.getValue().isObject())
                .forEach(f -> Stream.of(SUCCESS_KEY, FAILURE_KEY)
                        .map(key -> JsonFactory.newPointer(JsonFactory.newKey(f.getKeyName()), key))
                        .map(jsonObject::get)
                        .filter(JsonValue::isObject)
                        .filter(o -> !o.isEmpty())
                        .map(JsonValue::asObject)
                        .map(ImmutableMeasurement::fromJson)
                        .forEach(readMeasurements::add));
        return ImmutableAddressMetric.of(readMeasurements);
    }

    private  ImmutableAddressMetric(final Set<Measurement> measurements);

}