41 lines
1023 B
Java
41 lines
1023 B
Java
package com.mzh.library.entity;
|
|
|
|
import java.util.Locale;
|
|
|
|
public enum ReaderStatus {
|
|
ACTIVE("active", "正常"),
|
|
SUSPENDED("suspended", "暂停"),
|
|
INACTIVE("inactive", "停用");
|
|
|
|
private final String code;
|
|
private final String displayName;
|
|
|
|
ReaderStatus(String code, String displayName) {
|
|
this.code = code;
|
|
this.displayName = displayName;
|
|
}
|
|
|
|
public String getCode() {
|
|
return code;
|
|
}
|
|
|
|
public String getDisplayName() {
|
|
return displayName;
|
|
}
|
|
|
|
public static ReaderStatus fromCode(String code) {
|
|
if (code == null || code.trim().isEmpty()) {
|
|
throw new IllegalArgumentException("Reader status is required");
|
|
}
|
|
|
|
String normalized = code.trim().toLowerCase(Locale.ROOT);
|
|
for (ReaderStatus status : values()) {
|
|
if (status.code.equals(normalized)) {
|
|
return status;
|
|
}
|
|
}
|
|
|
|
throw new IllegalArgumentException("Unsupported reader status: " + code);
|
|
}
|
|
}
|