use crate::field_type::FieldType;
#[derive(Clone, Debug)]
pub struct Field {
name: String,
index: usize,
field_type: FieldType,
ignore_blanks: bool,
ignore_case: bool,
random: bool,
}
impl Field {
pub fn new(
index: usize,
field_type: FieldType,
) -> Field {
Field {
name: String::new(),
index,
field_type,
ignore_blanks: false,
ignore_case: false,
random: false,
}
}
pub fn name(&self) -> &String {
&self.name
}
pub fn index(&self) -> usize {
self.index
}
pub fn field_type(&self) -> &FieldType {
&self.field_type
}
pub fn ignore_blanks(&self) -> bool {
self.ignore_blanks
}
pub fn ignore_case(&self) -> bool {
self.ignore_case
}
pub fn random(&self) -> bool {
self.random
}
pub fn with_name(mut self, name: String) -> Field {
self.name = name;
self
}
pub fn with_str_name(mut self, name: &str) -> Field {
self.name = name.to_string();
self
}
pub fn with_index(mut self, index: usize) -> Field {
self.index = index;
self
}
pub fn with_field_type(mut self, field_type: FieldType) -> Field {
self.field_type = field_type;
self
}
pub fn with_ignore_blanks(mut self, ignore_blanks: bool) -> Field {
self.ignore_blanks = ignore_blanks;
self
}
pub fn with_ignore_case(mut self, ignore_case: bool) -> Field {
self.ignore_case = ignore_case;
self
}
pub fn with_random(mut self, random: bool) -> Field {
self.random = random;
self
}
}