- return this.schemaHandler;
- }
- }
-
- /**
- * Parser and holder of query paramteres from uriInfo for notifications.
- */
- public static final class NotificationQueryParams {
-
- private final Instant start;
- private final Instant stop;
- private final String filter;
-
- private NotificationQueryParams(final Instant start, final Instant stop, final String filter) {
- this.start = start == null ? Instant.now() : start;
- this.stop = stop;
- this.filter = filter;
- }
-
- static NotificationQueryParams fromUriInfo(final UriInfo uriInfo) {
- Instant start = null;
- boolean startTimeUsed = false;
- Instant stop = null;
- boolean stopTimeUsed = false;
- String filter = null;
- boolean filterUsed = false;
-
- for (final Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
- switch (entry.getKey()) {
- case "start-time":
- if (!startTimeUsed) {
- startTimeUsed = true;
- start = SubscribeToStreamUtil.parseDateFromQueryParam(entry);
- } else {
- throw new RestconfDocumentedException("Start-time parameter can be used only once.");
- }
- break;
- case "stop-time":
- if (!stopTimeUsed) {
- stopTimeUsed = true;
- stop = SubscribeToStreamUtil.parseDateFromQueryParam(entry);
- } else {
- throw new RestconfDocumentedException("Stop-time parameter can be used only once.");
- }
- break;
- case "filter":
- if (!filterUsed) {
- filterUsed = true;
- filter = entry.getValue().iterator().next();
- }
- break;
- default:
- throw new RestconfDocumentedException(
- "Bad parameter used with notifications: " + entry.getKey());
- }
- }
- if (!startTimeUsed && stopTimeUsed) {
- throw new RestconfDocumentedException("Stop-time parameter has to be used with start-time parameter.");
- }
-
- return new NotificationQueryParams(start, stop, filter);
- }
-
- /**
- * Get start-time query parameter.
- *
- * @return start-time
- */
- public @NonNull Instant getStart() {
- return start;
- }
-
- /**
- * Get stop-time query parameter.
- *
- * @return stop-time
- */
- public Optional<Instant> getStop() {
- return Optional.ofNullable(stop);
- }
-
- /**
- * Get filter query parameter.
- *
- * @return filter
- */
- public Optional<String> getFilter() {
- return Optional.ofNullable(filter);