// -*- mode: kotlin -*-

/*
 * AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT.
 */
{# The rendered markdown is autogenerated, but this
Jinja2 template is not. Please file bugs! #}

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

@file:Suppress("PackageNaming", "MaxLineLength")
package {{ namespace }}

import {{ glean_namespace }}.private.BooleanMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.CounterMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.HistogramMetricBase // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.LabeledMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.QuantityMetricType // ktlint-disable import-ordering no-unused-imports
import {{ glean_namespace }}.private.StringMetricType // ktlint-disable import-ordering no-unused-imports

/*
 * This class performs the mapping between Gecko metrics and Glean SDK
 * metric types.
 */
internal object GleanGeckoMetricsMapping {
    // Support exfiltration of Gecko histograms from products using both the
    // Glean SDK and GeckoView. See bug 1566356 for more context.
    @Suppress("UNUSED_PARAMETER")
    fun getHistogram(geckoMetricName: String): HistogramMetricBase? {
    {% if 'histograms' in gecko_metrics %}
        return when (geckoMetricName) {
        {% for category in gecko_metrics['histograms'].keys()|sort %}
            // From {{ category|Camelize }}.kt
            {% for metric in gecko_metrics['histograms'][category] %}
            "{{ metric.gecko_datapoint }}" -> {{ category|Camelize }}.{{ metric.name|camelize }}
            {% endfor %}
        {%- endfor %}
            else -> null
        }
    {% else %}
        return null
    {% endif %}
    }

    // Support exfiltration of Gecko categorical histograms from products using
    // both the Glean SDK and GeckoView. See bug 1571740 for more context.
    @Suppress("UNUSED_PARAMETER")
    fun getCategoricalMetric(
        geckoMetricName: String
    ): LabeledMetricType<CounterMetricType>? {
    {% if 'categoricals' in gecko_metrics %}
        return when (geckoMetricName) {
        {% for category in gecko_metrics['categoricals'].keys()|sort %}
            // From {{ category|Camelize }}.kt
            {% for metric in gecko_metrics['categoricals'][category] %}
            "{{ metric.gecko_datapoint }}" -> {{ category|Camelize }}.{{ metric.name|camelize }}
            {% endfor %}
        {%- endfor %}
            else -> null
        }
    {% else %}
        return null
    {% endif %}
    }

    // Support exfiltration of Gecko boolean scalars from products using both the
    // Glean SDK and GeckoView. See bug 1579365 for more context.
    @Suppress("UNUSED_PARAMETER")
    fun getBooleanScalar(geckoMetricName: String): BooleanMetricType? {
    {% if 'boolean' in gecko_metrics %}
        return when (geckoMetricName) {
        {% for category in gecko_metrics['boolean'].keys()|sort %}
            // From {{ category|Camelize }}.kt
            {% for metric in gecko_metrics['boolean'][category] %}
            "{{ metric.gecko_datapoint }}" -> {{ category|Camelize }}.{{ metric.name|camelize }}
            {% endfor %}
        {%- endfor %}
            else -> null
        }
    {% else %}
        return null
    {% endif %}
    }

    // Support exfiltration of Gecko string scalars from products using both the
    // Glean SDK and GeckoView. See bug 1579365 for more context.
    @Suppress("UNUSED_PARAMETER")
    fun getStringScalar(geckoMetricName: String): StringMetricType? {
    {% if 'string' in gecko_metrics %}
        return when (geckoMetricName) {
        {% for category in gecko_metrics['string'].keys()|sort %}
            // From {{ category|Camelize }}.kt
            {% for metric in gecko_metrics['string'][category] %}
            "{{ metric.gecko_datapoint }}" -> {{ category|Camelize }}.{{ metric.name|camelize }}
            {% endfor %}
        {%- endfor %}
            else -> null
        }
    {% else %}
        return null
    {% endif %}
    }

    // Support exfiltration of Gecko quantity scalars from products using both the
    // Glean SDK and GeckoView. See bug 1579365 for more context.
    @Suppress("UNUSED_PARAMETER")
    fun getQuantityScalar(geckoMetricName: String): QuantityMetricType? {
    {% if 'quantity' in gecko_metrics %}
        return when (geckoMetricName) {
        {% for category in gecko_metrics['quantity'].keys()|sort %}
            // From {{ category|Camelize }}.kt
            {% for metric in gecko_metrics['quantity'][category] %}
            "{{ metric.gecko_datapoint }}" -> {{ category|Camelize }}.{{ metric.name|camelize }}
            {% endfor %}
        {%- endfor %}
            else -> null
        }
    {% else %}
        return null
    {% endif %}
    }
}
