private and protected fields
I think a lot of fields should be visible by its child class. For example: We have AbstractRandomDataProviderStrategy with private field typeManufacturers I would like to add new typeManufacturer depends on field name. When field name match i want use my custom manufacturer, but if not use the default. In this situation I have not possibility to get typeManufacturers in implementation which extends this abstract class.
Hi,
This is breaking the data encapsulation. To achieve what you want you should inherit from the default type manufacturer
@Override
public String getType(DataProviderStrategy strategy,
AttributeMetadata attributeMetadata,
ManufacturingContext manufacturingCtx) {
if ("myAttr".equals(attributeMetadata.getAttributeName())) {
String retValue;
/* Customization here */
...
return retValue;
} else {
return super.getType(strategy, attributeMetadata, manufacturingCtx);
}
}
and then just replace default manufacturer with custom one
dataProviderStrategy.addOrReplaceTypeManufacturer(String.class, customManufacturer);
Thanks, Daniil
Let me know, if there is a need for clarification.
Thanks, Daniil
Yes of course. But for me this encapsulation is too strictly. It is abstract class only. I wanted do this, because of standard implementation is generally ok as concept, but attribute strategies are not working there.