cmccabe commented on code in PR #12036:
URL: https://github.com/apache/kafka/pull/12036#discussion_r848894276


##########
clients/src/main/java/org/apache/kafka/clients/admin/FeatureUpdate.java:
##########
@@ -23,33 +23,92 @@
  */
 public class FeatureUpdate {
     private final short maxVersionLevel;
-    private final boolean allowDowngrade;
+    private final DowngradeType downgradeType;
+
+    public enum DowngradeType {
+        NONE(0),
+        SAFE(1),
+        UNSAFE(2);
+
+        private final byte code;
+
+        DowngradeType(int code) {
+            this.code = (byte) code;
+        }
+
+        public byte code() {
+            return code;
+        }
+
+        public static DowngradeType fromCode(int code) {
+            if (code == 0) {
+                return NONE;
+            } else if (code == 1) {
+                return SAFE;
+            } else if (code == 2) {
+                return UNSAFE;
+            } else {
+                throw new IllegalArgumentException("No downgrade type for code 
" + code);
+            }
+        }
+    }
 
     /**
      * @param maxVersionLevel   the new maximum version level for the 
finalized feature.
      *                          a value < 1 is special and indicates that 
the update is intended to
      *                          delete the finalized feature, and should be 
accompanied by setting
      *                          the allowDowngrade flag to true.
      * @param allowDowngrade    - true, if this feature update was meant to 
downgrade the existing
-     *                            maximum version level of the finalized 
feature.
+     *                            maximum version level of the finalized 
feature. Only "safe" downgrades are
+     *                            enabled with this boolean. See {@link 
FeatureUpdate#FeatureUpdate(short, DowngradeType)}
      *                          - false, otherwise.
      */
+    @Deprecated
     public FeatureUpdate(final short maxVersionLevel, final boolean 
allowDowngrade) {

Review Comment:
   can we have this function call the non-deprecated one, to avoid repeating 
the same validation logic twice?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to