@Udf
  public Map<String, String> splitToMap(
      @UdfParameter(
          description = "Separator string and values to join") final String input,
      @UdfParameter(
          description = "Separator string and values to join") final String entryDelimiter,
      @UdfParameter(
          description = "Separator string and values to join") final String kvDelimiter) {

    if (input == null || entryDelimiter == null || kvDelimiter == null) {
      return null;
    }

    if (entryDelimiter.isEmpty() || kvDelimiter.isEmpty() || entryDelimiter.equals(kvDelimiter)) {
      return null;
    }

    final Iterable<String> entries = Splitter.on(entryDelimiter).omitEmptyStrings().split(input);
    return StreamSupport.stream(entries.spliterator(), false)
        .filter(e -> e.contains(kvDelimiter))
        .map(kv -> Splitter.on(kvDelimiter).split(kv).iterator())
        .collect(Collectors.toMap(
            Iterator::next,
            Iterator::next,
            (v1, v2) -> v2));
  }
@Test
  public void shouldSplitStringGivenMultiCharDelimiters() {
    Map<String, String> result = udf.splitToMap("foo:=apple||bar:=cherry", "||", ":=");
    assertThat(result, hasEntry("foo", "apple"));
    assertThat(result, hasEntry("bar", "cherry"));
    assertThat(result.size(), equalTo(2));
  }