1 package net.sourceforge.pmd.sourcetypehandlers; 2 3 import java.util.Map ; 4 5 import net.sourceforge.pmd.SourceType; 6 import net.sourceforge.pmd.util.CollectionUtil; 7 8 13 public class SourceTypeHandlerBroker { 14 15 private static final Map mapSourceTypeOnSourceTypeHandler = CollectionUtil.mapFrom( new Object [][] { 16 { SourceType.JAVA_13, new Java13Handler()}, 17 { SourceType.JAVA_14, new Java14Handler()}, 18 { SourceType.JAVA_15, new Java15Handler()}, 19 { SourceType.JAVA_16, new Java16Handler()}, 20 { SourceType.JSP, new JspTypeHandler()}, 21 }); 22 23 26 private SourceTypeHandlerBroker() { } 27 28 public static SourceTypeHandler getVisitorsFactoryForSourceType(SourceType sourceType) { 29 SourceTypeHandler handler = (SourceTypeHandler) mapSourceTypeOnSourceTypeHandler.get(sourceType); 30 31 if (handler == null) { 32 throw new IllegalArgumentException ("No VisitorsFactory is registered for SourceType [" + sourceType + "]."); 33 } 34 return handler; 35 } 36 37 } 38 | Popular Tags |