PMD :the method has cyclomatic complexity 10. What is the alternative or is it fine?
<p>This method invokes different validation methods for every textfield in a form and the int[] array in the Map decides which methods or what type of validations is to be done on a textfield. But this method has cyclomatic complexity of 10. Please suggest any better alternatives or what can be done to improve this code ?</p>

<pre><code>public final boolean validateFields(final HashMap&lt;JTextField, int[]&gt; textFieldMap) {
        boolean flag = false;
        for (Map.Entry&lt;JTextField, int[]&gt; entry : textFieldMap.entrySet()) {
            JTextField field = entry.getKey();
            for (int constant : entry.getValue()) {
                switch (constant) {
                    case Constants.VAL_CHAR : flag = validateChar();
                        break;
                    case Constants.VAL_DATE : flag = validateDate();
                        break;
                    case Constants.VAL_DUPLICATE : flag = validateDuplicate();
                        break;
                    case Constants.VAL_EMAIL : flag = validateEmail();
                        break;
                    case Constants.VAL_LENGTH : flag = validateLength();
                        break;
                    case Constants.VAL_NUMERIC : flag = validateNumeric();
                        break;
                    case Constants.VAL_STRING : flag = validateNumeric();
                        break;
                    default : flag = validateNotNull();
                        break;
                }
            }
        }
        return flag;
    }
</code></pre>
