Sfoglia il codice sorgente

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

master
Yanming Zhou GitHub 3 anni fa
parent
commit
df871b0350
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
2 ha cambiato i file con 7 aggiunte e 25 eliminazioni
  1. +3
    -16
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java
  2. +4
    -9
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java

+ 3
- 16
sentinel-core/src/main/java/com/alibaba/csp/sentinel/EntryType.java Vedi 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;
}
}

+ 4
- 9
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/transport/endpoint/Protocol.java Vedi 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();
}
}

Loading…
Annulla
Salva