- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
abstract class GovnoPapa{
private final Map<String, Object> properties = new HashMap<>();
protected abstract void fillProperties(Map<String, Object> properties2);
public Map<String, Object> getProperties() {
if (this.properties.size() == 0) {
fillProperties(this.properties);
}
return this.properties;
}
public void method do(){
Map<String, Object> props = getProperties();
do1(props);
do2();
}
private void do1(Map<String, Object> props){
... do smth with props ..
}
private void do2(){
Map<String, Object> props = getProperties();
... do smth with props ..
}
}
class Child extends GovnoPapa{
protected abstract void fillProperties(Map<String, Object> properties2){
properties2.put("prop1", "smth1");
properties2.put("prop2", "smth2");
}
}
class App{
public static void main(String[] args) {
new Child().do();
}
}