use crate::model::{Event, EventType, Object, ObjectType, Ocel};
use crate::validate::Violation;
#[derive(Debug, Default)]
pub struct OcelBuilder {
event_types: Vec<EventType>,
object_types: Vec<ObjectType>,
events: Vec<Event>,
objects: Vec<Object>,
}
impl OcelBuilder {
#[must_use]
pub fn new() -> Self {
Self::default()
}
pub fn add_event_type(&mut self, event_type: EventType) {
self.event_types.push(event_type);
}
pub fn add_object_type(&mut self, object_type: ObjectType) {
self.object_types.push(object_type);
}
pub fn add_event(&mut self, event: Event) {
self.events.push(event);
}
pub fn add_object(&mut self, object: Object) {
self.objects.push(object);
}
pub fn build(self) -> Result<Ocel, Vec<Violation>> {
let ocel = Ocel {
event_types: self.event_types,
object_types: self.object_types,
events: self.events,
objects: self.objects,
};
ocel.validate()?;
Ok(ocel)
}
}