Generic use of 2 same classes but from different packages

Viewed 235

I have two same model classes,but they are in different packages. First one is: model.my.prod.Model and second model.my.test.Model

I have also a simple mapper for this model.my.prod.Model which take a Model class as a parameter:

public class Mapper{

    private static Map<Model, String> models= new HashMap<>();

    static {
        models.put(Model.IMAGE_JPG, MediaType.IMAGE_JPEG_VALUE);
        models.put(Model.IMAGE_GIF, MediaType.IMAGE_GIF_VALUE);
    }

    public static String createModelMap(Model model) {
        if (models.containsKey(model)) {
            return models.get(model);
        } else {
            throw new ModelException("Exeception");
        }
    }
}

Now I would like to use this Mapper also for model.my.test.Model, is it possible without copy of this Mapper and change a Model package?

2 Answers
Related