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.translator.datatypes.heattotosca;
23 import org.apache.commons.collections.CollectionUtils;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.regex.Pattern;
29 public class PropertyRegexMatcher {
30 private String propertyName;
31 private List<Pattern> regexPatterns;
32 private String stringToSearchForPropertyValue;
35 * Constractor for creating PropertyRegexMatcher.
36 * @param propertyName property name
37 * @param regexPatterns regex pattern
38 * @param stringToSearchForPropertyValue string for search in the property value manipulation
40 public PropertyRegexMatcher(String propertyName,
41 List<String> regexPatterns,
42 String stringToSearchForPropertyValue) {
43 this.propertyName = propertyName;
44 setRegex(regexPatterns);
45 this.stringToSearchForPropertyValue = stringToSearchForPropertyValue;
48 public String getPropertyName() {
52 public void setPropertyName(String propertyName) {
53 this.propertyName = propertyName;
59 * @param regexPatterns the regex patterns
61 public void setRegex(List<String> regexPatterns) {
62 if (CollectionUtils.isEmpty(this.regexPatterns)) {
63 this.regexPatterns = new ArrayList<>();
66 for (String regexPattern : regexPatterns) {
67 this.regexPatterns.add(Pattern.compile(regexPattern));
71 public List<Pattern> getRegexPatterns() {
75 public String getStringToSearchForPropertyValue() {
76 return stringToSearchForPropertyValue;
79 public void setStringToSearchForPropertyValue(String stringToSearchForPropertyValue) {
80 this.stringToSearchForPropertyValue = stringToSearchForPropertyValue;