From df871b03502300fc967837212f742c548730d2bb Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 4 Mar 2021 11:56:02 +0800 Subject: [PATCH] Simplify enums: reuse enum name and remove unnecessary code (#2032) --- .../com/alibaba/csp/sentinel/EntryType.java | 19 +++---------------- .../sentinel/transport/endpoint/Protocol.java | 13 ++++--------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java index 311a8a4d..0c116f77 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java @@ -19,29 +19,16 @@ package com.alibaba.csp.sentinel; * An enum marks resource invocation direction. * * @author jialiang.linjl + * @author Yanming Zhou */ public enum EntryType { /** * Inbound traffic */ - IN("IN"), + IN, /** * Outbound traffic */ - OUT("OUT"); + OUT; - private final String name; - - EntryType(String s) { - name = s; - } - - public boolean equalsName(String otherName) { - return name.equals(otherName); - } - - @Override - public String toString() { - return name; - } } diff --git a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java index 5a635099..a0d89eee 100644 --- a/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java +++ b/sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java @@ -2,18 +2,13 @@ package com.alibaba.csp.sentinel.transport.endpoint; /** * @author Leo Li + * @author Yanming Zhou */ public enum Protocol { - HTTP("http"), - HTTPS("https"); - - private String protocol; - - Protocol(String protocol) { - this.protocol = protocol; - } + HTTP, + HTTPS; public String getProtocol() { - return protocol; + return name().toLowerCase(); } }