Class Design : Parsers for different file type and ParserFactory I have come up with a class design for parsers (for xml,csv etc) and parser factory. I will be using it in my project.I will be configuring these as beans in the spring context file. I would like to get opinion on the class design.

public interface Parser&lt;T&gt; {
    String fileFormatSupported();
    List&lt;T&gt; parse(File file);
    boolean supports(Class&lt;?&gt; clazz);
    boolean validate(File file);
}
public abstract class AbstractCSVFileParser&lt;T&gt; implements Parser&lt;T&gt;{
    private static final String FILE_FORMAT = "csv";
    @Override
    public final String fileFormatSupported() {
        return FILE_FORMAT;
    }
}
public class CSVToDeviceportServer extends AbstractCSVFileParser&lt;DeviceportServer&gt; {
    @Override
    public boolean supports(Class&lt;?&gt; clazz) {
        return DeviceportServer.class.isAssignableFrom(clazz);
    }
    @Override
    public  List&lt;DeviceportServer&gt; parse(File file) { /* logic*/ }
    @Override
    public boolean validate(File file) { /* logic */  }
}
public class CSVToDeviceParser extends AbstractCSVFileParser&lt;Device&gt; {
    @Override
    public boolean supports(Class&lt;?&gt; clazz) {
        return Device.class.isAssignableFrom(clazz);
    }
    @Override
    public List&lt;Device&gt; parse(File file) {  /* logic */  }
    @Override
    public boolean validate(File file) { /* logic */ }
}
public class ParserFactory {
    @Autowired
    private List&lt;Parser&lt;?&gt;&gt; parsers;

    private Map&lt;String, List&lt;Parser&lt;?&gt;&gt;&gt; parserMap;

    public List&lt;Parser&lt;?&gt;&gt; getParsers() {
        return parsers;
    }
    @PostConstruct
    public void afterPropertiesSet() throws Exception{
        if(this.parsers == null) {
            throw new IllegalStateException("Parsers not initialized");
        }
        parserMap = new HashMap&lt;&gt;(2);
        for(Parser&lt;?&gt; parser : parsers) {
            if (parserMap.containsKey(parser.fileFormatSupported())) {
                parserMap.get(parser.fileFormatSupported()).add(parser);
            }else {
                List&lt;Parser&lt;?&gt;&gt; parserList = new ArrayList&lt;&gt;();
                parserList.add(parser);
                parserMap.put(parser.fileFormatSupported(), parserList);
            }
        }
    }
    public Parser&lt;?&gt; getParser(Class&lt;?&gt; clazz, String format) {
        for(Parser&lt;?&gt; parser : parserMap.get(format)) {
            if(parser.supports(clazz)) return parser;
        }
        throw new IllegalStateException("Could not find parser for the format");
    }
}


I'm adding parser classes only for the CSV type of files, but there are other types of parsers for xml, json. They will have same class design as the CSV file parsers.
The method Parser.fileFormatSupported looks great. Letting each parser declare which file types it can process allows for information hiding. Android uses the same style for deciding the "Which app can handle which file types?" question.
The method Parser.supports uses an inferior style. If you can, you should also switch to a declarative style by replacing this method with Set&lt;Class&lt;?&gt;&gt; getSupportedClasses(). Maybe you only need Class&lt;?&gt; getSupportedClass().
In the supports methods, you currently use isAssignableFrom. This looks wrong to me, since each of these parsers probably only supports exactly this one class. Therefore these methods should return clazz == Device.class.
The CSVToDeviceportServer class is missing the Parser in its name.
In the afterPropertiesSet method, you don't need to check for this.parsers == null. The code will fail in the for loop below. The chances of your custom exception being thrown are close to zero. And even if this.parsers were null, it would be very easy to see in the stack trace.
In the afterPropertiesSet method, you should use a Multimap (from Guava) instead of a HashMap of lists. This makes the code shorter and easier to understand.
Instead of the @PostConstruct method, you may think about having an @Autowired void setParsers(List&lt;Parser&gt; parsers) method that initializes everything. This method is easier to use in unit tests. This method should be package-private since it is not intended to be used by any other code.