hi together,

on the first glimpse i don't understand why AbstractFileObject doesn't override equals() and hashCode(). depending on the concrete implementation this may result in Object's identity comparison when comparing two file objects which is in most cases definitely not desired (see further below). in my opinion a simple solution would be:


    @Override
    public boolean equals(final Object other) {
        if (this == other)
            return true;
        if (other == null)
            return false;
        if (!(other instanceof FileObject))
            return false;

        try {
            return getURL().equals(((FileObject) other).getURL());
        } catch (FileSystemException e) {
            return false;
        }
    }

    @Override
    public int hashCode() {
        try {
            return getURL().hashCode();
        } catch (FileSystemException e) {
            return super.hashCode();
        }
    }


another issue i stumbled upon today: in AbstractFileObject.getParent() there's an if-clause like:

    if (this == fs.getRoot()) { ... }

i'm pretty sure that an identity comparison makes no sense here and this should rather be changed to

    if (this.equals(fs.getRoot())) { ... }

however, this will only work if equals() is overridden.


what do you think?


regards,
stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to