title: Smart way to do if else in Java where the number of parameters is too big
body: <p>I am getting a parameter name as the input to my function which can be of type "Numeric" or "currency". Based on the type, I need to do some formatting before ultimately printing that in an excel file using Apache POI library. to check whether the received parameter belongs to either of the categories, I am doing the check like the following:</p>
  
  <pre><code>//Format the columns currency or numeric
      if (DcHandlerConstant.currencyColumnList().contains(String.valueOf(key))) {
          DecimalFormat df = new DecimalFormat("'$'0.00");
          df.setGroupingUsed(true);
          df.setGroupingSize(3);
          value = df.format(input);
      }
      if (DcHandlerConstant.numericColumnList().contains(String.valueOf(key))) {
          DecimalFormat df = new DecimalFormat("0.00");
          df.setGroupingUsed(true);
          df.setGroupingSize(3);
          value = df.format(input);
      }
  </code></pre>
  
  <p>where the lists contain the possible input name. I used it like this instead of hard-coding the value in the if clause because the number of parameters is too long, ATM it has 10 elements each and it is only going to increase further, we are expecting almost 20 in each list.</p>
  
  <p>But during the testing I observed that this <code>contains</code> method in the arraylist is taking an awful lot of time. Below is a snapshot from Visual VM:</p>
  
  <p><a href="https://i.stack.imgur.com/OirSu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OirSu.png" alt="VisualVM SS"></a></p>
  
  <p>So how can I use the intended functionality without using Arraylist? Will enum be a faster approach?</p>