From 077b3eb52d1c7f64900f00900eb6b6272d59a176 Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Fri, 2 Dec 2011 14:57:29 +0000 Subject: [PATCH] enums to upper case, with camel conversion routines --- .../jclouds/cloudstack/domain/Snapshot.java | 14 +++++++++--- .../jclouds/cloudstack/domain/Template.java | 1 + .../org/jclouds/cloudstack/domain/Volume.java | 22 +++++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java index c86286225e..31fa4ae52c 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Snapshot.java @@ -22,6 +22,9 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; +import org.jclouds.cloudstack.domain.VirtualMachine.State; + +import com.google.common.base.CaseFormat; import com.google.gson.annotations.SerializedName; /** @@ -171,11 +174,16 @@ public class Snapshot implements Comparable { 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 { - return valueOf(checkNotNull(type, "type")); + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); } catch (IllegalArgumentException e) { return UNRECOGNIZED; } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java index 1834456db1..12cc7fb8ce 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Template.java @@ -211,6 +211,7 @@ public class Template implements Comparable