Class IterableStringMapper

  • All Implemented Interfaces:
    IValueMapper

    public class IterableStringMapper
    extends java.lang.Object
    implements IValueMapper
    The iterable string mapper can be used to map an object that can be iterated over (e.g. collection, array, enumeration, ...) to a string with definable delimiter (e.g. ","). In addition a prefix and postfix can be given which are pre- and postpended to the string. A submapper can be used to handle more complex cases in a recursive way. For each element the submapper is invoked so that e.g. multidimensional arrays can be processed.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String delim
      The delimiter.
      protected java.lang.String postfix
      The string postfix.
      protected java.lang.String prefix
      The string prefix,
      protected IValueMapper submapper
      The optional submapper.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object convertValue​(java.lang.Object value)
      Convert the given value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • delim

        protected java.lang.String delim
        The delimiter.
      • prefix

        protected java.lang.String prefix
        The string prefix,
      • postfix

        protected java.lang.String postfix
        The string postfix.
      • submapper

        protected IValueMapper submapper
        The optional submapper.
    • Constructor Detail

      • IterableStringMapper

        public IterableStringMapper()
        Create a new string mapper.
      • IterableStringMapper

        public IterableStringMapper​(java.lang.String delim)
        Create a new string mapper.
        Parameters:
        delim - The delimiter that is placed between elements.
      • IterableStringMapper

        public IterableStringMapper​(java.lang.String delim,
                                    IValueMapper submapper)
        Create a new string mapper.
        Parameters:
        delim - The delimiter that is placed between elements.
        submapper - The submapper that will be invoked for each element.
      • IterableStringMapper

        public IterableStringMapper​(java.lang.String prefix,
                                    java.lang.String delim)
        Create a new string mapper.
        Parameters:
        prefix - The prefix for the result string.
        delim - The delimiter that is placed between elements.
      • IterableStringMapper

        public IterableStringMapper​(java.lang.String prefix,
                                    java.lang.String delim,
                                    java.lang.String postfix)
        Create a new string mapper.
        Parameters:
        prefix - The prefix for the result string.
        delim - The delimiter that is placed between elements.
        postfix - The postfix for the result string.
      • IterableStringMapper

        public IterableStringMapper​(java.lang.String prefix,
                                    java.lang.String delim,
                                    java.lang.String postfix,
                                    IValueMapper submapper)
        Create a new string mapper.
        Parameters:
        prefix - The prefix for the result string.
        delim - The delimiter that is placed between elements.
        postfix - The postfix for the result string.
        submapper - The submapper that will be invoked for each element.
    • Method Detail

      • convertValue

        public java.lang.Object convertValue​(java.lang.Object value)
                                      throws java.lang.Exception
        Convert the given value.
        Specified by:
        convertValue in interface IValueMapper
        Parameters:
        value - The value to convert.
        Returns:
        The converted value.
        Throws:
        java.lang.Exception