Package wt.fc

Class WTPair

All Implemented Interfaces:
Serializable

public class WTPair extends Pair<WTReference,WTReference>
Aggregates an ordered pair of WTReferences and handles them as a unique combination. Two WTPair objects will test equal if their component WTReferences test equal. A WTPair's hash code is a combination of its component WTReference hash codes, which allows them to be added to collections and used as map keys.

Only the following WTReference implementations ares supported:



Supported API: true

Extendable: false
See Also:
  • Constructor Details

    • WTPair

      public WTPair()
      Construct a default WTPair with null component objects.

      Supported API: true
    • WTPair

      public WTPair(Object obj1, Object obj2)
      Construct a WTPair from component objects.

      Supported API: true
      Parameters:
      obj1 - First Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey object.
      obj2 - Second Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey object.
    • WTPair

      public WTPair(WTPair wtPair)
      Construct a WTPair copy.

      Supported API: true
      Parameters:
      wtPair - WTPair object to be copied.
  • Method Details

    • getReference1

      public WTReference getReference1()
      Get first reference.

      Supported API: true
    • getReference2

      public WTReference getReference2()
      Get second reference.

      Supported API: true
    • getPersistable1

      public Persistable getPersistable1()
      Get first Persistable (will inflate the reference).

      Supported API: true
    • getPersistable2

      public Persistable getPersistable2()
      Get second Persistable (will inflate the reference).

      Supported API: true
    • getKey1

      public QueryKey getKey1()
      Get first query key.

      Supported API: true
    • getKey2

      public QueryKey getKey2()
      Get second query key.

      Supported API: true
    • setWTObj1

      public void setWTObj1(Object obj1)
      Set first object.

      Supported API: true
      Parameters:
      obj1 - New first Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey.
    • setWTObj2

      public void setWTObj2(Object obj2)
      Set second object.

      Supported API: true
      Parameters:
      obj2 - New second Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey.
    • setWTObjs

      public void setWTObjs(Object obj1, Object obj2)
      Set both component objects.

      Supported API: true
      Parameters:
      obj1 - New first Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey.
      obj2 - New second Persistable, ObjectReference, VersionReference, ObjectIdentifier or VersionForeignKey.
    • setObj1

      public void setObj1(WTReference ref1)
      Set first reference.

      Supported API: true
      Overrides:
      setObj1 in class Pair<WTReference,WTReference>
      Parameters:
      ref1 - New first reference.
    • setObj2

      public void setObj2(WTReference ref2)
      Set second reference.

      Supported API: true
      Overrides:
      setObj2 in class Pair<WTReference,WTReference>
      Parameters:
      ref1 - New second reference.
    • mapWTPairs

      public static WTKeyedMap mapWTPairs(Collection wtPairs, WTKeyedMap map, boolean firstKey)
      Populate a WTKeyedMap from a collection of WTPairs.

      Supported API: true
      Parameters:
      wtPairs - Collection of WTPair objects. Only WTPair objects with non-null first and second references will be added to the map. All others are skipped. All WTPairs in the collection should have consistent WTRefernce types for the keys and values, or a runtime exception will be thrown.

      map - WTKeyedMap or WTValeudMap to be populated with WTPairs. Pre-populated map contents will be retained. The map's keys will be either the first or second reference from the WTPair objects. The map's values will be a WTCollection of the other references. The type of WTCollection created will match the wtPairs type (i.e., a WTList if wtPairs is a List, otherwise a WTSet). A WTKeyedMap will be created if null is passed in.

      Note that if a WTValuedMap is passed in then the map's value will be a single WTReference rather than a WTCollection. If the same key is provided by multiple WTPair objects then the value returned in the map will be from the last WTPair encountered.

      firstKey - True to assign the first reference as the map key and the second reference as the map value, or false for the opposite assignment.
      Returns:
      The map that was passed in (or created) with the WTPair objects added.