From: Jody G. <jga...@re...> - 2007-08-28 15:21:35
|
While you are correct - equalsIgnoreMetadata would work - the option is not available to me. I am working only against the geoapi interfaces and I am interacting with ReferenceIdentifier implementations from both GeoTools and a commercial application. Jody > Jody Garnett a écrit : > >> Hi Martin; I have run into an interesting situation when comparing the >> results of different EPSG authority factories. I cannot compare a >> ReferenceIdentifier created with a factory against one created by hand >> using Citations.EPSG. Citation.equals takes getVersion() into account >> when making the comparison. >> Currently I am doing a lot of Citation.toString() and getCode() calls in >> order to make my comparisons. >> > > > I usually favor strict "equals" implementation in the hope to avoid arbitrary > choice or unexpected behavior, especially when the object is added in a HashSet. > In the particular case of Citation, if my memory serve me right it should not be > a problem when comparing CRS object using "equalsIgnoreMetadata"? > > If the purpose is to compare Citations themself rather than CRS objects, I > suggest to keep the "equals" method strict and provide convenience methods > relaxing the comparaison in different way instead. For example should we compare > the titles or the identifiers? The Citations class provide such convenience > methods. On my side, I use Citations.identifierMatches(Citation,Citation) in > order to make my comparaisons: > > http://javadoc.geotools.fr/snapshot/org/geotools/metadata/iso/citation/Citations.html#identifierMatches(org.opengis.metadata.citation.Citation,%20org.opengis.metadata.citation.Citation) > > There is also a "titleMatches" method. We could add more convenience methods > making the comparaisons in different way if there is a need for that. > > > Martin > |