Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-222

Builder should not use singleton map

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: Mac OS
      Platform: PC

    • 1407

    Description

      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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mvitez@cisco.com Martin Vitez
            railor33@gmail.com Alexander Fan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: