Вижу 2 варианта:
1) наследование
public class A {
private Object b;
public Object getB() {
return b;
}
}
public class A1 extends A {
}
public class A2 extends A {
}
public int calc(String data, A value, Boolean rez) {
value.getB();
}
2) Интерфейсы:
public interface I {
Object getC();
}
public class B implements I {
private Object c;
public Object getC() {
return c;
}
}
public class D implements I {
private Object c;
public Object getC() {
return c;
}
}
public int calc(String data, I value, Boolean rez) {
value.getC();
}