/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019,2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Pattern;
import org.onap.policy.common.utils.validation.Assertions;
/**
private static final int LOCAL_NAME_FIELD = 3;
@Column(name = PARENT_KEY_NAME, length = 120)
+ @NotNull
+ @Pattern(regexp = NAME_REGEXP)
private String parentKeyName;
@Column(name = PARENT_KEY_VERSION, length = 15)
+ @NotNull
+ @Pattern(regexp = VERSION_REGEXP)
private String parentKeyVersion;
@Column(name = PARENT_LOCAL_NAME, length = 120)
+ @NotNull
+ @Pattern(regexp = LOCAL_NAME_REGEXP)
private String parentLocalName;
@Column(name = LOCAL_NAME, length = 120)
+ @NotNull
+ @Pattern(regexp = LOCAL_NAME_REGEXP)
private String localName;
/**
@Override
public boolean isNullKey() {
- return this.equals(PfReferenceKey.getNullKey());
+ return (PfReferenceKey.NULL_KEY_NAME.equals(this.getParentKeyName()) && PfReferenceKey.NULL_KEY_VERSION
+ .equals(this.getParentKeyVersion()) && PfReferenceKey.NULL_KEY_NAME.equals(this.getParentLocalName())
+ && PfReferenceKey.NULL_KEY_NAME.equals(this.getLocalName()));
}
/**
return this.getParentConceptKey().isNewerThan(otherReferenceKey.getParentConceptKey());
}
- @Override
- public ValidationResult validate(@NonNull String fieldName) {
- BeanValidationResult result = new BeanValidationResult(fieldName, this);
-
- result.addResult(validateRegex(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP));
- result.addResult(validateRegex(PARENT_KEY_VERSION, parentKeyVersion, VERSION_REGEXP));
- result.addResult(validateRegex(PARENT_LOCAL_NAME, parentLocalName, LOCAL_NAME_REGEXP));
- result.addResult(validateRegex(LOCAL_NAME, localName, LOCAL_NAME_REGEXP));
-
- return result;
- }
-
@Override
public void clean() {
parentKeyName = Assertions.validateStringParameter(PARENT_KEY_NAME, parentKeyName, NAME_REGEXP);