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<SourceType, Language> mapSourceTypeOnRuleLanguage = CollectionUtil.mapFrom(
17              new SourceType[] { SourceType.JAVA_13, SourceType.JAVA_14,
18                      SourceType.JAVA_15, SourceType.JAVA_16, SourceType.JAVA_17, SourceType.JSP, },
19              new Language[] { Language.JAVA, Language.JAVA, Language.JAVA,
20                      Language.JAVA, Language.JAVA, Language.JSP, });
21  
22      private SourceTypeToRuleLanguageMapper() {};
23      /**
24       * Get the RuleLanguage that corresponds to the given SourceType.
25       * 
26       * @param sourceType
27       *            the SourceType
28       * @return a RuleLanguage
29       */
30      public static Language getMappedLanguage(SourceType sourceType) {
31          return mapSourceTypeOnRuleLanguage.get(sourceType);
32      }
33  }