2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2023 Nordix Foundation
4 * Modifications Copyright (C) 2023 TechMahindra Ltd
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.cpspath.parser;
24 import static org.onap.cps.cpspath.parser.CpsPathPrefixType.ABSOLUTE;
26 import java.util.List;
28 import lombok.AccessLevel;
33 @Setter(AccessLevel.PACKAGE)
34 public class CpsPathQuery {
36 private String xpathPrefix;
37 private String normalizedParentPath;
38 private String normalizedXpath;
39 private List<String> containerNames;
40 private CpsPathPrefixType cpsPathPrefixType = ABSOLUTE;
41 private String descendantName;
42 private Map<String, Object> leavesData;
43 private String ancestorSchemaNodeIdentifier = "";
44 private String textFunctionConditionLeafName;
45 private String textFunctionConditionValue;
46 private List<String> booleanOperators;
47 private List<String> comparativeOperators;
48 private String containsFunctionConditionLeafName;
49 private String containsFunctionConditionValue;
52 * Returns a cps path query.
54 * @param cpsPathSource cps path
55 * @return a CpsPathQuery object.
57 public static CpsPathQuery createFrom(final String cpsPathSource) {
58 return CpsPathUtil.getCpsPathQuery(cpsPathSource);
62 * Has ancestor axis been included in cpsPath.
64 * @return boolean value.
66 public boolean hasAncestorAxis() {
67 return !(ancestorSchemaNodeIdentifier.isEmpty());
71 * Have leaf value conditions been included in cpsPath.
73 * @return boolean value.
75 public boolean hasLeafConditions() {
76 return leavesData != null;
80 * Has text function condition been included in cpsPath.
82 * @return boolean value.
84 public boolean hasTextFunctionCondition() {
85 return textFunctionConditionLeafName != null;
89 * Has contains function condition been included in cpsPath.
91 * @return boolean value.
93 public boolean hasContainsFunctionCondition() {
94 return containsFunctionConditionLeafName != null;
98 * Returns boolean indicating xpath is an absolute path to a list element.
100 * @return true if xpath is an absolute path to a list element
102 public boolean isPathToListElement() {
103 return cpsPathPrefixType == ABSOLUTE && hasLeafConditions();