Class AgreementTuple

java.lang.Object
com.isode.dsapi.config.AgreementTuple
All Implemented Interfaces:
Comparable<AgreementTuple>

public class AgreementTuple extends Object implements Comparable<AgreementTuple>
A shadow agreement is uniquely identified with three pieces of information, which are held in an AgreementTuple. Objects of this class may be used as keys for HashMaps etc., and because they are comparable will be ordered properly if used as a key for a SortedMap.
Since:
15.1
  • Constructor Details

    • AgreementTuple

      public AgreementTuple(DN areaName, DN supplierDN, DN consumerDN)
      Construct a new tuple.
      Parameters:
      areaName - area name. Must not be null.
      supplierDN - supplier DSA's DN. Must not be null.
      consumerDN - consumer DSA's DN. Must not be null.
  • Method Details

    • getAreaName

      public DN getAreaName()
      Determine the area DN represented by this agreement
      Returns:
      the area name, which will never be null.
    • getSupplierDN

      public DN getSupplierDN()
      Determine the DN of the supplier DSA for this agreement
      Returns:
      supplier DSA's DN, which will never be null.
    • getConsumerDN

      public DN getConsumerDN()
      Determine the DN of the consumer DSA for this agreement
      Returns:
      consumer DSA's DN, which will never be null.
    • equals

      public boolean equals(Object other)
      Compares two objects for equality.
      Overrides:
      equals in class Object
      Parameters:
      other - another AgreementTuple. May be null.
      Returns:
      true if other is either the same object, or one that contains area/supplier/consumer values which are the same as this one, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(AgreementTuple other)
      Compare for sort ordering. Ordering is performed by comparing the areaName, then supplierDN, then consumerDN. For example area:c=aa is always "less than" area:c=bb regardless of who supplier and consumer are.

      This means if you sort a list of tuples you'll get something like.

      • c=aa supplied from Z to B
      • c=aa supplied from Z to C
      • c=bb supplied from A to B
      • c=cc supplied from A to D
      • c=dd supplied from A to B
      • c=dd supplied from Z to B
      (all the agreements for a specific area will be adjacent in the sorted list).
      Specified by:
      compareTo in interface Comparable<AgreementTuple>
      Parameters:
      other - another AgreementTuple. Must not be null.
      Returns:
      -1 if this object is "less than" other; 0 if they are "equal", or 1 if it is "greater than" other