class ArrayIntersect {

  @Udf
  public <T> List<T> intersect(
      @UdfParameter(description = "First array of values") final List<T> left,
      @UdfParameter(description = "Second array of values") final List<T> right) {
    if (left == null || right == null) {
      return null;
    }
    final Set<T> intersection = Sets.newLinkedHashSet(left);
    intersection.retainAll(Sets.newHashSet(right));
    return Lists.newArrayList(intersection);
  }

}