lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trejkaz <>
Subject Weird cloning in QueryNode implementations
Date Tue, 11 Apr 2017 04:06:18 GMT
Hi all.

Something queer I found while looking at QueryNode implementations is
this sort of thing:

    public FieldQueryNode cloneTree() throws CloneNotSupportedException {
        FieldQueryNode fqn = (FieldQueryNode) super.cloneTree();
        fqn.begin = this.begin;
        fqn.end = this.end;
        fqn.field = this.field;
        fqn.text = this.text;
        fqn.positionIncrement = this.positionIncrement;

        return fqn;

I guess what I don't get is the point of all these field copies, because:

    * super.cloneTree() seems to call QueryNodeImpl#cloneTree()
    * QueryNodeImpl#cloneTree seems to call Object#clone()
    * Object#clone() seems to already copy all primitives and
references (a "shallow copy")

So to me it looks like the query node classes are doing a lot of
pedalling, but that the gears aren't really connected to the wheels,
and that classes should only override these if they have a more
complex object which isn't already taken care of automatically.

Or am I missing something?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message