From d6958ab27c48017e5b4a6fced8bb218aff4f31d0 Mon Sep 17 00:00:00 2001 From: chenyiqin <83362909+Daydreamer-ia@users.noreply.github.com> Date: Tue, 11 Jul 2023 17:15:52 +0800 Subject: [PATCH] Correct comment and add description for AbilityKey (#10760) * correct the comments * correct the comments and add description field for AbilityKey. --- .../api/ability/constant/AbilityKey.java | 28 +++++++++++-------- .../register/impl/ClientAbilities.java | 7 ++--- .../register/impl/ServerAbilities.java | 7 ++--- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityKey.java b/api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityKey.java index d78de35d3..a6d3d691a 100644 --- a/api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityKey.java +++ b/api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityKey.java @@ -29,29 +29,33 @@ import java.util.stream.Collectors; * @date 2022/8/31 12:27 **/ public enum AbilityKey { - - /**. - * just for junit test - */ - TEST_1("test_1"), - - /**. - * just for junit test - */ - TEST_2("test_2"); + + TEST_1("test_1", "just for junit test"), + + TEST_2("test_2", "just for junit test"); /**. * the name of a certain ability */ private final String keyName; - - AbilityKey(String name) { + + /** + * description or comment about this ability. + */ + private final String description; + + AbilityKey(String name, String description) { this.keyName = name; + this.description = description; } public String getName() { return keyName; } + + public String getDescription() { + return description; + } /**. * All key set diff --git a/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ClientAbilities.java b/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ClientAbilities.java index 533f4ecdd..669bd2ab3 100644 --- a/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ClientAbilities.java +++ b/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ClientAbilities.java @@ -37,11 +37,10 @@ public class ClientAbilities extends AbstractAbilityRegistry { * The key is from

AbilityKey

, the value is whether turn on. * * You can add a new public field in

AbilityKey

like: - * DATA_COMPRESSION("compression", 1) - * This field can be used outside, and the offset should be unique. + * DATA_COMPRESSION("compression", "description about this ability") * - * And then you need to declare the offset of the flag bit of this ability in the ability table, you can: - * supportedAbilities.put(AbilityKey.DATA_COMPRESSION, true); means that is the first bit from left to right in the table. + * And then you need to declare whether turn on in the ability table, you can: + * supportedAbilities.put(AbilityKey.DATA_COMPRESSION, true); means that current client support compression. * */ // put ability here, which you want current client supports diff --git a/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ServerAbilities.java b/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ServerAbilities.java index ca4597a4f..456b9f906 100644 --- a/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ServerAbilities.java +++ b/api/src/main/java/com/alibaba/nacos/api/ability/register/impl/ServerAbilities.java @@ -37,11 +37,10 @@ public class ServerAbilities extends AbstractAbilityRegistry { * The key is from

AbilityKey

, the value is whether turn on. * * You can add a new public field in

AbilityKey

like: - * DATA_COMPRESSION("compression", 1) - * This field can be used outside, and the offset should be unique. + * DATA_COMPRESSION("compression", "description about this ability") * - * And then you need to declare the offset of the flag bit of this ability in the ability table, you can: - * supportedAbilities.put(AbilityKey.DATA_COMPRESSION, true); means that is the first bit from left to right in the table. + * And then you need to declare whether turn on in the ability table, you can: + * supportedAbilities.put(AbilityKey.DATA_COMPRESSION, true); means that current client support compression. * */ // put ability here, which you want current server supports