Debian Codegraph @

src/main/org/h2/result/ResultWithGeneratedKeys.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.result;
7
8 /**
9 * Result of update command with optional generated keys.
10 */
11 public class ResultWithGeneratedKeys {
12 /**
13 * Result of update command with generated keys;
14 */
15 public static final class WithKeys extends ResultWithGeneratedKeys {
16 private final ResultInterface generatedKeys;
17
18 /**
19 * Creates a result with update count and generated keys.
20 *
21 * @param updateCount
22 * update count
23 * @param generatedKeys
24 * generated keys
25 */
26 public WithKeys(long updateCount, ResultInterface generatedKeys) {
27 super(updateCount);
28 this.generatedKeys = generatedKeys;
29 }
30
31 @Override
32 public ResultInterface getGeneratedKeys() {
33 return generatedKeys;
34 }
35 }
36
37 /**
38 * Returns a result with only update count.
39 *
40 * @param updateCount
41 * update count
42 * @return the result.
43 */
44 public static ResultWithGeneratedKeys of(long updateCount) {
45 return new ResultWithGeneratedKeys(updateCount);
46 }
47
48 private final long updateCount;
49
50 ResultWithGeneratedKeys(long updateCount) {
51 this.updateCount = updateCount;
52 }
53
54 /**
55 * Returns generated keys, or {@code null}.
56 *
57 * @return generated keys, or {@code null}
58 */
59 public ResultInterface getGeneratedKeys() {
60 return null;
61 }
62
63 /**
64 * Returns update count.
65 *
66 * @return update count
67 */
68 public long getUpdateCount() {
69 return updateCount;
70 }
71
72 }