[
https://issues.apache.org/jira/browse/PDFBOX-4723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17009054#comment-17009054
]
Maruan Sahyoun commented on PDFBOX-4723:
----------------------------------------
The current implementation works similar to othe List implementations - which
was the whole purpose of the change - but not necessarily to all possible cases
of the PDF specification. wo overwriting equals and identical are the same. But
when doing a custom equals implementation one would compare the contents of
the fields of the object and with all fields being equal an object is treated
to be equal (but not identical).
With the double nature of COSArrayList (holding the PD and COS) {{remove(Object
o)}} and {{removeAll}} can only work properly when assuming equalty is because
of same COS content. An alternative would be to store the COS object at the PD
level so one would be able to take that as a reference when accessing the COS
level. Now this would allow to treat equal as identical. I'm not sure that
this meats the users expectation.
With the old implementation remove/removeAll would only remove PD objects and
sometimes correctly corresponding COS objects. With the new implementation at
least one can be sure how objects are removed.
But that brings me back to my first point. I don't think that COSArrayList
should exist at all.
> Add equals() and hashCode() to PDAnnotation and COS objects
> -----------------------------------------------------------
>
> Key: PDFBOX-4723
> URL: https://issues.apache.org/jira/browse/PDFBOX-4723
> Project: PDFBox
> Issue Type: Sub-task
> Components: PDModel
> Affects Versions: 2.0.18
> Reporter: Maruan Sahyoun
> Assignee: Maruan Sahyoun
> Priority: Major
> Fix For: 2.0.19, 3.0.0 PDFBox
>
>
> In order to proper support removeAll/retainAll for COSArrayList we need to
> detect if entries are in fact duplicates of others. This currently fails as
> even though one might add the same instance of an annotation object multiple
> times to setAnnotations getting the annotations will have individual
> instances. See the discussion at PDFBOX-4669.
> In order to proper support removal we need to be able to detect equality
> where an object is equal if the underlying COSDictionary has the same entries.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]