mirror of
https://github.com/getrebuild/rebuild.git
synced 2025-02-25 23:05:06 +08:00
state ex
This commit is contained in:
parent
bda20178e4
commit
7f7ae3572a
3 changed files with 13 additions and 7 deletions
|
@ -40,7 +40,7 @@ public final class Lisence {
|
|||
String SN = SysConfiguration.get(ConfigurableItem.SN, true);
|
||||
if (SN == null) {
|
||||
SN = String.format("ZR%s%s-%s",
|
||||
"150",
|
||||
"105", // v1.5
|
||||
StringUtils.leftPad(Locale.getDefault().getCountry(), 3, "0"),
|
||||
UUID.randomUUID().toString().replace("-", "").substring(0, 15).toUpperCase());
|
||||
SysConfiguration.set(ConfigurableItem.SN, SN);
|
||||
|
|
|
@ -39,7 +39,11 @@ public class StateHelper {
|
|||
* @return
|
||||
*/
|
||||
public static boolean isStateClass(String clazzName) {
|
||||
return getSatetClass(clazzName) != null;
|
||||
try {
|
||||
return getSatetClass(clazzName) != null;
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +67,7 @@ public class StateHelper {
|
|||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static Class<?> getSatetClass(String stateClass) throws IllegalArgumentException {
|
||||
assert stateClass != null;
|
||||
Class<?> stateEnum = null;
|
||||
try {
|
||||
stateEnum = ClassUtils.getClass(stateClass);
|
||||
|
|
|
@ -80,15 +80,16 @@ public class DefaultValueHelper {
|
|||
&& field.getReferenceEntity().getEntityCode() == EntityHelper.PickList) {
|
||||
return PickListManager.instance.getDefaultItem(field);
|
||||
} else if (EasyMeta.getDisplayType(field) == DisplayType.STATE) {
|
||||
Class<?> stateClass = StateHelper.getSatetClass(field);
|
||||
if (stateClass == null) {
|
||||
Class<?> stateClass;
|
||||
try {
|
||||
stateClass = StateHelper.getSatetClass(field);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
LOG.error("Bad field: " + field, ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Object c : stateClass.getEnumConstants()) {
|
||||
if (((StateSpec) c).isDefault()) {
|
||||
return ((StateSpec) c).getState();
|
||||
}
|
||||
if (((StateSpec) c).isDefault()) return ((StateSpec) c).getState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue