google-nomulus/java/google/registry/model
mcilwain 4491b7b909 Make loadByForeignKey() and related methods return Optional
This is safer and addresses a common source of confusion in the codebase because it's always explicit that the resource returned may not be present, whether because it's soft-deleted when projected to the given time or because it never existed in the first place.

In production code, the presence of the returned value is always checked. In test code, its presence is assumed using .get() where that is expected and convenient, as it not being present will throw an NPE that will cause the test to fail anyway.

Note that the roughly equivalent reloadResourceByForeignKey(), which is widely used in test code, is not having this same treatment applied to it. That is out of the scope of this CL, and has much smaller returns anyway because it's only used in tests (where the unexpected absence of a given resource would just cause the test to fail).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=225424002
2018-12-14 11:24:49 -05:00
..
annotations Clean up some code quality issues 2017-12-01 22:14:06 -05:00
billing Add a RESERVED billing event flag for creates of reserved domains 2018-10-22 18:38:23 -04:00
common Add an auto update time field to the Cursor entity 2018-08-10 13:44:25 -04:00
contact Migrate Guava Predicates.notNull to Objects.nonNull 2017-12-27 11:19:53 -05:00
domain Make loadByForeignKey() and related methods return Optional 2018-12-14 11:24:49 -05:00
eppcommon Refactor EppXmlTransformer to be in the model/ package 2018-12-12 13:22:34 -05:00
eppinput Add more absent clTrid unit tests 2018-06-27 15:28:52 -04:00
eppoutput Switch from Guava Optionals to Java 8 Optionals 2017-10-24 16:53:47 -04:00
host Format some imports using fix_imports.py 2017-10-24 16:53:47 -04:00
index Clean up some areas in preparation for externalized codebase 2018-11-16 16:51:11 -05:00
mark Update copyright year on all license headers 2017-02-02 16:27:22 -05:00
ofy Migrate away from VoidWorks 2018-06-27 15:28:52 -04:00
poll Remove leniency on poll message ID format without years in them 2018-02-20 15:12:43 -05:00
pricing Clean up some code quality issues 2017-12-01 22:14:06 -05:00
rde Refer to Datastore everywhere correctly by its capitalized form 2017-02-17 12:12:12 -05:00
registrar Handle Purchase Order numbers explicitly in billing pipeline 2018-09-20 11:19:36 -04:00
registry Remove the deprecated MISTAKEN_PREMIUM reservation type 2018-09-14 21:28:23 -04:00
reporting Fix NPE in GetHistoryEntriesCommand 2017-10-24 16:53:47 -04:00
server Use locking on async mapreduces 2018-08-10 13:44:25 -04:00
smd Replace FluentIterable with streams 2017-12-27 11:40:50 -05:00
tmch Fix checkState failing to trigger retrier's retry 2018-12-12 13:22:34 -05:00
transfer Clean up some code quality issues 2017-12-01 22:14:06 -05:00
translators Remove unnecessary "throws" declarations 2018-06-18 18:17:56 -04:00
BackupGroupRoot.java Refer to Datastore everywhere correctly by its capitalized form 2017-02-17 12:12:12 -05:00
BUILD Clean up annotation imports in BUILD files 2018-06-27 15:28:53 -04:00
Buildable.java Clean up some code quality issues 2017-12-01 22:14:06 -05:00
CacheUtils.java Refer to Datastore everywhere correctly by its capitalized form 2017-02-17 12:12:12 -05:00
CreateAutoTimestamp.java Add create timestamp as field on AllocationToken entity 2018-01-19 14:25:28 -05:00
EntityClasses.java Delete all Limited Release Program (LRP) code 2018-08-20 14:28:16 -04:00
EppResource.java Add limit to list_domains command 2018-05-17 21:52:35 -04:00
EppResourceUtils.java Make loadByForeignKey() and related methods return Optional 2018-12-14 11:24:49 -05:00
ImmutableObject.java Replace com.google.common.base.Function with java.util.function.Function 2017-12-27 11:08:55 -05:00
Jsonifiable.java Update copyright year on all license headers 2017-02-02 16:27:22 -05:00
JsonMapBuilder.java Replace com.google.common.base.Function with java.util.function.Function 2017-12-27 11:08:55 -05:00
ModelUtils.java Replace FluentIterable with streams 2017-12-27 11:40:50 -05:00
package-info.java Refer to Datastore everywhere correctly by its capitalized form 2017-02-17 12:12:12 -05:00
SchemaVersion.java Run automatic Java 8 conversion over codebase 2017-10-10 12:09:41 -04:00
UpdateAutoTimestamp.java Add an auto update time field to the Cursor entity 2018-08-10 13:44:25 -04:00