mirror of https://github.com/apache/jclouds.git
enums to upper case, with camel conversion routines
This commit is contained in:
parent
6c42eb04a0
commit
077b3eb52d
|
@ -22,6 +22,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.VirtualMachine.State;
|
||||||
|
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,11 +174,16 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
|
||||||
BackedUp, Creating, BackingUp, UNRECOGNIZED;
|
BACKED_UP, CREATING, BACKING_UP, UNRECOGNIZED;
|
||||||
|
|
||||||
public static State fromValue(String type) {
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static State fromValue(String state) {
|
||||||
try {
|
try {
|
||||||
return valueOf(checkNotNull(type, "type"));
|
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,7 @@ public class Template implements Comparable<Template> {
|
||||||
|
|
||||||
USER, BUILTIN, UNRECOGNIZED;
|
USER, BUILTIN, UNRECOGNIZED;
|
||||||
|
|
||||||
|
//TODO do we need camel case routines (e.g. see enums in VirtualMachine) ?
|
||||||
public static Type fromValue(String type) {
|
public static Type fromValue(String type) {
|
||||||
try {
|
try {
|
||||||
return valueOf(checkNotNull(type, "type"));
|
return valueOf(checkNotNull(type, "type"));
|
||||||
|
|
|
@ -24,6 +24,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.VirtualMachine.State;
|
||||||
|
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -540,21 +543,26 @@ public class Volume implements Comparable<Volume> {
|
||||||
public enum State {
|
public enum State {
|
||||||
|
|
||||||
/** indicates that the volume record is created in the DB, but not on the backend */
|
/** indicates that the volume record is created in the DB, but not on the backend */
|
||||||
Allocated,
|
ALLOCATED,
|
||||||
/** the volume is being created on the backend */
|
/** the volume is being created on the backend */
|
||||||
Creating,
|
CREATING,
|
||||||
/** the volume is ready to be used */
|
/** the volume is ready to be used */
|
||||||
Ready,
|
READY,
|
||||||
/** the volume is destroyed (either as a result of deleteVolume command for DataDisk or as a part of destroyVm) */
|
/** the volume is destroyed (either as a result of deleteVolume command for DataDisk or as a part of destroyVm) */
|
||||||
Destroyed,
|
DESTROYED,
|
||||||
/** the volume has failed somehow, e.g. during creation (in cloudstack development) */
|
/** the volume has failed somehow, e.g. during creation (in cloudstack development) */
|
||||||
Failed,
|
FAILED,
|
||||||
|
|
||||||
UNRECOGNIZED;
|
UNRECOGNIZED;
|
||||||
|
|
||||||
public static State fromValue(String type) {
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static State fromValue(String state) {
|
||||||
try {
|
try {
|
||||||
return valueOf(checkNotNull(type, "type"));
|
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return UNRECOGNIZED;
|
return UNRECOGNIZED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue