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

Sanititize bits type mapping

XMLWordPrintable

    • Evolve bits mapping

      We map a "bits" type to a dedicated TypeObject. We already have a ScalarTypeObject specialization which has getValue() method.
      Examining the generated code for a , it creates this atrocity:

          public static MyBits getDefaultInstance(final String defaultValue) {
              List<String> properties = Lists.newArrayList("bitOne",
              "bitTwo",
              "bitZero"
              );
              if (!properties.contains(defaultValue)) {
                  throw new IllegalArgumentException("invalid default parameter");
              }
              int i = 0;
              return new MyBits(
              properties.get(i++).equals(defaultValue) ? Boolean.TRUE : null,
              properties.get(i++).equals(defaultValue) ? Boolean.TRUE : null,
              properties.get(i++).equals(defaultValue) ? Boolean.TRUE : null
              );
          }
      

      There are so many things wrong in this mapping it's not even funny. Let's evolve this thing into something sane in terms of interface modeling, implementation design as well as interactions with runtime.

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

              Created:
              Updated: