some comments ALTO code


chenguohai
 

Hi folks,

 

I am reading the code under ALTO@ODL. And here are my two comments.

 

1:File named AltoProviderImplBuilderunder alto-provider/……./modules/module/configuration  :in function named  'toString',first is defined to judge a common should be inserted, i recommend writting as following

        @Override

        public java.lang.String toString() {

            java.lang.StringBuilder builder = new java.lang.StringBuilder ("AltoProviderImpl [");

            //boolean first = true;

       

            if (_dataBroker != null) {

                //if (first) {

                //    first = false;

                //} else {

                //    builder.append(", ");

                //}

                builder.append("_dataBroker=");

                builder.append(_dataBroker);

                builder.append(", ");//new added

 

             }

            if (_rpcRegistry != null) {

                //if (first) {

                //    first = false;

                //} else {

                //    builder.append(", ");

                //}

                builder.append("_rpcRegistry=");

                builder.append(_rpcRegistry);

                builder.append(", ");//new added

 

             }

            //if (first) {

            //    first = false;

            //} else {

            //    builder.append(", ");

            //}

            builder.append("augmentation=");

            builder.append(augmentation.values());

            return builder.append(']').toString();

        }

    }

Fewer judgement, fewer jumpes and simplified, consistent code,Make sense.

There are similar something in file named RpcRegistryBuilder.java under alto-provider/……../modules/module/configuration/alto/provider/impl

 

2:  File named YangModuleInfoImpl line36 there are duplicated something between $YangModuleInfoImpl method(line 30 to line 33) and getModuleSourceStream.YangModuleInfoImpl can call getModuleSourceStream to get a stream.

 

    private $YangModuleInfoImpl() {

        Set<YangModuleInfo> set = new HashSet<>();

        set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.rev131028.$YangModuleInfoImpl.getInstance());

        set.add(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.$YangModuleInfoImpl.getInstance());

        set.add(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.rpc.context.rev130617.$YangModuleInfoImpl.getInstance());

        importedModules = ImmutableSet.copyOf(set);

   

        //InputStream stream = $YangModuleInfoImpl.class.getResourceAsStream(resourcePath);

        //if (stream == null) {

        //    throw new IllegalStateException("Resource '" + resourcePath + "' is missing");

        //}

        InputStream stream = getModuleSourceStream ();// new added one

        try {

            stream.close();

        } catch (IOException e) {

        // Resource leak, but there is nothing we can do

        }

}

 

BR

Robert

-------------------------------------------------------------------------------------------------------------------------------------

Chen Guohai (Robert), 陈国海. Network Research Department, Huawei Technologies Co., Ltd. Telephone: 0086-25-56624606;

华为技术有限公司 ,地址:深圳市龙岗区坂田华为基地 邮编:518129 http://www.huawei.com

-------------------------------------------------------------------------------------------------------------------------------------

本邮件及其附件含有华为公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件!

This e-mail and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the  information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!

----------------------------------------------------------------------------------------------------------------------------------------

 

Join z.archive.alto-dev@lists.opendaylight.org to automatically receive all group messages.