use crate::data::keyed::Keyed;

#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub(crate) struct SimulatedTargetingInfo {
    pub(crate) rule_id: u32,
    pub(crate) variation_id: u32,
}

impl SimulatedTargetingInfo {
    pub fn new(rule_id: u32, variation_id: u32) -> Self {
        Self { rule_id, variation_id }
    }
}

#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq))]
pub(crate) struct SimulatedVariation {
    targeting_info: Option<SimulatedTargetingInfo>,
    feature_key: String,
}

impl SimulatedVariation {
    pub fn new(targeting_info: Option<SimulatedTargetingInfo>, feature_key: String) -> Self {
        Self {
            targeting_info,
            feature_key,
        }
    }

    pub fn targeting_info(&self) -> Option<&SimulatedTargetingInfo> {
        self.targeting_info.as_ref()
    }

    pub fn feature_key(&self) -> &str {
        &self.feature_key
    }
}

impl Keyed<String> for SimulatedVariation {
    fn key(&self) -> &String {
        &self.feature_key
    }
}
