Uploaded image for project: 'vpp'
  1. vpp
  2. VPP-1153

Add support for Java enum generation

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Medium Medium
    • None
    • None
    • Java API binding
    • None

      VPP API supports enums since introduction of new vppapigen:

      https://gerrit.fd.io/r/#/c/8781/23

       

      JVPP generation needs to be refactored first.

      Either VPP-480 or vppapigen plugin (https://gerrit.fd.io/r/#/c/8781/).

       

      Proposed template:

      enum_template = Template("""
      package $plugin_package.$type_package;
      
      /**
       * <p>This class represents $enum_name enum definition.
       * <br>It was generated by enum_gen.py based on $inputfile preparsed data:
       * <pre>
      $docs
       * </pre>
       */
      public enum $java_enum_name \{
      $fields
      
          public final $value_type value;
      
          $java_enum_name(final $value_type value) \{
              this.value = value;
          }
          
          public static $java_enum_name forValue(final $value_type value) \{
              for ($java_enum_name enumeration : $java_enum_name.values()) \{
                  if (value == enumeration.value) \{
                      return enumeration;
                  }
              }
              return null;
          }
      }
      

            mgradzki Marek Gradzki
            mgradzki Marek Gradzki
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: