diff options
author | Jim Hahn <jrh3@att.com> | 2019-03-22 14:12:03 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-03-25 10:33:34 -0400 |
commit | a8cd3141696d2a2258d90fc234eb6a2618b8731b (patch) | |
tree | be1fa429f936d68b3db9e8b69bed05fd072d52fb /models-pdp/src/main/java | |
parent | 2a245ef80e39a101015efb164de53f1753fa5d47 (diff) |
Add PolicyIdentOptVersion
Added additional PolicyIdentXxx classes. Added PdpDeployPolicies, which
makes use of it, thus eliminating the need for PdpPolicies, which will be
deleted once the PAP has been modified to use the new code.
Added Validated class to facilitate field validation.
Added utility methods to Validated class.
Use new validator methods in PolicyIdentXxx classes.
Use addError() method in validator class.
Use parameter types instead of "?".
Use static Validator instead of local.
Get "result" from each call to a validateXxx() method.
Derived PolicyIdentOptVersion from PfConceptKey.
Moved PolicyIdent classes to models-pdp.
Added PolicyIdent classes to models-pap.
Also removed copy constructors from classes in models-pap, as those
are plain POJOs that will not be copied. Copy constructors will be
added to new classes that will be added to models-pdp in a separate
review.
Forgot to include the new Ident classes in models-pap.
Change-Id: I923132c464c7802ee3e9225685cde44f36c64620
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/main/java')
4 files changed, 161 insertions, 1 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java index f7b911fc4..814d35732 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java @@ -25,7 +25,6 @@ import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.models.base.keys.PolicyTypeIdent; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpMessageType; import org.onap.policy.models.pdp.enums.PdpState; diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java new file mode 100644 index 000000000..6d6b6fedd --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdent.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.base.Validated; + +/** + * Identifies a policy. Both the name and version must be non-null. + */ +@NonNull +@NoArgsConstructor +public class PolicyIdent extends PfConceptKey { + private static final long serialVersionUID = 1L; + private static final Validated validator = new Validated(); + + public PolicyIdent(String name, String version) { + super(name, version); + } + + public PolicyIdent(PolicyIdent source) { + super(source); + } + + @Override + public PfValidationResult validate(PfValidationResult result) { + return super.validate(validator.validateNotNull(this, result)); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java new file mode 100644 index 000000000..a68a271f2 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyIdentOptVersion.java @@ -0,0 +1,61 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.base.Validated; + +/** + * Policy identifier with an optional version; only the "name" is required. + */ +@NonNull +@NoArgsConstructor +public class PolicyIdentOptVersion extends PfConceptKey { + private static final long serialVersionUID = 1L; + private static final Validated validator = new Validated(); + + + public PolicyIdentOptVersion(PolicyIdentOptVersion source) { + super(source); + } + + /** + * Validates the object. + * + * @param resultIn where to place any errors + * @return a validation result + */ + public PfValidationResult validate(@NonNull final PfValidationResult resultIn) { + PfValidationResult result = resultIn; + + String name = getName(); + if (PfConceptKey.NULL_KEY_NAME.equals(name)) { + validator.addError(this, "name", result, "null"); + } + result = validator.validateText(this, "name", name, PfKey.NAME_REGEXP, result); + + return validator.validateText(this, "version", getVersion(), PfKey.VERSION_REGEXP, result); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java new file mode 100644 index 000000000..ef67de86e --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PolicyTypeIdent.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.base.Validated; + +/** + * Identifies a policy type. Both the name and version must be non-null. + */ +@NonNull +@NoArgsConstructor +public class PolicyTypeIdent extends PfConceptKey { + private static final long serialVersionUID = 1L; + private static final Validated validator = new Validated(); + + public PolicyTypeIdent(String name, String version) { + super(name, version); + } + + public PolicyTypeIdent(PolicyTypeIdent source) { + super(source); + } + + @Override + public PfValidationResult validate(PfValidationResult result) { + return super.validate(validator.validateNotNull(this, result)); + } +} |