60 lines
1.1 KiB
Java
60 lines
1.1 KiB
Java
package com.senmesh.sfile.constant;
|
||
|
||
/**
|
||
* 文件位置枚举
|
||
*/
|
||
public enum FileLocationEnum {
|
||
|
||
/**
|
||
* 内网
|
||
*/
|
||
INTERNAL("1", "内网"),
|
||
|
||
/**
|
||
* 外网
|
||
*/
|
||
EXTERNAL("2", "外网");
|
||
|
||
private final String location;
|
||
private final String desc;
|
||
|
||
FileLocationEnum(String location, String desc) {
|
||
this.location = location;
|
||
this.desc = desc;
|
||
}
|
||
|
||
public String getLocation() {
|
||
return location;
|
||
}
|
||
|
||
public String getDesc() {
|
||
return desc;
|
||
}
|
||
|
||
/**
|
||
* 根据位置获取枚举
|
||
*
|
||
* @param location 位置
|
||
* @return FileLocationEnum
|
||
*/
|
||
public static FileLocationEnum getByLocation(String location) {
|
||
for (FileLocationEnum fileLocationEnum : FileLocationEnum.values()) {
|
||
if (fileLocationEnum.getLocation().equals(location)) {
|
||
return fileLocationEnum;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 判断是否为内网
|
||
*
|
||
* @param location 位置
|
||
* @return true-内网,false-外网
|
||
*/
|
||
public static boolean isInternal(String location) {
|
||
return INTERNAL.getLocation().equals(location);
|
||
}
|
||
}
|
||
|