Class PdfDictionaryEqualityCalculator

java.lang.Object
com.itextpdf.pdfoptimizer.handlers.fontduplication.PdfDictionaryEqualityCalculator

public class PdfDictionaryEqualityCalculator extends Object
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 Details

    • PdfDictionaryEqualityCalculator

      public PdfDictionaryEqualityCalculator (List<IValueUpdateRule> rules)
      Creates a new instance of the class.
      Parameters:
      rules - is a list of rules for PdfDictionary processing
  • Method Details

    • getHashCode

      public int getHashCode (com.itextpdf.kernel.pdf.PdfDictionary dict)
      Applies rules passed to constructor PdfDictionaryEqualityCalculator(List) to provided dictionary and then calculates its hash code using EqualityUtils.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 constructor PdfDictionaryEqualityCalculator(List) to both provided dictionaries and then compares them using EqualityUtils.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.