I have an abstract class that contains a map variable, and for the subclasses that extend the abstract class, I want to initialize the map using different implementations.
For example:
public abstract class Abs() {
protected Map<Object, Object> map;
}
public class classA extends Abs {
public classA() {
map = new HashMap<>();
}
}
public class classB extends Abs {
public classB() {
map = new ConcurrentHashMap<>();
}
}
public class classC extends Abs {
public classC() {
map = new LinkedHashMap<>();
}
}
My question is: Is there a current design pattern for this kind of implementation? Also because in the abstract class, we do not initialize the map, is there any concerns for that?