Skip to content

Clarify model class fields interface regarding mandatory / optional / default values #44

@laurentg

Description

@laurentg

The model classes is our internal main reference regarding the specification of optional/mandatory fields. Currently we uses Optional<T> when a field is marked as optional in the specs, with another getter supplying by design a non-null value with a default. However Optional is better understood in language context, and since we are inside a validator, even mandatory value can be null.

We should clarify how to model the following:

  • Mandatory values:
    • that cannot be null by design, such as a mandatory ID in DAO scope. Example: stop time trip ID.
    • that can be null for invalid input data:
      • without a sensible default to use by a validator. Example: stop name
      • with a sensible default to use by a validator. Example: route type, in speed checks we can fallback on a default type to get the max speed
  • Optional values:
    • that have a default value provided by the specs. Example: timepoint, pickup/dropoff type, route colors...
    • that do not have a default value provided by the specs:
      • with a sensible default value that can be used by validators. Example: ?
      • without a sensible default value that can be used by validators. Here a null is valid. Example: route URL.
  • Conditionally required, for example stop name (where boarding areas or generic nodes make it optional), parent_station...

Maybe creating dedicated holders such as Optional<T>, for example Required<T> etc...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions