Create database path builder
Typing a database access path (e.g. "/LOBBIES/4/otherPlayerId"
) is error-prone. This is made safer by using enums and field names, e.g. "${DataPaths.LOBBIES}/4/${LobbyData::otherPlayerID.name}"
, but it's not super readable, it's not discoverable, it's not context-sensitive, and it's not type-safe. I see this as a great opportunity to use something builder-pattern-like for points, where the same path could be constructed using something like DataPath.lobbies(4).field(LobbyData::otherPlayerID)
. This expression could have a toPath
-method, and the final type of this example expression could be e.g. DataPathPrimitive<String>
, so that our database access methods know precisely which type to return, and the DataPath-builder knows there are no further paths from a String.