i need to create objects following an sequence of rules
public class MyClass {
private Double field1;
private Integer field2;
private Double fiels3;
//getters setters
}
I need to calculate first field1:
MyClass object = new MyClass();
object.setField1(OtherClass.calculateField1(parameter1, parameter2, parameter3));
Than calculate field2, but field1 must be calculated before, because to calculate the second field2 need field1 to be done:
MyClass object = new MyClass();
object.setField1(OtherClass.getField2(object, parameter4, parameter5));
For set field3 i need the field2 and field1 calculated, and so on
How force who is creating the object MyClass to follow this sequence o creation? A Chain of resposability can help me?
Aucun commentaire:
Enregistrer un commentaire