mirror of
https://github.com/google/nomulus
synced 2026-09-05 15:46:55 +00:00
Perform minor refactors on premium list code
Principally, this moves a load method into DatastoreHelper that is now only used by tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=148649087
This commit is contained in:
@@ -987,5 +987,23 @@ public class DatastoreHelper {
|
||||
}});
|
||||
}
|
||||
|
||||
/** Returns the entire map of {@link PremiumListEntry}s for the given {@link PremiumList}. */
|
||||
public static ImmutableMap<String, PremiumListEntry> loadPremiumListEntries(
|
||||
PremiumList premiumList) {
|
||||
try {
|
||||
ImmutableMap.Builder<String, PremiumListEntry> entriesMap = new ImmutableMap.Builder<>();
|
||||
if (premiumList.getRevisionKey() != null) {
|
||||
for (PremiumListEntry entry :
|
||||
ofy().load().type(PremiumListEntry.class).ancestor(premiumList.getRevisionKey())) {
|
||||
entriesMap.put(entry.getLabel(), entry);
|
||||
}
|
||||
}
|
||||
return entriesMap.build();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"Could not retrieve entries for premium list " + premiumList.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private DatastoreHelper() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user