📄 constants.java
字号:
package com.ejsun.entapps.util.workflow;
/**
* an util class
* @author Quake Wang
* @since 2004-3-30
* @version $Revision: 1.1 $
*
**/
public class Constants {
public static final String STEP_OWNER = "stepOwner";
public static final int OWNER_TYPE_USER = 1;
public static final int OWNER_TYPE_GROUP = 2;
public static final String OWNER_TYPE_USER_PREFIX = "USER:";
public static final String OWNER_TYPE_GROUP_PREFIX = "GROUP:";
public static long convertToUserId(String userOwner) {
return convertToId(userOwner, OWNER_TYPE_USER);
}
public static long convertToGroupId(String groupOwner) {
return convertToId(groupOwner, OWNER_TYPE_GROUP);
}
public static long convertToId(String owner, int type) {
switch (type) {
case OWNER_TYPE_USER :
return Long.parseLong(
owner.substring(OWNER_TYPE_USER_PREFIX.length()));
case OWNER_TYPE_GROUP :
return Long.parseLong(
owner.substring(OWNER_TYPE_GROUP_PREFIX.length()));
default :
throw new IllegalArgumentException("owner type error: " + type);
}
}
public static String convertToUserOwner(long userId) {
return convertToOwner(userId, OWNER_TYPE_USER);
}
public static String convertToGroupOwner(long groupId) {
return convertToOwner(groupId, OWNER_TYPE_GROUP);
}
public static String convertToOwner(long id, int type) {
switch (type) {
case OWNER_TYPE_USER :
return OWNER_TYPE_USER_PREFIX + id;
case OWNER_TYPE_GROUP :
return OWNER_TYPE_GROUP_PREFIX + id;
default :
throw new IllegalArgumentException("owner type error: " + type);
}
}
public static void main(String[] args) {
System.out.println(convertToUserOwner(1));
System.out.println(convertToUserId(convertToUserOwner(2)));
System.out.println(convertToGroupOwner(1));
System.out.println(convertToGroupId(convertToGroupOwner(2)));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -