vendredi 7 décembre 2018

set a property to subclass builder class in Java

I have one parent class builder 'bridgeDomainPojo' which has few sub class builders. when I'm trying to set one sub class builder to parent class builder. After setting the sub class builder when I build the parent class the sub class builder is not updated as part of parent class builder.

DiscoveryInformation.Builder disBuilder = new DiscoveryInformation.Builder(bridgeDomainPojo.getBridgeDomainInfo().getBridgeVfiList().iterator().next().discoveryInformationBuilder());

initially the .discoveryInformationBuilder() value will be null in the parent builder, If it is null it will create a return a new DiscoveryInformation object

disBuilder.setVpnId(updatedVpnId).build();

For newly created object, I'm setting the one attribute.

   BridgeDomain.Builder lBdBuilder = new BridgeDomain.Builder(bridgeDomainPojo);
    bridgeDomainList.add(lBdBuilder.build());

After that I'm creating a new builder for parent class and building the same. But after that also .discoveryInformationBuilder() builder value is not updated in the parent builder.

Is there any other alternate way to update the same

Aucun commentaire:

Enregistrer un commentaire