use super::{FeatureRelationship, RelationshipType};
impl<T> FeatureRelationship<T> {
pub const fn new(
source_id: usize,
to_id: usize,
relationship_type: RelationshipType,
strength: T,
) -> Self {
Self {
source_id,
to_id,
relationship_type,
strength,
occurrences: 1,
}
}
pub const fn from_id(&self) -> usize {
self.source_id
}
pub const fn from_id_mut(&mut self) -> &mut usize {
&mut self.source_id
}
pub const fn to_id(&self) -> usize {
self.to_id
}
pub const fn to_id_mut(&mut self) -> &mut usize {
&mut self.to_id
}
pub const fn occurrences(&self) -> usize {
self.occurrences
}
pub const fn occurrences_mut(&mut self) -> &mut usize {
&mut self.occurrences
}
pub const fn relationship_type(&self) -> &RelationshipType {
&self.relationship_type
}
pub const fn relationship_type_mut(&mut self) -> &mut RelationshipType {
&mut self.relationship_type
}
pub const fn strength(&self) -> &T {
&self.strength
}
pub const fn strength_mut(&mut self) -> &mut T {
&mut self.strength
}
pub fn set_from_id(&mut self, from_id: usize) -> &mut Self {
self.source_id = from_id;
self
}
pub fn set_to_id(&mut self, to_id: usize) -> &mut Self {
self.to_id = to_id;
self
}
pub fn set_occurrences(&mut self, occurrences: usize) -> &mut Self {
self.occurrences = occurrences;
self
}
pub fn set_relationship_type(&mut self, relationship_type: RelationshipType) -> &mut Self {
self.relationship_type = relationship_type;
self
}
pub fn set_strength(&mut self, strength: T) -> &mut Self {
self.strength = strength;
self
}
pub fn increment_occurrences(&mut self) -> &mut Self {
self.occurrences += 1;
self
}
pub fn with_from_id(self, source_id: usize) -> Self {
Self { source_id, ..self }
}
pub fn with_to_id(self, to_id: usize) -> Self {
Self { to_id, ..self }
}
pub fn with_occurrences(self, occurrences: usize) -> Self {
Self {
occurrences,
..self
}
}
pub fn with_relationship_type(self, relationship_type: RelationshipType) -> Self {
Self {
relationship_type,
..self
}
}
pub fn with_strength(self, strength: T) -> Self {
Self { strength, ..self }
}
}