Skip to content

Commit 9197302

Browse files
committed
PDFBOX-6179: add equals and hash
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932458 13f79535-47bb-0310-9956-ffa450edef68
1 parent be290a4 commit 9197302

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

  • pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.IOException;
2020
import java.util.List;
21+
import java.util.Objects;
2122

2223
import org.apache.pdfbox.cos.COSArray;
2324
import org.apache.pdfbox.cos.COSBase;
@@ -475,4 +476,33 @@ public String toString()
475476
return getFullyQualifiedName() + "{type: " + getClass().getSimpleName() + " value: " +
476477
getInheritableAttribute(COSName.V) + "}";
477478
}
479+
480+
/**
481+
* {@inheritDoc}
482+
*/
483+
@Override
484+
public boolean equals (Object o)
485+
{
486+
if (o == this)
487+
{
488+
return true;
489+
}
490+
491+
if (!(o instanceof PDField))
492+
{
493+
return false;
494+
}
495+
496+
COSDictionary toBeCompared = ((PDField) o).getCOSObject();
497+
return toBeCompared.equals(getCOSObject());
498+
}
499+
500+
/**
501+
* {@inheritDoc}
502+
*/
503+
@Override
504+
public int hashCode()
505+
{
506+
return Objects.hash(dictionary);
507+
}
478508
}

0 commit comments

Comments
 (0)