@VisibleForTesting
  void populate(
      Function<Optional<String>, Path> cellRoots,
      ProjectFilesystem filesystem,
      BuildRuleFactoryParams params,
      Object dto,
      final ImmutableSet.Builder<BuildTarget> declaredDeps,
      Map<String, ?> instance,
      boolean onlyOptional)
      throws ConstructorArgMarshalException {
    Set<ParamInfo<?>> allInfo = getAllParamInfo(dto);

    for (ParamInfo<?> info : allInfo) {
      if (onlyOptional && !info.isOptional()) {
        continue;
      }
      try {
        info.setFromParams(cellRoots, filesystem, params, dto, instance);
      } catch (ParamInfoException e) {
        throw new ConstructorArgMarshalException(e.getMessage(), e);
      }
      if (info.getName().equals("deps")) {
        populateDeclaredDeps(info, declaredDeps, dto);
      }
    }
  }