|
| 1 | +package tech.ydb.table.description; |
| 2 | + |
| 3 | +import javax.annotation.Nullable; |
| 4 | + |
| 5 | +/** |
| 6 | + * @author Kirill Kurdyukov |
| 7 | + */ |
| 8 | +public class SequenceDescription { |
| 9 | + |
| 10 | + public String getName() { |
| 11 | + return name; |
| 12 | + } |
| 13 | + |
| 14 | + @Nullable |
| 15 | + public Long getMinValue() { |
| 16 | + return minValue; |
| 17 | + } |
| 18 | + |
| 19 | + @Nullable |
| 20 | + public Long getMaxValue() { |
| 21 | + return maxValue; |
| 22 | + } |
| 23 | + |
| 24 | + @Nullable |
| 25 | + public Long getStartValue() { |
| 26 | + return startValue; |
| 27 | + } |
| 28 | + |
| 29 | + @Nullable |
| 30 | + public Long getCache() { |
| 31 | + return cache; |
| 32 | + } |
| 33 | + |
| 34 | + @Nullable |
| 35 | + public Long getIncrement() { |
| 36 | + return increment; |
| 37 | + } |
| 38 | + |
| 39 | + @Nullable |
| 40 | + public Boolean getCycle() { |
| 41 | + return cycle; |
| 42 | + } |
| 43 | + |
| 44 | + @Nullable |
| 45 | + public SetVal getSetVal() { |
| 46 | + return setVal; |
| 47 | + } |
| 48 | + |
| 49 | + public static class SetVal { |
| 50 | + @Nullable |
| 51 | + private final Long nextValue; |
| 52 | + @Nullable |
| 53 | + private final Boolean nextUsed; |
| 54 | + |
| 55 | + public SetVal(@Nullable Long nextValue, @Nullable Boolean nextUsed) { |
| 56 | + this.nextValue = nextValue; |
| 57 | + this.nextUsed = nextUsed; |
| 58 | + } |
| 59 | + |
| 60 | + @Nullable |
| 61 | + public Long getNextValue() { |
| 62 | + return nextValue; |
| 63 | + } |
| 64 | + |
| 65 | + @Nullable |
| 66 | + public Boolean getNextUsed() { |
| 67 | + return nextUsed; |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + private final String name; |
| 72 | + @Nullable |
| 73 | + private final Long minValue; |
| 74 | + @Nullable |
| 75 | + private final Long maxValue; |
| 76 | + @Nullable |
| 77 | + private final Long startValue; |
| 78 | + @Nullable |
| 79 | + private final Long cache; |
| 80 | + @Nullable |
| 81 | + private final Long increment; |
| 82 | + @Nullable |
| 83 | + private final Boolean cycle; |
| 84 | + @Nullable |
| 85 | + private final SetVal setVal; |
| 86 | + |
| 87 | + private SequenceDescription(Builder builder) { |
| 88 | + this.name = builder.name; |
| 89 | + this.minValue = builder.minValue; |
| 90 | + this.maxValue = builder.maxValue; |
| 91 | + this.startValue = builder.startValue; |
| 92 | + this.cache = builder.cache; |
| 93 | + this.increment = builder.increment; |
| 94 | + this.cycle = builder.cycle; |
| 95 | + this.setVal = builder.setVal; |
| 96 | + } |
| 97 | + |
| 98 | + public static Builder newBuilder() { |
| 99 | + return new Builder(); |
| 100 | + } |
| 101 | + |
| 102 | + public static class Builder { |
| 103 | + private String name; |
| 104 | + private Long minValue; |
| 105 | + private Long maxValue; |
| 106 | + private Long startValue; |
| 107 | + private Long cache; |
| 108 | + private Long increment; |
| 109 | + private Boolean cycle; |
| 110 | + private SetVal setVal; |
| 111 | + |
| 112 | + public Builder setName(String name) { |
| 113 | + this.name = name; |
| 114 | + return this; |
| 115 | + } |
| 116 | + |
| 117 | + public Builder setMinValue(@Nullable Long minValue) { |
| 118 | + this.minValue = minValue; |
| 119 | + return this; |
| 120 | + } |
| 121 | + |
| 122 | + public Builder setMaxValue(@Nullable Long maxValue) { |
| 123 | + this.maxValue = maxValue; |
| 124 | + return this; |
| 125 | + } |
| 126 | + |
| 127 | + public Builder setStartValue(@Nullable Long startValue) { |
| 128 | + this.startValue = startValue; |
| 129 | + return this; |
| 130 | + } |
| 131 | + |
| 132 | + public Builder setCache(@Nullable Long cache) { |
| 133 | + this.cache = cache; |
| 134 | + return this; |
| 135 | + } |
| 136 | + |
| 137 | + public Builder setIncrement(@Nullable Long increment) { |
| 138 | + this.increment = increment; |
| 139 | + return this; |
| 140 | + } |
| 141 | + |
| 142 | + public Builder setCycle(@Nullable Boolean cycle) { |
| 143 | + this.cycle = cycle; |
| 144 | + return this; |
| 145 | + } |
| 146 | + |
| 147 | + public Builder setSetVal(@Nullable Long nextValue, @Nullable Boolean nextUsed) { |
| 148 | + this.setVal = new SetVal(nextValue, nextUsed); |
| 149 | + return this; |
| 150 | + } |
| 151 | + |
| 152 | + public SequenceDescription build() { |
| 153 | + if (name == null) { |
| 154 | + throw new IllegalStateException("name is required"); |
| 155 | + } |
| 156 | + |
| 157 | + return new SequenceDescription(this); |
| 158 | + } |
| 159 | + } |
| 160 | +} |
0 commit comments