Package com.helger.base.string
Class StringImplode.ImploderBuilderMap
java.lang.Object
com.helger.base.string.StringImplode.ImploderBuilderMap
- Enclosing class:
StringImplode
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull Stringbuild()Build the imploded string from the configured source map, separators, and filters.@NonNull StringImplode.ImploderBuilderMapSet a custom filter predicate for map keys.@NonNull StringImplode.ImploderBuilderMapSet the key filter to only include entries with non-nulland non-empty keys.@NonNull StringImplode.ImploderBuilderMapfilterValue(@Nullable Predicate<String> a) Set a custom filter predicate for map values.@NonNull StringImplode.ImploderBuilderMapSet the value filter to only include entries with non-nulland non-empty values.@NonNull StringImplode.ImploderBuilderMapseparatorInner(char c) Set the inner separator character used between key and value within each entry.@NonNull StringImplode.ImploderBuilderMapseparatorInner(@Nullable String s) Set the inner separator string used between key and value within each entry.@NonNull StringImplode.ImploderBuilderMapseparatorOuter(char c) Set the outer separator character used between map entries.@NonNull StringImplode.ImploderBuilderMapseparatorOuter(@Nullable String s) Set the outer separator string used between map entries.@NonNull StringImplode.ImploderBuilderMapSet the source map, converting keys and values to strings viaObject.toString().<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.
-
Constructor Details
-
ImploderBuilderMap
public ImploderBuilderMap()Constructor.
-
-
Method Details
-
source
Set the source map, converting keys and values to strings viaObject.toString().- Parameters:
a- The source map. May benull.- 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 mapV- The value type of the source map- Parameters:
a- The source map. May benull.aKeyMapper- The mapping function for keys. May not benull.aValueMapper- The mapping function for values. May not benull.- Returns:
- this for chaining
-
separatorOuter
Set the outer separator character used between map entries.- Parameters:
c- The outer separator character.- Returns:
- this for chaining
-
separatorOuter
Set the outer separator string used between map entries.- Parameters:
s- The outer separator string. May benull.- Returns:
- this for chaining
-
separatorInner
Set the inner separator character used between key and value within each entry.- Parameters:
c- The inner separator character.- Returns:
- this for chaining
-
separatorInner
Set the inner separator string used between key and value within each entry.- Parameters:
s- The inner separator string. May benull.- Returns:
- this for chaining
-
filterKeyNonEmpty
Set the key filter to only include entries with non-nulland non-empty keys.- Returns:
- this for chaining
-
filterKey
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 benullto include all keys.- Returns:
- this for chaining
-
filterValueNonEmpty
Set the value filter to only include entries with non-nulland non-empty values.- Returns:
- this for chaining
-
filterValue
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 benullto include all values.- Returns:
- this for chaining
-
build
Build the imploded string from the configured source map, separators, and filters.
-