Class ForeignKeyIndex<E extends EppResource>

    • Constructor Detail

      • ForeignKeyIndex

        public ForeignKeyIndex()
    • Method Detail

      • getForeignKey

        public java.lang.String getForeignKey()
      • getDeletionTime

        public org.joda.time.DateTime getDeletionTime()
      • getResourceKey

        public VKey<E> getResourceKey()
      • mapToFkiClass

        public static <T extends EppResource> java.lang.Class<ForeignKeyIndex<T>> mapToFkiClass​(java.lang.Class<T> resourceClass)
      • create

        public static <E extends EppResourceForeignKeyIndex<E> create​(E resource,
                                                                        org.joda.time.DateTime deletionTime)
        Create a ForeignKeyIndex instance for a resource, expiring at a specified time.
      • loadAndGetKey

        @Nullable
        public static <E extends EppResourceVKey<E> loadAndGetKey​(java.lang.Class<E> clazz,
                                                                    java.lang.String foreignKey,
                                                                    org.joda.time.DateTime now)
        Loads a Key to an EppResource from Datastore by foreign key.

        Returns null if no foreign key index with this foreign key was ever created, or if the most recently created foreign key index was deleted before time "now". This method does not actually check that the referenced resource actually exists. However, for normal epp resources, it is safe to assume that the referenced resource exists if the foreign key index does.

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

        @Nullable
        public static <E extends EppResourceForeignKeyIndex<E> load​(java.lang.Class<E> clazz,
                                                                      java.lang.String foreignKey,
                                                                      org.joda.time.DateTime now)
        Load a ForeignKeyIndex by class and id string that is active at or after the specified moment in time.

        This will return null if the ForeignKeyIndex doesn't exist or has been soft deleted.

      • load

        public static <E extends EppResource> com.google.common.collect.ImmutableMap<java.lang.String,​ForeignKeyIndex<E>> load​(java.lang.Class<E> clazz,
                                                                                                                                     java.util.Collection<java.lang.String> foreignKeys,
                                                                                                                                     org.joda.time.DateTime now)
        Load a map of ForeignKeyIndex instances by class and id strings that are active at or after the specified moment in time.

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

      • setCacheForTest

        public static void setCacheForTest​(java.util.Optional<java.time.Duration> expiry)
      • loadCached

        public static <E extends EppResource> com.google.common.collect.ImmutableMap<java.lang.String,​ForeignKeyIndex<E>> loadCached​(java.lang.Class<E> clazz,
                                                                                                                                           java.util.Collection<java.lang.String> foreignKeys,
                                                                                                                                           org.joda.time.DateTime now)
        Load a list of ForeignKeyIndex instances by class and id 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 ForeignKeyIndex 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.