mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
use upstream method for creating enums from strings (#12158)
Co-authored-by: Daan Hoogland <dahn@apache.org>
This commit is contained in:
parent
db6147060b
commit
f3a112fd9e
@ -59,7 +59,7 @@ public class VTreeMigrationInfo {
|
||||
}
|
||||
|
||||
public void setMigrationStatus(String migrationStatus) {
|
||||
this.migrationStatus = EnumUtils.fromString(MigrationStatus.class, migrationStatus, MigrationStatus.None);
|
||||
this.migrationStatus = EnumUtils.getEnumIgnoreCase(MigrationStatus.class, migrationStatus, MigrationStatus.None);
|
||||
}
|
||||
|
||||
public void setMigrationStatus(MigrationStatus migrationStatus) {
|
||||
|
||||
@ -1767,7 +1767,7 @@ public class ApiDBUtils {
|
||||
return null;
|
||||
}
|
||||
String jobInstanceId = null;
|
||||
ApiCommandResourceType jobInstanceType = EnumUtils.fromString(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None);
|
||||
ApiCommandResourceType jobInstanceType = EnumUtils.getEnumIgnoreCase(ApiCommandResourceType.class, job.getInstanceType(), ApiCommandResourceType.None);
|
||||
|
||||
if (job.getInstanceId() == null) {
|
||||
// when assert is hit, implement 'getInstanceId' of BaseAsyncCmd and return appropriate instance id
|
||||
|
||||
@ -29,30 +29,4 @@ public class EnumUtils extends org.apache.commons.lang3.EnumUtils {
|
||||
b.append("]");
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> T fromString(Class<T> clz, String value, T defaultVal) {
|
||||
assert (clz != null);
|
||||
|
||||
if (value != null) {
|
||||
try {
|
||||
return Enum.valueOf(clz, value.trim());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
return defaultVal;
|
||||
}
|
||||
|
||||
public static <T extends Enum<T>> T fromString(Class<T> clz, String value) {
|
||||
assert (clz != null);
|
||||
|
||||
if (value != null) {
|
||||
try {
|
||||
return Enum.valueOf(clz, value.trim());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user