package com.lingniu.ingest.api.event;

import java.util.Locale;

/**
 * Stable string formatting for metadata values shared across protocol mappers.
 */
public final class TelemetryMetadataValues {

    private TelemetryMetadataValues() {
    }

    public static String doubleValue(double value) {
        if (!Double.isFinite(value)) {
            return "";
        }
        String formatted = String.format(Locale.ROOT, "%.6f", value);
        return formatted.indexOf('.') < 0
                ? formatted
                : formatted.replaceAll("0+$", "").replaceAll("\\.$", "");
    }
}
