title: How does this normalize function work?
body: <p>I was doing a Junit tutorial and I came across this normalize function that was being tested. It was defined like this:</p>
  
  <pre><code> public static String normalizeWord(String word) {
          try {
              int i;
              Class&lt;?&gt; normalizerClass = Class.forName("java.text.Normalizer");
              Class&lt;?&gt; normalizerFormClass = null;
              Class&lt;?&gt;[] nestedClasses = normalizerClass.getDeclaredClasses();
              for (i = 0; i &lt; nestedClasses.length; i++) {
                  Class&lt;?&gt; nestedClass = nestedClasses[i];
                  if (nestedClass.getName().equals("java.text.Normalizer$Form")) {
                      normalizerFormClass = nestedClass;
                  }
              }
              assert normalizerFormClass.isEnum();
              Method methodNormalize = normalizerClass.getDeclaredMethod(
                                                              "normalize",
                                                              CharSequence.class,
                                                              normalizerFormClass);
              Object nfcNormalization = null;
              Object[] constants = normalizerFormClass.getEnumConstants();
              for (i = 0; i &lt; constants.length; i++) {
                  Object constant = constants[i];
                  if (constant.toString().equals("NFC")) {
                      nfcNormalization = constant;
                  }
              }
              return (String) methodNormalize.invoke(null, word, nfcNormalization);
          } catch (Exception ex) {
              return null;
          }
      }
  </code></pre>
  
  <p>How does this function work? What is it actually doing?</p>