|
18 | 18 |
|
19 | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
20 | 20 |
|
| 21 | +import com.google.api.core.ApiFunction; |
21 | 22 | import com.google.api.services.bigquery.model.JobConfigurationLoad; |
| 23 | +import com.google.cloud.StringEnumType; |
| 24 | +import com.google.cloud.StringEnumValue; |
22 | 25 | import com.google.common.base.MoreObjects.ToStringHelper; |
23 | 26 | import com.google.common.base.Strings; |
24 | 27 | import com.google.common.collect.ImmutableList; |
@@ -71,20 +74,45 @@ public final class LoadJobConfiguration extends JobConfiguration implements Load |
71 | 74 | private final SourceColumnMatch sourceColumnMatch; |
72 | 75 | private final List<String> nullMarkers; |
73 | 76 |
|
74 | | - public enum SourceColumnMatch { |
75 | | - SOURCE_COLUMN_MATCH_UNSPECIFIED("SOURCE_COLUMN_MATCH_UNSPECIFIED"), |
76 | | - POSITION("POSITION"), |
77 | | - NAME("NAME"); |
| 77 | + public static final class SourceColumnMatch extends StringEnumValue { |
| 78 | + private static final long serialVersionUID = 818920627219751207L; |
| 79 | + private static final ApiFunction<String, SourceColumnMatch> CONSTRUCTOR = |
| 80 | + new ApiFunction<String, SourceColumnMatch>() { |
| 81 | + @Override |
| 82 | + public SourceColumnMatch apply(String constant) { |
| 83 | + return new SourceColumnMatch(constant); |
| 84 | + } |
| 85 | + }; |
78 | 86 |
|
79 | | - private final String option; |
| 87 | + private static final StringEnumType<SourceColumnMatch> type = |
| 88 | + new StringEnumType<SourceColumnMatch>(SourceColumnMatch.class, CONSTRUCTOR); |
80 | 89 |
|
81 | | - SourceColumnMatch(String option) { |
82 | | - this.option = option; |
| 90 | + public static final SourceColumnMatch SOURCE_COLUMN_MATCH_UNSPECIFIED = |
| 91 | + type.createAndRegister("SOURCE_COLUMN_MATCH_UNSPECIFIED"); |
| 92 | + public static final SourceColumnMatch POSITION = type.createAndRegister("POSITION"); |
| 93 | + |
| 94 | + public static final SourceColumnMatch NAME = type.createAndRegister("NAME"); |
| 95 | + |
| 96 | + private SourceColumnMatch(String constant) { |
| 97 | + super(constant); |
83 | 98 | } |
84 | 99 |
|
85 | | - @Override |
86 | | - public String toString() { |
87 | | - return option; |
| 100 | + /** |
| 101 | + * Get the SourceColumnMatch for the given String constant, and throw an exception if the |
| 102 | + * constant is not recognized. |
| 103 | + */ |
| 104 | + public static SourceColumnMatch valueOfStrict(String constant) { |
| 105 | + return type.valueOfStrict(constant); |
| 106 | + } |
| 107 | + |
| 108 | + /** Get the SourceColumnMatch for the given String constant, and allow unrecognized values. */ |
| 109 | + public static SourceColumnMatch valueOf(String constant) { |
| 110 | + return type.valueOf(constant); |
| 111 | + } |
| 112 | + |
| 113 | + /** Return the known values for SourceColumnMatch. */ |
| 114 | + public static SourceColumnMatch[] values() { |
| 115 | + return type.values(); |
88 | 116 | } |
89 | 117 | } |
90 | 118 |
|
|
0 commit comments