Class StringCompositor

  • All Implemented Interfaces:
    ValuesBinder<StringCompositor,​java.lang.String>

    public class StringCompositor
    extends java.lang.Object
    implements ValuesBinder<StringCompositor,​java.lang.String>
    StringCompositor provides a way to build strings from a string template and provided values.

    The template is simply an array of string values, where odd indices represent token positions, and even indices represent literals. This version of the StringCompositor fetches data from the bindings only for the named fields in the template.

    • Constructor Summary

      Constructors 
      Constructor Description
      StringCompositor​(java.lang.String template)
      Create a string template which has positional tokens, in "{}" form.
      StringCompositor​(java.lang.String template, java.util.function.Function<java.lang.Object,​java.lang.String> stringfunc)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String bindValues​(StringCompositor context, Bindings bindings, long cycle)
      Using context instance of type S, AKA the template, create and bind values to target object of type R
      java.util.List<java.lang.String> getBindPointNames()  
      protected java.lang.String[] parseTemplate​(java.lang.String template)  
      • Methods inherited from class java.lang.Object

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

      • StringCompositor

        public StringCompositor​(java.lang.String template)
        Create a string template which has positional tokens, in "{}" form.
        Parameters:
        template - The string template
      • StringCompositor

        public StringCompositor​(java.lang.String template,
                                java.util.function.Function<java.lang.Object,​java.lang.String> stringfunc)
    • Method Detail

      • parseTemplate

        protected java.lang.String[] parseTemplate​(java.lang.String template)
      • bindValues

        public java.lang.String bindValues​(StringCompositor context,
                                           Bindings bindings,
                                           long cycle)
        Description copied from interface: ValuesBinder
        Using context instance of type S, AKA the template, create and bind values to target object of type R
        Specified by:
        bindValues in interface ValuesBinder<StringCompositor,​java.lang.String>
        Parameters:
        context - A context object that knows how to provide an instance of type R
        bindings - A Bindings instance from which to draw the values
        cycle - The cycle for which to generate the values
        Returns:
        The new result instance of R
      • getBindPointNames

        public java.util.List<java.lang.String> getBindPointNames()