Skip to content

Instantly share code, notes, and snippets.

@lihongjie0209
Created May 25, 2018 10:37
Show Gist options
  • Save lihongjie0209/38ae3a2c5bd20b5898948cf4057fa1fd to your computer and use it in GitHub Desktop.
Save lihongjie0209/38ae3a2c5bd20b5898948cf4057fa1fd to your computer and use it in GitHub Desktop.
public enum PollutantCodeEnum {
PM10("001"),
SO2("002"),
NO2("005"),
CO("006"),
O3("007"),
PM25("022"),
Unknown("");
private String code;
PollutantCodeEnum(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public static PollutantCodeEnum of(String code) {
if (Strings.isNullOrEmpty(code)) {
return Unknown;
} else if (code.equalsIgnoreCase("001")) {
return PM10;
} else if (code.equalsIgnoreCase("002")) {
return SO2;
} else if (code.equalsIgnoreCase("005")) {
return NO2;
} else if (code.equalsIgnoreCase("006")) {
return CO;
} else if (code.equalsIgnoreCase("007")) {
return O3;
} else if (code.equalsIgnoreCase("022")) {
return PM25;
} else {
return Unknown;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment