Skip to content

Commit e3a1a4c

Browse files
RubenVerborghelf-pavlik
authored andcommitted
Rigorously define equals for Term.
1 parent aa3df2a commit e3a1a4c

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

index.html

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,18 @@ <h3><dfn>Term</dfn> interface</h3>
148148
<dfn>value</dfn> is refined by each interface which extends Term.
149149
</p>
150150
<p>
151-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has the same
152-
<code>termType</code> and the same contents (as defined by concrete subclasses).
151+
<dfn>equals()</dfn> returns <code>true</code>
152+
when called with parameter <code>other</code>
153+
on an object <code>term</code> if all of the conditions below hold:
154+
</p>
155+
<ul>
156+
<li><code>other</code> is <em>neither</em> <code>null</code> nor <code>undefined</code>;</li>
157+
<li><code>term.termType</code> is the same string as <code>other.termType</code>;</li>
158+
<li><code>other</code> follows the additional constraints of the specific <code>Term</code> interface implemented by <code>term</code>
159+
(e.g., <a>NamedNode</a>, <a>Literal</a>, …);</li>
160+
</ul>
161+
<p>
162+
otherwise, it returns <code>false</code>.
153163
</p>
154164
</section>
155165

@@ -171,8 +181,10 @@ <h3><dfn>NamedNode</dfn> interface</h3>
171181
<dfn>value</dfn> the IRI of the named node (example: <code>"http://example.org/resource"</code>).
172182
</p>
173183
<p>
174-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has
175-
<code>termType</code> <code>"NamedNode"</code> and the same <code></code>value</code>.
184+
<dfn>equals()</dfn> returns <code>true</code> if
185+
all general <a>Term.equals</a> conditions hold
186+
and <code>term.value</code> is the same string as <code>other.value</code>;
187+
otherwise, it returns <code>false</code>.
176188
</p>
177189
</section>
178190

@@ -196,8 +208,10 @@ <h3><dfn>BlankNode</dfn> interface</h3>
196208
sourced from RDF/XML, do not change the blank node name (example: <code>"blank3"</code>)
197209
</p>
198210
<p>
199-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has
200-
<code>termType</code> <code>"BlankNode"</code> and the same <code>value</code>.
211+
<dfn>equals()</dfn> returns <code>true</code> if
212+
all general <a>Term.equals</a> conditions hold
213+
and <code>term.value</code> is the same string as <code>other.value</code>;
214+
otherwise, it returns <code>false</code>.
201215
</p>
202216
</section>
203217

@@ -235,9 +249,12 @@ <h3><dfn>Literal</dfn> interface</h3>
235249
<code>"http://www.w3.org/2001/XMLSchema#string"</code>.
236250
</p>
237251
<p>
238-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has
239-
<code>termType</code> <code>"Literal"</code> and the same <code>value</code>,
240-
<code>language</code>, and <code>datatype</code>.
252+
<dfn>equals()</dfn> returns <code>true</code> if
253+
all general <a>Term.equals</a> conditions hold,
254+
<code>term.value</code> is the same string as <code>other.value</code>,
255+
<code>term.language</code> is the same string as <code>other.language</code>, and
256+
<code>term.datatype.equals(other.datatype)</code> evaluates to <code>true</code>;
257+
otherwise, it returns <code>false</code>.
241258
</p>
242259
</section>
243260

@@ -260,8 +277,10 @@ <h3><dfn>Variable</dfn> interface</h3>
260277
<code>"a"</code>).
261278
</p>
262279
<p>
263-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has
264-
<code>termType</code> <code>"Variable"</code> and the same <code>value</code>.
280+
<dfn>equals()</dfn> returns <code>true</code> if
281+
all general <a>Term.equals</a> conditions hold
282+
and <code>term.value</code> is the same string as <code>other.value</code>;
283+
otherwise, it returns <code>false</code>.
265284
</p>
266285
</section>
267286

@@ -287,8 +306,9 @@ <h3><dfn>DefaultGraph</dfn> interface</h3>
287306
<dfn>value</dfn> contains an empty string as constant value.
288307
</p>
289308
<p>
290-
<dfn>equals()</dfn> returns <code>true</code> if and only if <code>other</code> has
291-
<code>termType</code> <code>"DefaultGraph"</code>.
309+
<dfn>equals()</dfn> returns <code>true</code> if
310+
all general <a>Term.equals</a> conditions hold;
311+
otherwise, it returns <code>false</code>.
292312
</p>
293313
</section>
294314

0 commit comments

Comments
 (0)