Re: [xwiki-devs] [xwiki-notifications] r19378 - in platform/core/branches/xwiki-core-1.8: xwiki-bridge/src xwiki-bridge/src/main/java/org/xwiki/bridge xwiki-bridge/src/test xwiki-bridge/src/test/java xwiki-bridge/src/test/java/org xwiki-bridge/src/te
On Tue, May 5, 2009 at 12:49, Vincent Massol <[email protected]> wrote:
On May 5, 2009, at 12:40 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-05-05 12:40:47 +0200 (Tue, 05 May 2009) New Revision: 19378
Added: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/DocumentNameTest.java Modified: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/ org/xwiki/bridge/DocumentName.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/com/ xpn/xwiki/doc/XWikiDocument.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/com/ xpn/xwiki/doc/XWikiDocumentTest.java Log: XWIKI-3754: XWikiDocument.getLinkedPages loose multiwiki information
[snip]
+ + /** + * {@inheritDoc} + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + boolean equals = false; + + if (obj == this) { + equals = true; + } else if (obj instanceof DocumentName) { + DocumentName documentName = (DocumentName) obj; + + equals = + documentName.getWiki().equals(this.getWiki()) && documentName.getSpace().equals(this.getSpace()) + && documentName.getPage().equals(this.getPage()); + } + + return equals; + }
You're not handling null I think.
Yes but I assume DocumentName is supposed to be valid
[snip]
-Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On May 5, 2009, at 12:55 PM, Thomas Mortagne wrote:
On Tue, May 5, 2009 at 12:49, Vincent Massol <[email protected]> wrote:
On May 5, 2009, at 12:40 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-05-05 12:40:47 +0200 (Tue, 05 May 2009) New Revision: 19378
Added: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/DocumentNameTest.java Modified: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/ org/xwiki/bridge/DocumentName.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/ com/ xpn/xwiki/doc/XWikiDocument.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/ com/ xpn/xwiki/doc/XWikiDocumentTest.java Log: XWIKI-3754: XWikiDocument.getLinkedPages loose multiwiki information
[snip]
+ + /** + * {@inheritDoc} + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + boolean equals = false; + + if (obj == this) { + equals = true; + } else if (obj instanceof DocumentName) { + DocumentName documentName = (DocumentName) obj; + + equals = + documentName.getWiki().equals(this.getWiki()) && documentName.getSpace().equals(this.getSpace()) + && documentName.getPage().equals(this.getPage()); + } + + return equals; + }
You're not handling null I think.
Yes but I assume DocumentName is supposed to be valid
Equals methods should not assume this. I personally use this resource when coding equals/hashcode: http://www.geocities.com/technofundo/tech/java/equalhash.html -Vincent
On Tue, May 5, 2009 at 12:58, Vincent Massol <[email protected]> wrote:
On May 5, 2009, at 12:55 PM, Thomas Mortagne wrote:
On Tue, May 5, 2009 at 12:49, Vincent Massol <[email protected]> wrote:
On May 5, 2009, at 12:40 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-05-05 12:40:47 +0200 (Tue, 05 May 2009) New Revision: 19378
Added: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/ platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/test/java/ org/xwiki/bridge/DocumentNameTest.java Modified: platform/core/branches/xwiki-core-1.8/xwiki-bridge/src/main/java/ org/xwiki/bridge/DocumentName.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/main/java/ com/ xpn/xwiki/doc/XWikiDocument.java platform/core/branches/xwiki-core-1.8/xwiki-core/src/test/java/ com/ xpn/xwiki/doc/XWikiDocumentTest.java Log: XWIKI-3754: XWikiDocument.getLinkedPages loose multiwiki information
[snip]
+ + /** + * {@inheritDoc} + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + boolean equals = false; + + if (obj == this) { + equals = true; + } else if (obj instanceof DocumentName) { + DocumentName documentName = (DocumentName) obj; + + equals = + documentName.getWiki().equals(this.getWiki()) && documentName.getSpace().equals(this.getSpace()) + && documentName.getPage().equals(this.getPage()); + } + + return equals; + }
You're not handling null I think.
Yes but I assume DocumentName is supposed to be valid
Equals methods should not assume this. I personally use this resource when coding equals/hashcode: http://www.geocities.com/technofundo/tech/java/equalhash.html
Ok, i'm improving it then
-Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (2)
-
Thomas Mortagne -
Vincent Massol