-
Notifications
You must be signed in to change notification settings - Fork 214
/
JsonFieldSelectorInvalidException.java
executable file
·88 lines (72 loc) · 2.82 KB
/
JsonFieldSelectorInvalidException.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.json;
import java.net.URI;
import java.text.MessageFormat;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Thrown if a field selector at was in an invalid format.
*/
public final class JsonFieldSelectorInvalidException extends JsonRuntimeException {
/**
* Error code of this exception.
*/
public static final String ERROR_CODE = "json.fieldselector.invalid";
private static final String DEFAULT_DESCRIPTION =
"Check, for example, if the amount of opening parentheses '(' matches the amount of closing ones ')'.";
private static final long serialVersionUID = -8483368816839385508L;
private JsonFieldSelectorInvalidException(@Nullable final String message,
@Nullable final String description,
@Nullable final Throwable cause,
@Nullable final URI href) {
super(ERROR_CODE, message, description, cause, href);
}
/**
* Returns a builder for fluently creating instances of {@code JsonParseException}s..
*
* @return a new builder for JsonParseException objects.
*/
public static Builder newBuilder() {
return new Builder();
}
/**
* A mutable builder for a {@code JsonPointerInvalidException}.
*/
@NotThreadSafe
public static final class Builder extends AbstractJsonExceptionBuilder<JsonFieldSelectorInvalidException> {
private Builder() {
super(ERROR_CODE);
description(DEFAULT_DESCRIPTION);
}
/**
* Sets a message which points to the invalid field selector. Thus if this method is called, {@link #message}
* should not be called.
*
* @param fieldSelector the invalid field selector string.
* @return this builder to allow method chaining.
*/
public Builder fieldSelector(final String fieldSelector) {
message(MessageFormat.format("The field selector <{0}> is invalid!", fieldSelector));
return this;
}
@Override
protected JsonFieldSelectorInvalidException doBuild(final String errorCode,
@Nullable final String message,
@Nullable final String description,
@Nullable final Throwable cause,
@Nullable final URI href) {
return new JsonFieldSelectorInvalidException(message, description, cause, href);
}
}
}