Simplify enums: reuse enum name and remove unnecessary code (#2032)

This commit is contained in:
Yanming Zhou 2021-03-04 11:56:02 +08:00 committed by GitHub
parent 3755d53498
commit df871b0350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 25 deletions

View File

@ -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;
}
}

View File

@ -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();
}
}