2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.datatypes.elements;
23 import com.fasterxml.jackson.annotation.JsonIgnore;
24 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
26 import java.io.Serializable;
27 import java.util.List;
29 public class PropertyRule extends ToscaDataDefinition implements Serializable {
34 private static final long serialVersionUID = -3357933382124599996L;
36 public static String FORCE_ALL = "FORCE_ALL";
37 public static String ALL = "ALL";
38 public static String RULE_ANY_MATCH = ".+";
43 public PropertyRule() {
47 public PropertyRule(List<String> rule, String value) {
53 public List<String> getRule() {
57 public void setRule(List<String> rule) {
61 public String getValue() {
65 public void setValue(String value) {
70 public String getFirstToken() {
74 public String getToken(int tokenNumber) {
76 int index = tokenNumber - 1;
77 if (rule == null || index >= rule.size() || index < 0) {
81 return rule.get(index);
85 public int getRuleSize() {
93 public String toString() {
94 return "PropertyRule [rule=" + rule + ", value=" + value + "]";
97 public boolean compareRule(PropertyRule comparedPropertyRule) {
99 if (comparedPropertyRule == null) {
103 List<String> comparedRule = comparedPropertyRule.getRule();
104 if (rule == null && comparedRule == null) {
108 if (rule != null && comparedRule != null) {
109 if (rule.size() != comparedRule.size()) {
112 int size = rule.size();
113 boolean isEqual = true;
114 for (int i = 0; i < size; i++) {
115 String item = rule.get(i);
116 String comparedItem = comparedRule.get(i);
117 if (item == null || false == item.equals(comparedItem)) {
130 public void replaceFirstToken(String token) {
132 if (rule != null && rule.size() > 0) {