code: @SuppressWarnings("nullness") // static method, so null first arg is OK: oi.factory
    private @NonNull Object getRefArg(OptionInfo oi, String argName, String argValue)
        throws ArgException {
  
      Object val;
      try {
        if (oi.constructor != null) {
          val = oi.constructor.newInstance(new Object[] {argValue});
        } else if (oi.baseType.isEnum()) {
          @SuppressWarnings({"unchecked", "rawtypes"})
          Object tmpVal = getEnumValue((Class<Enum>) oi.baseType, argValue);
          val = tmpVal;
        } else {
          if (oi.factory == null) {
            throw new Error("No constructor or factory for argument " + argName);
          }
          if (oi.factoryArg2 == null) {
            val = oi.factory.invoke(null, argValue);
          } else {
            val = oi.factory.invoke(null, argValue, oi.factoryArg2);
          }
        }
      } catch (Exception e) {
        throw new ArgException("Invalid argument (%s) for argument %s", argValue, argName);
      }
  
      return val;
    }
docs: Given a value string supplied on the command line, create an object. The only expected error is
  some sort of parse error from the constructor.
  
  @param oi the option corresponding to {@code argName} and {@code argValue}
  @param argName the argument name -- used only for diagnostics
  @param argValue the value supplied on the command line, which this method parses
  @return a value, whose printed representation is {@code argValue}
  @throws ArgException if the user supplied an incorrect string (contained in {@code argValue})