I have a constructor which gets a HashSet and a HashMap. I need to run a validation check on one hashMAp and combine it with the hashSet, as 'super' must receive only one hashSet.
I can't find a way to do it as I get following error: cannot reference this before supertype constructor
Example:
public class A extends B {
public A(HashSet<Obj> h1, HashMap<UID,Objects> m1) {
super(new C (h1) ); //h1 should contain changes related to m1..
}
I want to do something like that:
public class A extends B {
public A(HashSet<Obj> h1, HashMap<UID,Objects> m1) {
runMyFunc(h1,m1);
super(new C (h1) );
}
runMyFunc(HashSet<Obj> h1, HashMap<UID,Objects> m1){
//do checks
//more checks...
// if something then h1.setUid(m1.get(0))...
return h1;
}
I thought converting the constructor to private and then run it like that:
public class A extends B {
private A(HashSet<Obj> h1) {
super(new C (h1) );
}
public A(HashSet<Obj> h1, HashMap<UID,Objects> m1) {
runMyFunc(h1,m1);
this(h1);
}
but it also didn't work.
Can you please advice?