Fix Absolute Path to list with Integer/String key
[cps.git] / cps-path-parser / src / main / java / org / onap / cps / cpspath / parser / CpsPathQuery.java
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2021-2022 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.cpspath.parser;
22
23 import static org.onap.cps.cpspath.parser.CpsPathPrefixType.ABSOLUTE;
24
25 import java.util.Map;
26 import lombok.AccessLevel;
27 import lombok.Getter;
28 import lombok.Setter;
29
30 @Getter
31 @Setter(AccessLevel.PACKAGE)
32 public class CpsPathQuery {
33
34     private String xpathPrefix;
35     private String normalizedXpath;
36     private CpsPathPrefixType cpsPathPrefixType = ABSOLUTE;
37     private String descendantName;
38     private Map<String, Object> leavesData;
39     private String ancestorSchemaNodeIdentifier = "";
40     private String textFunctionConditionLeafName;
41     private String textFunctionConditionValue;
42
43     /**
44      * Returns a cps path query.
45      *
46      * @param cpsPathSource cps path
47      * @return a CpsPathQuery object.
48      */
49     public static CpsPathQuery createFrom(final String cpsPathSource) {
50         return CpsPathUtil.getCpsPathQuery(cpsPathSource);
51     }
52
53     /**
54      * Has ancestor axis been included in cpsPath.
55      *
56      * @return boolean value.
57      */
58     public boolean hasAncestorAxis() {
59         return !(ancestorSchemaNodeIdentifier.isEmpty());
60     }
61
62     /**
63      * Have leaf value conditions been included in cpsPath.
64      *
65      * @return boolean value.
66      */
67     public boolean hasLeafConditions() {
68         return leavesData != null;
69     }
70
71     /**
72      * Has text function condition been included in cpsPath.
73      *
74      * @return boolean value.
75      */
76     public boolean hasTextFunctionCondition() {
77         return textFunctionConditionLeafName != null;
78     }
79
80 }