title: How to pass an Arbitrary number of Parameterized Functions into constructor without compiler Warnings
body: <p>I have a <code>Test</code> class and a <code>Writer</code> class.</p>
  <p>The <code>Writer</code> class does nothing but writes a string to a <code>StringBuilder</code>, nothing more. It also is allowed to have <em>&quot;transformers&quot;</em>. Meaning, in the constructor of the <code>Writer</code> class, you can pass any number of <em>lambda functions</em> to add additional processing to a string you are writing.</p>
  <p>For example, like <code>String::toLowerCase</code>.</p>
  <p>I want to be able to pass multiple of these <em>&quot;transformers&quot;</em> into the constructor of the writer.</p>
  <p><em>I have the below code:</em></p>
  <pre><code>///Writer Class   Writer(Function&lt;String, String&gt;... someFunctions) {
  abstract class Writer {
    Function&lt;String, String&gt;[] functions;
  
    Writer(Function&lt;String, String&gt;... someFunctions) {
      functions = someFunctions;
    }
  
  }
  
  ///Test Class
      @Test
      default void WriterTestWriteThere() throws IOException {
          Writer writer = createWriter();
          writer.write(&quot;There&quot;);
          writer.close();
  
          assertEquals(&quot;There&quot;, getContents());
      }
  
      @Test
      default void WriterTestTwoTransformerFunctions() throws IOException {
          Writer writer = createWriter(
                  text -&gt; text.replaceAll(&quot;sometext&quot;, &quot;s*****&quot;),
                  String::toUpperCase
          );
          writer.write(&quot;This is somethext!&quot;);
          writer.close();
  
          assertEquals(&quot;THIS IS S*****!&quot;, getContents());
      }
  
  </code></pre>
  <p>However, the compiler issues <em><strong>multiple warnings</strong></em>.</p>
  <p><code>Possible heap pollution from parameterized vararg type</code> - error-message for the constructor of the <code>Writer</code> class.</p>
  <p><code>Unchecked generics array creation for varargs parameter</code>  - error-message for the <code>Test</code> class when the <code>Writer</code> instance is being created.</p>
  <p><strong>I cannot use @SafeVarargs or @SuppressWarnings</strong></p>
  <p>I have looked everywhere online, but cannot get a solid answer as to why these warnings are created, other than that the Java compiler does not like parameterized arguments being passed into a list. So, raises my question.</p>
  <p>What can I use to fix it?</p>
  <p>I need to be able to pass multiple functions into the writer class to transform the text as those functions want, and have no warnings. I have experimented with other Java utility classes other than Function, but I can't seem to find what I need.</p>