public static List<String> buildList(Object propertyValue, String listSeparator)
  {
    List<String> valueList = new ArrayList<>();
    if (propertyValue != null)
    {
      if (propertyValue instanceof List<?>)
      {
        @SuppressWarnings("unchecked")
        List<String> list = (List<String>)propertyValue;
        valueList.addAll(list);
      }
      else
      {
        // list was expressed as a String in the config
        String propertyValueString = (String)propertyValue;
        if (listSeparator == null)
        {
          throw new IllegalArgumentException("The separator cannot be null!");
        }
        for (String value: propertyValueString.split(listSeparator))
        {
          if (!value.isEmpty())
          {
            valueList.add(value.trim());
          }
        }
      }
    }
    return valueList;
  }
@Test
  public void testListAndString()
  {
    List<String> inputList = new ArrayList<>();
    inputList.add("foo");
    inputList.add("bar");
    inputList.add("baz");

    List<String> configForList = ConfigValueExtractor.buildList(inputList, ",");
    List<String> configForString = ConfigValueExtractor.buildList("foo, bar, baz", ",");

    Assert.assertTrue(configForList.equals(configForString));
  }