Is there a way or design pattern to add supporting information to the existing java object?
Example I have a model class Parent and it has child models. Its nothing but hibernate entities with parent-child hierarchy. The parent class object is being pass through multiple Java business rules class. I would like to add supporting information (might be DTO/VO) to the parent object which will be used in all business rules and also if any business validation errors during business logic it can be added to supporting information object.
Is there a better design to achieve this? Is it good to have a Context object which will be shared across? or better to add non persistent DTO/VO object to parent persistent object?
Class Product {
Set<Category> categories;
...
...
}
Class ProductProcessing1{
void process(Product p) {
}
}
Class ProductProcessing2{
void process(Product p) {
}
}
All hibernate models are part of separate project called project-model and application is using that jar in class path. I would like to implement logic in Product processing rules for some specific products without altering product in project-model. Product specific supporting information should be carried over to all the processing rules. Project has more than 100 processing rules of validations. Also i would like to accumulate errors in each rules and save all of them at the end.