class ArrayDistinct {

  @Udf
  public <T> List<T> distinct(
      @UdfParameter(description = "Array of values to distinct") final List<T> input) {
    if (input == null) {
      return null;
    }
    final Set<T> distinctVals = Sets.newLinkedHashSetWithExpectedSize(input.size());
    input.forEach(entry -> {
      distinctVals.add(entry);
    });
    final List<T> output = new ArrayList<T>(distinctVals);
    return output;
  }

}