|
| 1 | +package io.contract_testing.contractcase.logs; |
| 2 | + |
| 3 | +import org.jetbrains.annotations.NotNull; |
| 4 | + |
| 5 | +/** |
| 6 | + * Data class to hold data to print a message error during matching. |
| 7 | + */ |
| 8 | +public interface PrintableMatchError { |
| 9 | + |
| 10 | + /** |
| 11 | + * A string representation of the actual data received (may contain newlines). |
| 12 | + */ |
| 13 | + @org.jetbrains.annotations.NotNull java.lang.String getActual(); |
| 14 | + |
| 15 | + /** |
| 16 | + * The machine-readable type for the cause of this error, for printing after the error message to |
| 17 | + * make it easy to search for. |
| 18 | + */ |
| 19 | + @org.jetbrains.annotations.NotNull java.lang.String getErrorTypeTag(); |
| 20 | + |
| 21 | + /** |
| 22 | + * A string representation of the expected data (may contain newlines). |
| 23 | + */ |
| 24 | + @org.jetbrains.annotations.NotNull java.lang.String getExpected(); |
| 25 | + |
| 26 | + /** |
| 27 | + * The red highlighted blob, eg "MATCHING ERROR" or "TRIGGER FUNCTION ERROR". |
| 28 | + * <p> |
| 29 | + * Could be any string. |
| 30 | + */ |
| 31 | + @org.jetbrains.annotations.NotNull java.lang.String getKind(); |
| 32 | + |
| 33 | + /** |
| 34 | + * The location the error happened, for printing at the top of the error message. |
| 35 | + */ |
| 36 | + @org.jetbrains.annotations.NotNull java.lang.String getLocation(); |
| 37 | + |
| 38 | + /** |
| 39 | + * The tag line for the location the error happened, for printing after the error message. |
| 40 | + * <p> |
| 41 | + * This might have more information than the <code>location</code> above. |
| 42 | + */ |
| 43 | + @org.jetbrains.annotations.NotNull java.lang.String getLocationTag(); |
| 44 | + |
| 45 | + /** |
| 46 | + * A summary of the error. |
| 47 | + * <p> |
| 48 | + * Could be any string. |
| 49 | + */ |
| 50 | + @org.jetbrains.annotations.NotNull java.lang.String getMessage(); |
| 51 | + |
| 52 | + /** |
| 53 | + * @return a {@link Builder} of {@link PrintableMatchError} |
| 54 | + */ |
| 55 | + static Builder builder() { |
| 56 | + return new Builder(); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * A builder for {@link PrintableMatchError} |
| 61 | + */ |
| 62 | + final class Builder implements software.amazon.jsii.Builder<PrintableMatchError> { |
| 63 | + |
| 64 | + java.lang.String actual; |
| 65 | + java.lang.String errorTypeTag; |
| 66 | + java.lang.String expected; |
| 67 | + java.lang.String kind; |
| 68 | + java.lang.String location; |
| 69 | + java.lang.String locationTag; |
| 70 | + java.lang.String message; |
| 71 | + |
| 72 | + /** |
| 73 | + * Sets the value of {@link PrintableMatchError#getActual} |
| 74 | + * |
| 75 | + * @param actual A string representation of the actual data received (may contain newlines). |
| 76 | + * This parameter is required. |
| 77 | + * @return {@code this} |
| 78 | + */ |
| 79 | + public Builder actual(java.lang.String actual) { |
| 80 | + this.actual = actual; |
| 81 | + return this; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Sets the value of {@link PrintableMatchError#getErrorTypeTag} |
| 86 | + * |
| 87 | + * @param errorTypeTag The machine-readable type for the cause of this error, for printing after |
| 88 | + * the error message to make it easy to search for. This parameter is |
| 89 | + * required. |
| 90 | + * @return {@code this} |
| 91 | + */ |
| 92 | + public Builder errorTypeTag(java.lang.String errorTypeTag) { |
| 93 | + this.errorTypeTag = errorTypeTag; |
| 94 | + return this; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Sets the value of {@link PrintableMatchError#getExpected} |
| 99 | + * |
| 100 | + * @param expected A string representation of the expected data (may contain newlines). This |
| 101 | + * parameter is required. |
| 102 | + * @return {@code this} |
| 103 | + */ |
| 104 | + public Builder expected(java.lang.String expected) { |
| 105 | + this.expected = expected; |
| 106 | + return this; |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Sets the value of {@link PrintableMatchError#getKind} |
| 111 | + * |
| 112 | + * @param kind The red highlighted blob, eg "MATCHING ERROR" or "TRIGGER FUNCTION ERROR". This |
| 113 | + * parameter is required. Could be any string. |
| 114 | + * @return {@code this} |
| 115 | + */ |
| 116 | + public Builder kind(java.lang.String kind) { |
| 117 | + this.kind = kind; |
| 118 | + return this; |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Sets the value of {@link PrintableMatchError#getLocation} |
| 123 | + * |
| 124 | + * @param location The location the error happened, for printing at the top of the error |
| 125 | + * message. This parameter is required. |
| 126 | + * @return {@code this} |
| 127 | + */ |
| 128 | + public Builder location(java.lang.String location) { |
| 129 | + this.location = location; |
| 130 | + return this; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Sets the value of {@link PrintableMatchError#getLocationTag} |
| 135 | + * |
| 136 | + * @param locationTag The tag line for the location the error happened, for printing after the |
| 137 | + * error message. This parameter is required. This might have more |
| 138 | + * information than the <code>location</code> above. |
| 139 | + * @return {@code this} |
| 140 | + */ |
| 141 | + public Builder locationTag(java.lang.String locationTag) { |
| 142 | + this.locationTag = locationTag; |
| 143 | + return this; |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Sets the value of {@link PrintableMatchError#getMessage} |
| 148 | + * |
| 149 | + * @param message A summary of the error. This parameter is required. Could be any string. |
| 150 | + * @return {@code this} |
| 151 | + */ |
| 152 | + public Builder message(java.lang.String message) { |
| 153 | + this.message = message; |
| 154 | + return this; |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Builds the configured instance. |
| 159 | + * |
| 160 | + * @return a new instance of {@link PrintableMatchError} |
| 161 | + * @throws NullPointerException if any required attribute was not provided |
| 162 | + */ |
| 163 | + @Override |
| 164 | + public PrintableMatchError build() { |
| 165 | + return new PrintableMatchErrorImpl(this); |
| 166 | + } |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * An implementation for {@link PrintableMatchError} |
| 171 | + */ |
| 172 | + final class PrintableMatchErrorImpl implements |
| 173 | + PrintableMatchError { |
| 174 | + |
| 175 | + private final java.lang.String actual; |
| 176 | + private final java.lang.String errorTypeTag; |
| 177 | + private final java.lang.String expected; |
| 178 | + private final java.lang.String kind; |
| 179 | + private final java.lang.String location; |
| 180 | + private final java.lang.String locationTag; |
| 181 | + private final java.lang.String message; |
| 182 | + |
| 183 | + |
| 184 | + /** |
| 185 | + * Constructor that initializes the object based on literal property values passed by the |
| 186 | + * {@link Builder}. |
| 187 | + */ |
| 188 | + private PrintableMatchErrorImpl(final Builder builder) { |
| 189 | + this.actual = java.util.Objects.requireNonNull(builder.actual, "actual is required"); |
| 190 | + this.errorTypeTag = java.util.Objects.requireNonNull( |
| 191 | + builder.errorTypeTag, |
| 192 | + "errorTypeTag is required" |
| 193 | + ); |
| 194 | + this.expected = java.util.Objects.requireNonNull(builder.expected, "expected is required"); |
| 195 | + this.kind = java.util.Objects.requireNonNull(builder.kind, "kind is required"); |
| 196 | + this.location = java.util.Objects.requireNonNull(builder.location, "location is required"); |
| 197 | + this.locationTag = java.util.Objects.requireNonNull( |
| 198 | + builder.locationTag, |
| 199 | + "locationTag is required" |
| 200 | + ); |
| 201 | + this.message = java.util.Objects.requireNonNull(builder.message, "message is required"); |
| 202 | + } |
| 203 | + |
| 204 | + @Override |
| 205 | + public java.lang.@NotNull String getActual() { |
| 206 | + return this.actual; |
| 207 | + } |
| 208 | + |
| 209 | + @Override |
| 210 | + public java.lang.@NotNull String getErrorTypeTag() { |
| 211 | + return this.errorTypeTag; |
| 212 | + } |
| 213 | + |
| 214 | + @Override |
| 215 | + public java.lang.@NotNull String getExpected() { |
| 216 | + return this.expected; |
| 217 | + } |
| 218 | + |
| 219 | + @Override |
| 220 | + public java.lang.@NotNull String getKind() { |
| 221 | + return this.kind; |
| 222 | + } |
| 223 | + |
| 224 | + @Override |
| 225 | + public java.lang.@NotNull String getLocation() { |
| 226 | + return this.location; |
| 227 | + } |
| 228 | + |
| 229 | + @Override |
| 230 | + public java.lang.@NotNull String getLocationTag() { |
| 231 | + return this.locationTag; |
| 232 | + } |
| 233 | + |
| 234 | + @Override |
| 235 | + public java.lang.@NotNull String getMessage() { |
| 236 | + return this.message; |
| 237 | + } |
| 238 | + |
| 239 | + @Override |
| 240 | + public boolean equals(final Object o) { |
| 241 | + if (this == o) { |
| 242 | + return true; |
| 243 | + } |
| 244 | + if (o == null || getClass() != o.getClass()) { |
| 245 | + return false; |
| 246 | + } |
| 247 | + |
| 248 | + PrintableMatchErrorImpl that = (PrintableMatchErrorImpl) o; |
| 249 | + |
| 250 | + if (!actual.equals(that.actual)) { |
| 251 | + return false; |
| 252 | + } |
| 253 | + if (!errorTypeTag.equals(that.errorTypeTag)) { |
| 254 | + return false; |
| 255 | + } |
| 256 | + if (!expected.equals(that.expected)) { |
| 257 | + return false; |
| 258 | + } |
| 259 | + if (!kind.equals(that.kind)) { |
| 260 | + return false; |
| 261 | + } |
| 262 | + if (!location.equals(that.location)) { |
| 263 | + return false; |
| 264 | + } |
| 265 | + if (!locationTag.equals(that.locationTag)) { |
| 266 | + return false; |
| 267 | + } |
| 268 | + return this.message.equals(that.message); |
| 269 | + } |
| 270 | + |
| 271 | + @Override |
| 272 | + public int hashCode() { |
| 273 | + int result = this.actual.hashCode(); |
| 274 | + result = 31 * result + (this.errorTypeTag.hashCode()); |
| 275 | + result = 31 * result + (this.expected.hashCode()); |
| 276 | + result = 31 * result + (this.kind.hashCode()); |
| 277 | + result = 31 * result + (this.location.hashCode()); |
| 278 | + result = 31 * result + (this.locationTag.hashCode()); |
| 279 | + result = 31 * result + (this.message.hashCode()); |
| 280 | + return result; |
| 281 | + } |
| 282 | + } |
| 283 | +} |
0 commit comments