defprotocol RDF.Term do @moduledoc """ Shared behaviour for all RDF terms. A `RDF.Term` is anything which can be an element of RDF statements of a RDF graph: - `RDF.IRI`s - `RDF.BlankNode`s - `RDF.Literal`s see """ @doc """ Tests for term equality. see """ @fallback_to_any true def equal?(term1, term2) @doc """ Tests for equality of values. Returns `nil` if the given terms are not comparable. see and the value equality semantics of the different literal datatypes here: """ @fallback_to_any true def equal_value?(term1, term2) end defimpl RDF.Term, for: RDF.IRI do def equal?(term1, term2), do: term1 == term2 def equal_value?(term1, term2), do: RDF.IRI.equal_value?(term1, term2) end defimpl RDF.Term, for: RDF.BlankNode do def equal?(term1, term2), do: term1 == term2 def equal_value?(term1, term2), do: RDF.BlankNode.equal_value?(term1, term2) end defimpl RDF.Term, for: RDF.Literal do def equal?(term1, term2), do: term1 == term2 def equal_value?(term1, term2), do: RDF.Literal.equal_value?(term1, term2) end defimpl RDF.Term, for: Any do def equal?(term1, term2), do: term1 == term2 def equal_value?(_, _), do: nil end