code: public void register(final FieldDefinition definition) {
          //ensure that we can't register a mandatory definition if there are already optional ones
          boolean hasOptionalField = false;
          for (final FieldDefinition fieldDefinition : fields.values()) {
              if (fieldDefinition.isOptional()) {
                  hasOptionalField = true;
                  break;
              }
          }
          if (!definition.isOptional() && hasOptionalField) {
              throw new IllegalArgumentException("Can't register mandatory definition after a optional definition.");
          }
          fields.put(definition.getFieldName(), definition);
      }
docs: Registers a certain FieldDefinition.
  
  @param definition - FieldDefinition  instance, never null