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.util.List;
28 public class PropertyRule extends ToscaDataDefinition {
30 public final static String FORCE_ALL = "FORCE_ALL";
31 public final static String ALL = "ALL";
32 public final static String RULE_ANY_MATCH = ".+";
37 public PropertyRule() {
41 public PropertyRule(List<String> rule, String value) {
47 public List<String> getRule() {
51 public void setRule(List<String> rule) {
55 public String getValue() {
59 public void setValue(String value) {
64 public String getFirstToken() {
68 public String getToken(int tokenNumber) {
70 int index = tokenNumber - 1;
71 if (rule == null || index >= rule.size() || index < 0) {
75 return rule.get(index);
79 public int getRuleSize() {
87 public String toString() {
88 return "PropertyRule [rule=" + rule + ", value=" + value + "]";
91 public boolean compareRule(PropertyRule comparedPropertyRule) {
93 if (comparedPropertyRule == null) {
97 List<String> comparedRule = comparedPropertyRule.getRule();
98 if (rule == null && comparedRule == null) {
102 if (rule != null && comparedRule != null) {
103 if (rule.size() != comparedRule.size()) {
106 int size = rule.size();
107 boolean isEqual = true;
108 for (int i = 0; i < size; i++) {
109 String item = rule.get(i);
110 String comparedItem = comparedRule.get(i);
111 if (item == null || !item.equals(comparedItem)) {
124 public void replaceFirstToken(String token) {
126 if (rule != null && rule.size() > 0) {