Java 17 Upgrade
[policy/models.git] / models-base / src / main / java / org / onap / policy / models / base / PfConceptKey.java
index 5e3295e..cda2bbf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.models.base;
 
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import java.io.Serial;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.NonNull;
+import lombok.ToString;
+import org.onap.policy.common.parameters.annotations.Pattern;
 import org.onap.policy.common.utils.validation.Assertions;
 
 /**
- * An concept key uniquely identifies every first order entity in the system. Every first order concept in the system
+ * A concept key uniquely identifies every first order entity in the system. Every first order concept in the system
  * must have an {@link PfConceptKey} to identify it. Concepts that are wholly contained in another concept are
  * identified using a {@link PfReferenceKey} key.
  *
@@ -39,13 +42,17 @@ import org.onap.policy.common.utils.validation.Assertions;
 @Embeddable
 @Getter
 @EqualsAndHashCode(callSuper = false)
+@ToString
 public class PfConceptKey extends PfKeyImpl {
+    @Serial
     private static final long serialVersionUID = 8932717618579392561L;
 
     @Column(name = NAME_TOKEN, length = 120)
+    @Pattern(regexp = NAME_REGEXP)
     private String name;
 
     @Column(name = VERSION_TOKEN, length = 20)
+    @Pattern(regexp = VERSION_REGEXP)
     private String version;
 
     /**
@@ -67,7 +74,7 @@ public class PfConceptKey extends PfKeyImpl {
     /**
      * Constructor to create a key with the specified name and version.
      *
-     * @param name the key name
+     * @param name    the key name
      * @param version the key version
      */
     public PfConceptKey(final String name, final String version) {
@@ -96,12 +103,7 @@ public class PfConceptKey extends PfKeyImpl {
      *
      * @return a null concept key
      */
-    public static final PfConceptKey getNullKey() {
+    public static PfConceptKey getNullKey() {
         return new PfConceptKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION);
     }
-
-    @Override
-    public String toString() {
-        return "PfConceptKey(name=" + getName() + ", version=" + getVersion() + ")";
-    }
 }