|
19 | 19 | import static com.google.common.base.MoreObjects.firstNonNull; |
20 | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
21 | 21 |
|
| 22 | +import com.google.api.core.ApiFunction; |
22 | 23 | import com.google.api.client.util.Data; |
| 24 | +import com.google.cloud.StringEnumType; |
| 25 | +import com.google.cloud.StringEnumValue; |
23 | 26 | import com.google.common.collect.ImmutableMap; |
24 | 27 | import com.google.common.collect.Maps; |
25 | 28 |
|
@@ -50,27 +53,67 @@ public class ProjectInfo implements Serializable { |
50 | 53 | /** |
51 | 54 | * The project lifecycle states. |
52 | 55 | */ |
53 | | - public enum State { |
| 56 | + public static final class State extends StringEnumValue { |
| 57 | + private static final long serialVersionUID = 869635563976629566L; |
| 58 | + |
| 59 | + private static final ApiFunction<String, State> CONSTRUCTOR = |
| 60 | + new ApiFunction<String, State>() { |
| 61 | + @Override |
| 62 | + public State apply(String constant) { |
| 63 | + return new State(constant); |
| 64 | + } |
| 65 | + }; |
| 66 | + |
| 67 | + private static final StringEnumType<State> type = new StringEnumType( |
| 68 | + State.class, |
| 69 | + CONSTRUCTOR); |
| 70 | + |
54 | 71 | /** |
55 | 72 | * Only used/useful for distinguishing unset values. |
56 | 73 | */ |
57 | | - LIFECYCLE_STATE_UNSPECIFIED, |
| 74 | + public static final State LIFECYCLE_STATE_UNSPECIFIED = type.createAndRegister("LIFECYCLE_STATE_UNSPECIFIED"); |
58 | 75 |
|
59 | 76 | /** |
60 | 77 | * The normal and active state. |
61 | 78 | */ |
62 | | - ACTIVE, |
| 79 | + public static final State ACTIVE = type.createAndRegister("ACTIVE"); |
63 | 80 |
|
64 | 81 | /** |
65 | 82 | * The project has been marked for deletion by the user or by the system (Google Cloud |
66 | 83 | * Platform). This can generally be reversed by calling {@link ResourceManager#undelete}. |
67 | 84 | */ |
68 | | - DELETE_REQUESTED, |
| 85 | + public static final State DELETE_REQUESTED = type.createAndRegister("DELETE_REQUESTED"); |
69 | 86 |
|
70 | 87 | /** |
71 | 88 | * The process of deleting the project has begun. Reversing the deletion is no longer possible. |
72 | 89 | */ |
73 | | - DELETE_IN_PROGRESS |
| 90 | + public static final State DELETE_IN_PROGRESS = type.createAndRegister("DELETE_IN_PROGRESS"); |
| 91 | + |
| 92 | + private State(String constant) { |
| 93 | + super(constant); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Get the State for the given String constant, and throw an exception if the constant is |
| 98 | + * not recognized. |
| 99 | + */ |
| 100 | + public static State valueOfStrict(String constant) { |
| 101 | + return type.valueOfStrict(constant); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Get the State for the given String constant, and allow unrecognized values. |
| 106 | + */ |
| 107 | + public static State valueOf(String constant) { |
| 108 | + return type.valueOf(constant); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Return the known values for State. |
| 113 | + */ |
| 114 | + public static State[] values() { |
| 115 | + return type.values(); |
| 116 | + } |
74 | 117 | } |
75 | 118 |
|
76 | 119 | static class ResourceId implements Serializable { |
|
0 commit comments