|
4 | 4 |
|
5 | 5 | package com.cadl.longrunning.models;
|
6 | 6 |
|
7 |
| -import com.azure.core.annotation.Generated; |
8 |
| -import com.azure.core.util.ExpandableStringEnum; |
9 |
| -import java.util.Collection; |
10 |
| - |
11 | 7 | /**
|
12 | 8 | * Enum describing allowed operation states.
|
13 | 9 | */
|
14 |
| -public final class OperationState extends ExpandableStringEnum<OperationState> { |
| 10 | +public enum OperationState { |
15 | 11 | /**
|
16 | 12 | * The operation has not started.
|
17 | 13 | */
|
18 |
| - @Generated |
19 |
| - public static final OperationState NOT_STARTED = fromString("NotStarted"); |
| 14 | + NOT_STARTED("NotStarted"), |
20 | 15 |
|
21 | 16 | /**
|
22 | 17 | * The operation is in progress.
|
23 | 18 | */
|
24 |
| - @Generated |
25 |
| - public static final OperationState RUNNING = fromString("Running"); |
| 19 | + RUNNING("Running"), |
26 | 20 |
|
27 | 21 | /**
|
28 | 22 | * The operation has completed successfully.
|
29 | 23 | */
|
30 |
| - @Generated |
31 |
| - public static final OperationState SUCCEEDED = fromString("Succeeded"); |
| 24 | + SUCCEEDED("Succeeded"), |
32 | 25 |
|
33 | 26 | /**
|
34 | 27 | * The operation has failed.
|
35 | 28 | */
|
36 |
| - @Generated |
37 |
| - public static final OperationState FAILED = fromString("Failed"); |
| 29 | + FAILED("Failed"), |
38 | 30 |
|
39 | 31 | /**
|
40 | 32 | * The operation has been canceled by the user.
|
41 | 33 | */
|
42 |
| - @Generated |
43 |
| - public static final OperationState CANCELED = fromString("Canceled"); |
| 34 | + CANCELED("Canceled"); |
44 | 35 |
|
45 | 36 | /**
|
46 |
| - * Creates a new instance of OperationState value. |
47 |
| - * |
48 |
| - * @deprecated Use the {@link #fromString(String)} factory method. |
| 37 | + * The actual serialized value for a OperationState instance. |
49 | 38 | */
|
50 |
| - @Generated |
51 |
| - @Deprecated |
52 |
| - public OperationState() { |
| 39 | + private final String value; |
| 40 | + |
| 41 | + OperationState(String value) { |
| 42 | + this.value = value; |
53 | 43 | }
|
54 | 44 |
|
55 | 45 | /**
|
56 |
| - * Creates or finds a OperationState from its string representation. |
| 46 | + * Parses a serialized value to a OperationState instance. |
57 | 47 | *
|
58 |
| - * @param name a name to look for. |
59 |
| - * @return the corresponding OperationState. |
| 48 | + * @param value the serialized value to parse. |
| 49 | + * @return the parsed OperationState object, or null if unable to parse. |
60 | 50 | */
|
61 |
| - @Generated |
62 |
| - public static OperationState fromString(String name) { |
63 |
| - return fromString(name, OperationState.class); |
| 51 | + public static OperationState fromString(String value) { |
| 52 | + if (value == null) { |
| 53 | + return null; |
| 54 | + } |
| 55 | + OperationState[] items = OperationState.values(); |
| 56 | + for (OperationState item : items) { |
| 57 | + if (item.toString().equalsIgnoreCase(value)) { |
| 58 | + return item; |
| 59 | + } |
| 60 | + } |
| 61 | + return null; |
64 | 62 | }
|
65 | 63 |
|
66 | 64 | /**
|
67 |
| - * Gets known OperationState values. |
68 |
| - * |
69 |
| - * @return known OperationState values. |
| 65 | + * {@inheritDoc} |
70 | 66 | */
|
71 |
| - @Generated |
72 |
| - public static Collection<OperationState> values() { |
73 |
| - return values(OperationState.class); |
| 67 | + @Override |
| 68 | + public String toString() { |
| 69 | + return this.value; |
74 | 70 | }
|
75 | 71 | }
|
0 commit comments