2 * ============LICENSE_START=======================================================
3 * PNF-REGISTRATION-HANDLER
4 * ================================================================================
5 * Copyright (C) 2018 Nokia. 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=========================================================
20 package org.onap.pnfsimulator.simulator.keywords;
23 import io.vavr.Tuple1;
24 import io.vavr.match.annotation.Patterns;
25 import io.vavr.match.annotation.Unapply;
26 import java.util.Collections;
27 import java.util.List;
28 import java.util.regex.Pattern;
36 public class NonParameterKeyword extends Keyword {
38 public static final int KEYWORD_NAME_GROUP = 2;
40 private static final String KEYWORD_REGEX = new StringBuilder()
41 .append(OPTIONAL.apply(NONLETTERS_REGEX))
43 .append(LETTERS_REGEX)
45 .append(OPTIONAL.apply(NONLETTERS_REGEX))
48 private NonParameterKeyword(String name, List<String> meaningfulParts) {
49 super(name, meaningfulParts);
53 static Tuple1<NonParameterKeyword> nonParameterKeyword(String keyword) {
54 val matcher = Pattern.compile(KEYWORD_REGEX).matcher(keyword);
55 NonParameterKeyword npk = null;
57 npk = new NonParameterKeyword(
58 matcher.group(KEYWORD_NAME_GROUP),
59 extractPartsFrom(matcher, Collections.emptyList())