Class PdfDictionaryEqualityCalculator
java.lang.Object
com.itextpdf.pdfoptimizer.handlers.fontduplication.PdfDictionaryEqualityCalculator
Class is used for flexible comparison of two instances of
PdfDictionary
. It allows to provide a list of rules. According to the rules dictionary will be processed appropriately before hash or equality calculation.
According to the contract of IValueUpdateRule
it is expected that rule applying should not change the internal state of the objects included as values into original PdfDictionary. Modified copies of the objects will be put into dictionary instead.
-
Constructor Summary
ConstructorDescriptionCreates a new instance of the class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
areEqual
(com.itextpdf.kernel.pdf.PdfDictionary dict1, com.itextpdf.kernel.pdf.PdfDictionary dict2) Applies rules passed to constructorPdfDictionaryEqualityCalculator(List)
to both provided dictionaries and then compares them usingEqualityUtils.areEqual(PdfObject, PdfObject)
method.int
getHashCode
(com.itextpdf.kernel.pdf.PdfDictionary dict) Applies rules passed to constructorPdfDictionaryEqualityCalculator(List)
to provided dictionary and then calculates its hash code usingEqualityUtils.getHashCode(PdfObject)
method.
-
Constructor Details
-
PdfDictionaryEqualityCalculator
Creates a new instance of the class.- Parameters:
-
rules
- is a list of rules forPdfDictionary
processing
-
-
Method Details
-
getHashCode
public int getHashCode(com.itextpdf.kernel.pdf.PdfDictionary dict) Applies rules passed to constructorPdfDictionaryEqualityCalculator(List)
to provided dictionary and then calculates its hash code usingEqualityUtils.getHashCode(PdfObject)
method.For the same set of rules two instances will have equal hashCode if they are considered as equal by
areEqual(PdfDictionary, PdfDictionary)
method.- Parameters:
-
dict
- is a dictionary whose content-based hash code has to be calculated - Returns:
- calculated content-based hash code for provided dictionary
-
areEqual
public boolean areEqual(com.itextpdf.kernel.pdf.PdfDictionary dict1, com.itextpdf.kernel.pdf.PdfDictionary dict2) Applies rules passed to constructorPdfDictionaryEqualityCalculator(List)
to both provided dictionaries and then compares them usingEqualityUtils.areEqual(PdfObject, PdfObject)
method.For the same set of rules if two instances are considered as equal they should also have equals hashCodes calculated by
getHashCode(PdfDictionary)
method.- Parameters:
-
dict1
- is the first dictionary to compare -
dict2
- is the second dictionary to compare - Returns:
- true if dictionaries are equal and false otherwise.
-