[YANGTOOLS-389] Binding DTOs: enums have inefficient forValue() implementation Created: 10/Dec/14  Updated: 10/Apr/22  Resolved: 15/Dec/14

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 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


 Comments   
Comment by Robert Varga [ 10/Dec/14 ]

https://git.opendaylight.org/gerrit/13532

Generated at Wed Feb 07 20:53:06 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.