FilterParameter now has a YangXPathExpression
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / FilterParameter.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.net.URI;
13 import javax.xml.xpath.XPathExpressionException;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression;
17 import org.opendaylight.yangtools.yang.xpath.api.YangXPathMathMode;
18 import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
19
20 /**
21  * This class represents a {@code filter} parameter as defined in
22  * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">RFC8040 section 4.8.4</a>.
23  */
24 @NonNullByDefault
25 public final class FilterParameter implements Immutable {
26     private static final URI CAPABILITY = URI.create("urn:ietf:params:restconf:capability:filter:1.0");
27
28     private final YangXPathExpression value;
29
30     private FilterParameter(final YangXPathExpression value) {
31         this.value = requireNonNull(value);
32     }
33
34     public static FilterParameter forUriValue(final YangXPathParserFactory parserFactory, final String uriValue)
35             throws XPathExpressionException {
36         return new FilterParameter(parserFactory.newParser(YangXPathMathMode.EXACT).parseExpression(uriValue));
37     }
38
39     public YangXPathExpression value() {
40         return value;
41     }
42
43     public static String uriName() {
44         return "filter";
45     }
46
47     public static URI capabilityUri() {
48         return CAPABILITY;
49     }
50 }