use crate::catalog::ArithmeticPos;
use std::fmt;
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub(crate) struct FnCallPredicatePos {
name: String,
args: Vec<ArithmeticPos>,
is_negated: bool,
}
impl FnCallPredicatePos {
pub(crate) fn new(name: String, args: Vec<ArithmeticPos>, is_negated: bool) -> Self {
Self {
name,
args,
is_negated,
}
}
#[inline]
pub(crate) fn name(&self) -> &str {
&self.name
}
#[inline]
pub(crate) fn args(&self) -> &[ArithmeticPos] {
&self.args
}
#[inline]
pub(crate) fn is_negated(&self) -> bool {
self.is_negated
}
}
impl fmt::Display for FnCallPredicatePos {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let args_str = self
.args
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()
.join(", ");
if self.is_negated {
write!(f, "[!{}({})]", self.name, args_str)
} else {
write!(f, "[{}({})]", self.name, args_str)
}
}
}