code: public String toOptionalType(ClassTemplateSpec spec, boolean optional) {
      return toType(
          spec,
          optional ? Optionality.REQUIRED_FIELDS_MAY_BE_ABSENT : androidProperties.optionality);
    }
docs: Returns the Java type of an optional field for the given {@link ClassTemplateSpec} as a
  Java source code string.
  
  If the field is optional it is always represented as a
  {@link AndroidProperties.Optionality#REQUIRED_FIELDS_MAY_BE_ABSENT} type else it is
  represented using the {@link AndroidProperties.Optionality} for this instance.
  
  @param spec to get a Java type name for.
  @param optional indicates if the type is optional or not.
  @return a Java source code string identifying the given type.