|
21 | 21 | import com.google.common.base.CaseFormat;
|
22 | 22 | import com.google.common.collect.ImmutableMap;
|
23 | 23 |
|
| 24 | +import java.io.File; |
24 | 25 | import java.util.LinkedHashMap;
|
25 | 26 | import java.util.Map;
|
26 | 27 |
|
|
29 | 30 | * @see Session#map
|
30 | 31 | */
|
31 | 32 | public enum Prop {
|
| 33 | + /** File property "directory" is the path of the directory that the |
| 34 | + * {@code file} variable maps to in this connection. |
| 35 | + * |
| 36 | + * <p>The default value is the empty string; |
| 37 | + * many tests use the "src/test/resources" directory; |
| 38 | + * when launched via the {@code morel} shell script, the default value is the |
| 39 | + * shell's current directory. */ |
| 40 | + DIRECTORY("directory", File.class, new File("")), |
| 41 | + |
32 | 42 | /** Boolean property "hybrid" controls whether to try to create a hybrid
|
33 | 43 | * execution plan that uses Apache Calcite relational algebra wherever
|
34 | 44 | * possible. Default is false. */
|
@@ -114,6 +124,10 @@ public enum Prop {
|
114 | 124 | assert defaultValue == null || defaultValue.getClass() == type;
|
115 | 125 | } else if (type == Integer.class) {
|
116 | 126 | assert defaultValue == null || defaultValue.getClass() == type;
|
| 127 | + } else if (type == String.class) { |
| 128 | + assert defaultValue == null || defaultValue.getClass() == type; |
| 129 | + } else if (type == File.class) { |
| 130 | + assert defaultValue == null || defaultValue.getClass() == type; |
117 | 131 | } else {
|
118 | 132 | throw new AssertionError("not a valid property type: "
|
119 | 133 | + type);
|
@@ -149,6 +163,20 @@ public int intValue(Map<Prop, Object> map) {
|
149 | 163 | return this.<Integer>typeValue(o);
|
150 | 164 | }
|
151 | 165 |
|
| 166 | + /** Returns the value of a string property. */ |
| 167 | + public String stringValue(Map<Prop, Object> map) { |
| 168 | + assert type == String.class; |
| 169 | + Object o = map.get(this); |
| 170 | + return this.typeValue(o); |
| 171 | + } |
| 172 | + |
| 173 | + /** Returns the value of a file property. */ |
| 174 | + public File fileValue(Map<Prop, Object> map) { |
| 175 | + assert type == File.class; |
| 176 | + Object o = map.get(this); |
| 177 | + return this.typeValue(o); |
| 178 | + } |
| 179 | + |
152 | 180 | @SuppressWarnings("unchecked")
|
153 | 181 | private <T> T typeValue(Object o) {
|
154 | 182 | if (o == null) {
|
|
0 commit comments