Nicer defaults for mandatory values

Issue #16 closed
Chris Fuller created an issue

There are several values that are mandatory in the JSON schema that have reasonable default values we could use so that the caller doesn’t have to always specify them and also some places where we could map either null or "" to the other so that the caller doesn’t have to worry about getting this exactly right. Examples:

  • mediaSingle.layout – can default to Layout.CENTER
  • media.collection – can default to "" and map null to it
  • media.occurrenceKey – can map "" to null
  • mediaInline – same fix-ups as media
  • mention.id – schema permits "", which is currently disallowed
  • mention.text – must start with @, but if "" we can map to null and otherwise we can just silently add @ ourselves

This will be a binary compatibility break because it involves dropping the partial builder stats for things like Media.Partial.NeedsCollection, since these can now build without a collection. This is worth it because

  1. It isn’t a source compatibility break (unless folks are explicitly declaring a variable to hold the intermediate type).
  2. Most callers will no longer want to call the method at all, whereas previously they had to even to provide the default.

Additionally, the exception for mention.text not starting with @ is no longer needed, so it is removed, though there aren’t very many reasons why anyone would catch that anyway.

Comments (3)

  1. Log in to comment