01 /*
02 * SPDX-License-Identifier: Apache-2.0
03 *
04 * Copyright 2020-2022 Agorapulse.
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package com.agorapulse.micronaut.bigquery;
19
20 import java.time.Instant;
21
22 /**
23 * Row result is the abstraction of a row returned from the BigQuery job.
24 */
25 public interface RowResult {
26
27 /**
28 * Returns <code>true</code> if the column value returned is null.
29 * @param key the name of the column
30 * @return <code>true</code> if the column value returned is null
31 */
32 boolean isNull(String key);
33
34 /**
35 * Returns the boolean value of the column if applicable.
36 * @param key the name of the column
37 * @return the boolean value of the column if applicable
38 */
39 Boolean getBooleanValue(String key);
40
41 /**
42 * Returns the double value of the column if applicable.
43 * @param key the name of the column
44 * @return the double value of the column if applicable
45 */
46 Double getDoubleValue(String key);
47
48 /**
49 * Returns the string value of the column if applicable.
50 * @param key the name of the column
51 * @return the string value of the column if applicable
52 */
53 String getStringValue(String key);
54
55 /**
56 * Returns the long value of the column if applicable.
57 * @param key the name of the column
58 * @return the long value of the column if applicable
59 */
60 Long getLongValue(String key);
61
62 /**
63 * Returns the value of the column as {@link Instant} if applicable.
64 * @param key the name of the column
65 * @return the value of the column as {@link Instant} if applicable
66 */
67 Instant getTimestampValue(String key);
68
69 /**
70 * Returns the enum value of the column if applicable.
71 * @param key the name of the column
72 * @param enumType the enum type
73 * @param <E> the enum type
74 * @return the enum value of the column if applicable
75 */
76 default <E extends Enum<E>> E getEnumValue(String key, Class<E> enumType) {
77 return isNull(key) ? null : Enum.valueOf(enumType, getStringValue(key));
78 }
79
80 }
|