If a class Foo has a hashmap ie:
public class Foo {
private HashMap <String, Integer> fooMap;
//other foo methods
}
When encapsulating the fooMap, what are the circumstances by which the fooMap should have its methods wrapped as seen below:
public class Foo {
private HashMap<String, Integer> fooMap;
//other foo methods
public int getFoo(String s) {
return fooMap.get(s);
}
//other wrapper methods
}
or have the fooMap returned itself:
public class Foo {
private HashMap<String, Integer> fooMap;
//other foo methods
public HashMap<String, Integer> getFooMap() {
return fooMap;
}
}