Class StringImplode.ImploderBuilderMap

java.lang.Object
com.helger.base.string.StringImplode.ImploderBuilderMap
All Implemented Interfaces:
IBuilder<String>
Enclosing class:
StringImplode

public static class StringImplode.ImploderBuilderMap extends Object implements IBuilder<String>
A simple builder that allows to implode maps of arguments with a lot of customization. It used by all the "getImploded*" overloads and fulfills the requests of other use cases as well.
Since:
10.0.0
Author:
Philip Helger
  • Constructor Details

    • ImploderBuilderMap

      public ImploderBuilderMap()
      Constructor.
  • Method Details

    • source

      public @NonNull StringImplode.ImploderBuilderMap source(@Nullable Map<?,?> a)
      Set the source map, converting keys and values to strings via Object.toString().
      Parameters:
      a - The source map. May be null.
      Returns:
      this for chaining
    • source

      public <K, V> @NonNull StringImplode.ImploderBuilderMap source(@Nullable Map<K,V> a, @NonNull Function<? super K,String> aKeyMapper, @NonNull Function<? super V,String> aValueMapper)
      Set the source map, converting keys and values using the provided mapper functions.
      Type Parameters:
      K - The key type of the source map
      V - The value type of the source map
      Parameters:
      a - The source map. May be null.
      aKeyMapper - The mapping function for keys. May not be null.
      aValueMapper - The mapping function for values. May not be null.
      Returns:
      this for chaining
    • separatorOuter

      public @NonNull StringImplode.ImploderBuilderMap separatorOuter(char c)
      Set the outer separator character used between map entries.
      Parameters:
      c - The outer separator character.
      Returns:
      this for chaining
    • separatorOuter

      public @NonNull StringImplode.ImploderBuilderMap separatorOuter(@Nullable String s)
      Set the outer separator string used between map entries.
      Parameters:
      s - The outer separator string. May be null.
      Returns:
      this for chaining
    • separatorInner

      public @NonNull StringImplode.ImploderBuilderMap separatorInner(char c)
      Set the inner separator character used between key and value within each entry.
      Parameters:
      c - The inner separator character.
      Returns:
      this for chaining
    • separatorInner

      public @NonNull StringImplode.ImploderBuilderMap separatorInner(@Nullable String s)
      Set the inner separator string used between key and value within each entry.
      Parameters:
      s - The inner separator string. May be null.
      Returns:
      this for chaining
    • filterKeyNonEmpty

      public @NonNull StringImplode.ImploderBuilderMap filterKeyNonEmpty()
      Set the key filter to only include entries with non-null and non-empty keys.
      Returns:
      this for chaining
    • filterKey

      public @NonNull StringImplode.ImploderBuilderMap filterKey(@Nullable Predicate<String> a)
      Set a custom filter predicate for map keys. Only entries whose key matches the filter will be included.
      Parameters:
      a - The key filter predicate. May be null to include all keys.
      Returns:
      this for chaining
    • filterValueNonEmpty

      public @NonNull StringImplode.ImploderBuilderMap filterValueNonEmpty()
      Set the value filter to only include entries with non-null and non-empty values.
      Returns:
      this for chaining
    • filterValue

      public @NonNull StringImplode.ImploderBuilderMap filterValue(@Nullable Predicate<String> a)
      Set a custom filter predicate for map values. Only entries whose value matches the filter will be included.
      Parameters:
      a - The value filter predicate. May be null to include all values.
      Returns:
      this for chaining
    • build

      public @NonNull String build()
      Build the imploded string from the configured source map, separators, and filters.
      Specified by:
      build in interface IBuilder<String>
      Returns:
      The imploded string. Never null.