use std::fmt;
use super::ValueType;
#[derive(Clone, Debug, PartialEq)]
pub enum Type {
EntityType(EntityType),
RelationType(RelationType),
AttributeType(AttributeType),
RoleType(RoleType),
}
impl Type {
pub fn label(&self) -> &str {
match self {
Type::EntityType(entity_type) => entity_type.label(),
Type::RelationType(relation_type) => relation_type.label(),
Type::AttributeType(attribute_type) => attribute_type.label(),
Type::RoleType(role_type) => role_type.label(),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EntityType {
pub label: String,
}
impl EntityType {
pub fn label(&self) -> &str {
&self.label
}
}
impl fmt::Display for EntityType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RelationType {
pub label: String,
}
impl RelationType {
pub fn label(&self) -> &str {
&self.label
}
}
impl fmt::Display for RelationType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct AttributeType {
pub label: String,
pub value_type: Option<ValueType>,
}
impl AttributeType {
pub fn label(&self) -> &str {
&self.label
}
pub fn value_type(&self) -> Option<&ValueType> {
self.value_type.as_ref()
}
}
impl fmt::Display for AttributeType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RoleType {
pub label: String,
}
impl RoleType {
pub fn label(&self) -> &str {
&self.label
}
}
impl fmt::Display for RoleType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}