use super::leg::Leg;
use crate::cashflows::cashflow::Cashflow;
pub struct Swap {
cashflows: Vec<Cashflow>,
legs: Vec<Leg>,
id: Option<String>,
}
impl Swap {
#[allow(clippy::missing_const_for_fn)]
#[must_use]
pub fn new(cashflows: Vec<Cashflow>, legs: Vec<Leg>, id: Option<String>) -> Self {
Self {
cashflows,
legs,
id,
}
}
pub fn add_leg(&mut self, leg: Leg) {
self.cashflows.extend(leg.cashflows().iter().copied());
self.legs.push(leg);
}
#[must_use]
pub const fn legs(&self) -> &Vec<Leg> {
&self.legs
}
#[must_use]
pub const fn cashflows(&self) -> &Vec<Cashflow> {
&self.cashflows
}
#[must_use]
pub const fn id(&self) -> &Option<String> {
&self.id
}
pub fn set_id(&mut self, id: String) {
self.id = Some(id);
}
}