On 25/09/18 09:48, Claude Warren wrote:
> I have a case that I know falls under Don't Do That (DDT), but it got me
> wondering.
>
> Background:
>
> We have created a custom data type that extends AdhocDatatype and provides
> a data type for an enum. The parse() and unparse() methods work as
> expected.
>
> I have a test case that managed to create 2 instances of the datatype (this
> is the DDT part). I will be spending this morning figuring out why we do
> this and what the proper solution is. But it got me thinking.
>
> The isomorphic test fails on the enum data type based literals. Looking at
> the code, in BaseDatatype.java, it perfors Object.equals( datatype1,
> datatype2 ) in the various equality checks.
>
> Question:
>
> Since the two datatype instances return the same enum, and the lexical form
> of the two is the same, and there is no language specified, should they not
> be considered equal? Should the two graphs not be considered isomorphic?
>
> If not can someone explain why?
Because you haven't implemented .hashCode() and .equals()?
(AdhocDatatype doesn't and can't).
BaseDatatype does not implement .hashCode() and .equals() - the inner
TypeValue does ... but that's the value, not the term. See
LiteralLabel.equals.
Andy
>
> Claude
>
|