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

Binding DTOs: enums have inefficient forValue() implementation

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 2498

    Description

      YANG enumerations map to an enum, which has a forValue() method. This gets realized this way:

      public enum BgpOrigin {
      static java.util.Map<java.lang.Integer, BgpOrigin> valueMap;

      static {
      valueMap = new java.util.HashMap<>();
      for (BgpOrigin enumItem : BgpOrigin.values())

      { valueMap.put(enumItem.value, enumItem); }

      }

      public static BgpOrigin forValue(int valueArg)

      { return valueMap.get(valueArg); }

      }

      There are multiple things wrong here:

      • valueMap should be a proper constant
      • valueMap has wrong name, should be all capitals
      • valueMap should an ImmutableMap

      Attachments

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

        Activity

          People

            rovarga Robert Varga
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: