Uploaded image for project: 'ONOS'
  1. ONOS
  2. ONOS-5005

[YANG UTILS] Cannot use YO builder API to build YO

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.0
    • Component/s: None
    • Labels:
      None
    • Story Points:
      1

      Description

      From:Yixiao Chen
      To:Vidyashree Rama,Bharat Saraswal,VinodS Kumar,Gaurav agrawal,Janani B,Suchitra h n,
      Cc:Henry Yu,Aihuaguo (Aihua Guo, CRC),Hesam Rahimi,Patrick Liu,
      Date:2016-07-22 15:54:11
      Subject:RE: YangUtils function

      Any progress here? I think the issue and the solution should be very straight forward. It blocks me from building APP now.

      From: Yixiao Chen
      Sent: Thursday, July 21, 2016 4:11 PM
      To: Vidyashree Rama; Bharat Saraswal; VinodS Kumar; Gaurav agrawal; Janani B; Suchitra h n
      Cc: Henry Yu; Aihuaguo (Aihua Guo, CRC); Hesam Rahimi; Patrick Liu
      Subject: RE: YangUtils function

      Hi team,

      I guess the Builder Pattern is trying to be followed here. Then the inner builder class must be “static”, and the outer class constructor should be “private”. You can see examples from the link below:
      http://stackoverflow.com/questions/5007355/builder-pattern-in-effective-java

      I believe the change should be simple, please make it available to us ASAP.

      Thanks,
      Yixiao

      From: Yixiao Chen
      Sent: Thursday, July 21, 2016 3:14 PM
      To: Vidyashree Rama; Bharat Saraswal; VinodS Kumar; Gaurav agrawal; Janani B; Suchitra h n
      Cc: Henry Yu; Aihuaguo (Aihua Guo, CRC); Hesam Rahimi; Patrick Liu
      Subject: RE: YangUtils function
      Importance: High

      Hello guys,

      Today I tried to use the Yang generated code to build a Yang Object, but I am not able to (not a Java expert ). Let’s use ietf-network.yang as an example:

      The Yang generated file IetfNetwork.java has an outer interface “IetfNetwork” and an inner interface “IetfNetworkBuilder”, the interface implementation file DefaultIetfNetwork.java has an outer class “DefaultIetfNetwork” and an inner class “IetfNetworkBuilder”:
       Outer class “DefaultIetfNetwork” implements interface “IetfNetwork”, but it only has one constructor which using the inner class “IetfNetworkBuilder” as its sole parameter.
       Inner class “IetfNetworkBuilder” implements inner interface “IetfNetworkBuilder” to build a DefaultIetfNetwork object.

      Now in my application code, I am not able to new/build a “DefaultIetfNetwork” object. Questions for you:
       I believe class “IetfNetworkBuilder” is to be used by APP to build a “IetfNetwork” object, why is it an inner class? If it is an inner class, APP has to have an outer class DefaultIetfNetwork object first in order to have a new inner class object.
       Now I am not able to new the outer class DefaultIetfNetwork since it doesn’t have a default constructor.
       Even if there is a default constructor DefaultIetfNetwork() which doesn’t need any parameter, user has to new the outer class first, then uses the outer object to new the inner class, at last uses the inner object to build the second outer object. Is it weird?

      Can you let me know what I am missing? Did anybody use yangUtil to build an APP before? I am a little confused here.

      Thanks,
      Yixiao

        Attachments

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

          Activity

            People

            Assignee:
            bsaraswal bharat saraswal
            Reporter:
            hyu2010 Henry Yu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: