static @Nullable <T extends PluginConfig> T getPluginConfig(
      Map<String, Object> params, Class<T> configClass) {
    // Validate configClass
    if (configClass == null) {
      throw new IllegalArgumentException("Config class must be not null!");
    }
    List<Field> allFields = new ArrayList<>();
    Class<?> currClass = configClass;
    while (currClass != null && !currClass.equals(Object.class)) {
      allFields.addAll(
          Arrays.stream(currClass.getDeclaredFields())
              .filter(f -> !Modifier.isStatic(f.getModifiers()))
              .collect(Collectors.toList()));
      currClass = currClass.getSuperclass();
    }
    InstantiatorFactory instantiatorFactory = new InstantiatorFactory(false);

    @Initialized T config = instantiatorFactory.get(TypeToken.of(configClass)).create();

    if (config != null) {
      for (Field field : allFields) {
        field.setAccessible(true);

        Class<?> fieldType = field.getType();

        Name declaredAnnotation = field.getDeclaredAnnotation(Name.class);
        Object fieldValue =
            declaredAnnotation != null ? params.get(declaredAnnotation.value()) : null;

        if (fieldValue != null && fieldType.equals(fieldValue.getClass())) {
          try {
            field.set(config, fieldValue);
          } catch (IllegalAccessException e) {
            LOG.error("Can not set a field with value {}", fieldValue);
          }
        } else if (field.getName().equals(MACRO_FIELDS_FIELD_NAME)) {
          try {
            field.set(config, Collections.emptySet());
          } catch (IllegalAccessException e) {
            LOG.error("Can not set macro fields");
          }
        }
      }
    }
    return config;
  }
@Test
  public void testBuildingPluginConfigFromEmptyParamsMap() {
    try {
      ServiceNowSourceConfig config =
          PluginConfigInstantiationUtils.getPluginConfig(
              new HashMap<>(), ServiceNowSourceConfig.class);
      assertNotNull(config);
    } catch (Exception e) {
      LOG.error("Error occurred while building the config object", e);
      fail();
    }
  }