|
When creating a builder for a given object, i.e. "NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder(nc)"
The ncBuilder will initialize its "augmentation" HashMap variable to be a SingletonMap when nc only has 1 augmentation.
However, I want to add augmentations onto ncBuilder using the "addAugmentation" method. Using the "addAugmentation" method will throw an UnsupportedOperationException because SingletonMap does not override AbstractMap's "put" method.
Here is an example of the NodeConnectorBuilder
if (base instanceof NodeConnectorImpl) {
NodeConnectorImpl _impl = (NodeConnectorImpl) base;
switch (_impl.augmentation.size())
{
case 0:
this.augmentation = Collections.emptyMap();
break;
case 1:
final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>> e = _impl.augmentation.entrySet().iterator().next();
this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector>>singletonMap(e.getKey(), e.getValue()); //this is where the problem lies
break;
default :
this.augmentation = new HashMap<>(_impl.augmentation);
}
}
The relevant file is BuilderTemplate.xtend
|