Class ForeignKeyUtils

java.lang.Object
google.registry.model.ForeignKeyUtils

public final class ForeignKeyUtils extends Object
Util class to map a foreign key to the VKey to the active instance of EppResource whose unique repoId matches the foreign key string at a given time. The instance is never deleted, but it is updated if a newer entity becomes the active entity.
  • Method Details

    • load

      @Nullable public static <E extends EppResource> VKey<E> load(Class<E> clazz, String foreignKey, org.joda.time.DateTime now)
      Loads a VKey to an EppResource from the database by foreign key.

      Returns null if no resource with this foreign key was ever created, or if the most recently created resource was deleted before time "now".

      Parameters:
      clazz - the resource type to load
      foreignKey - foreign key to match
      now - the current logical time to use when checking for soft deletion of the foreign key index
    • load

      public static <E extends EppResource> com.google.common.collect.ImmutableMap<String,VKey<E>> load(Class<E> clazz, Collection<String> foreignKeys, org.joda.time.DateTime now)
      Load a map of String foreign keys to VKeys to EppResource that are active at or after the specified moment in time.

      The returned map will omit any foreign keys for which the EppResource doesn't exist or has been soft-deleted.

    • setCacheForTest

      public static void setCacheForTest(Optional<Duration> expiry)
    • loadCached

      public static <E extends EppResource> com.google.common.collect.ImmutableMap<String,VKey<E>> loadCached(Class<E> clazz, Collection<String> foreignKeys, org.joda.time.DateTime now)
      Load a list of VKey to EppResource instances by class and foreign key strings that are active at or after the specified moment in time, using the cache if enabled.

      The returned map will omit any keys for which the EppResource doesn't exist or has been soft-deleted.

      Don't use the cached version of this method unless you really need it for performance reasons, and are OK with the trade-offs in loss of transactional consistency.