2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.base;
24 * The key uniquely identifies every entity in the system. This class is an abstract class to give a
25 * common parent for all key types in the system.
27 public abstract class PfKey extends PfConcept {
28 private static final long serialVersionUID = 6281159885962014041L;
30 /** Regular expression to specify the structure of key names. */
31 public static final String NAME_REGEXP = "[A-Za-z0-9\\-_\\.]+";
33 /** Regular expression to specify the structure of key versions. */
34 public static final String VERSION_REGEXP = "[A-Za-z0-9.]+";
36 /** Regular expression to specify the structure of key IDs. */
37 public static final String KEY_ID_REGEXP = "[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]";
39 /** Specifies the value for names in NULL keys. */
40 public static final String NULL_KEY_NAME = "NULL";
42 /** Specifies the value for versions in NULL keys. */
43 public static final String NULL_KEY_VERSION = "0.0.0";
46 * This enumeration is returned on key compatibility checks.
48 public enum Compatibility {
49 /** The keys have different names. */
52 * The name of the key matches but the Major version number of the keys is different (x in
53 * x.y.z do not match).
57 * The name of the key matches but the Minor version number of the keys is different (y in
58 * x.y.z do not match).
62 * The name of the key matches but the Patch version number of the keys is different (z in
63 * x.y.z do not match).
66 /** The keys match completely. */
71 * Default constructor.
80 * @param copyConcept the concept to copy from
82 public PfKey(final PfKey copyConcept) {
87 public abstract String getId();
90 * Return the result of a compatibility check of two keys.
92 * @param otherKey the key to check compatibility against
93 * @return the compatibility result of the check
95 public abstract Compatibility getCompatibility(PfKey otherKey);
98 * Check if two keys are compatible, that is the keys are IDENTICAL or have only MINOR, PATCH
101 * @param otherKey the key to check compatibility against
102 * @return true, if the keys are compatible
104 public abstract boolean isCompatible(PfKey otherKey);