private static Map<String, String> getLabelsFromAnnotation(
JsonObject env, Field serviceNameField, boolean withLabel, boolean withLabels) {
final Map<String, String> labels = new HashMap<>();
if (withLabel) {
final WithLabel wl = serviceNameField.getAnnotation(WithLabel.class);
labels.put(resolveProperty(env, wl.name()), resolveProperty(env, wl.value()));
}
if (withLabels) {
final WithLabels wls = serviceNameField.getAnnotation(WithLabels.class);
labels.putAll(
Stream.of(wls.value())
.collect(
Collectors.toMap(
wl -> resolveProperty(env, wl.name()),
wl -> resolveProperty(env, wl.value()))));
}
return labels;
}