Package google.registry.model
Class ForeignKeyUtils
java.lang.Object
google.registry.model.ForeignKeyUtils
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 Summary
Modifier and TypeMethodDescriptionstatic <E extends EppResource>
VKey<E> Loads aVKey
to anEppResource
from the database by foreign key.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 ofString
foreign keys toVKey
s toEppResource
that are active at or after the specified moment in time.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 ofVKey
toEppResource
instances by class and foreign key strings that are active at or after the specified moment in time, using the cache if enabled.static void
setCacheForTest
(Optional<Duration> expiry)
-
Method Details
-
load
@Nullable public static <E extends EppResource> VKey<E> load(Class<E> clazz, String foreignKey, org.joda.time.DateTime now) Loads aVKey
to anEppResource
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 loadforeignKey
- foreign key to matchnow
- 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 ofString
foreign keys toVKey
s toEppResource
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
-
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 ofVKey
toEppResource
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.
-