View Javadoc

    1   package net.sourceforge.pmd;
    2
    3   import java.util.Map;
    4
    5   import net.sourceforge.pmd.util.CollectionUtil;
    6
    7   /***
    8    * Mapping of SourceType to RuleLanguage.
    9    *
    10   * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
    11   */
    12  public class SourceTypeToRuleLanguageMapper {
    13      /***
    14       * Map of SourceType on RuleLanguage.
    15       */
    16      private static Map mapSourceTypeOnRuleLanguage = CollectionUtil.mapFrom( new Object[][] {
    17      	{ SourceType.JAVA_13, Language.JAVA },
    18  		{ SourceType.JAVA_14, Language.JAVA },
    19  		{ SourceType.JAVA_15, Language.JAVA },
    20  		{ SourceType.JAVA_16, Language.JAVA },
    21  		{ SourceType.JSP, Language.JSP },
    22      	});
    23
    24      private SourceTypeToRuleLanguageMapper() {};
    25      /***
    26       * Get the RuleLanguage that corresponds to the given SourceType.
    27       *
    28       * @param sourceType the SourceType
    29       * @return a RuleLanguage
    30       */
    31      public static Language getMappedLanguage(SourceType sourceType) {
    32          return (Language) mapSourceTypeOnRuleLanguage.get(sourceType);
    33      }
    34  }