diff options
-rw-r--r-- | models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java index a98a7ac54..5f38a395a 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. 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. @@ -331,30 +332,37 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex if (conceptKey.isNullVersion()) { return get(conceptKey.getName()); } else { - return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKey); + return new PfConceptGetterImpl<>(getNavigableConceptMap()).get(conceptKey); } } @Override public C get(final String conceptKeyName) { - return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKeyName); + return new PfConceptGetterImpl<>(getNavigableConceptMap()).get(conceptKeyName); } @Override public C get(final String conceptKeyName, final String conceptKeyVersion) { - return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).get(conceptKeyName, - conceptKeyVersion); + return new PfConceptGetterImpl<>(getNavigableConceptMap()).get(conceptKeyName, conceptKeyVersion); } @Override public Set<C> getAll(final String conceptKeyName) { - return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).getAll(conceptKeyName); + return new PfConceptGetterImpl<>(getNavigableConceptMap()).getAll(conceptKeyName); } @Override public Set<C> getAll(final String conceptKeyName, final String conceptKeyVersion) { - return new PfConceptGetterImpl<>((NavigableMap<PfConceptKey, C>) conceptMap).getAll(conceptKeyName, - conceptKeyVersion); + return new PfConceptGetterImpl<>(getNavigableConceptMap()).getAll(conceptKeyName, conceptKeyVersion); + } + + /** + * Get the concept map as a NavigableMap object. + * + * @return NavigableMap conceptMap instance. + */ + private NavigableMap<PfConceptKey, C> getNavigableConceptMap() { + return new TreeMap<>(conceptMap); } /** @@ -386,4 +394,4 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex + keyFieldValue + " does not match the value " + conceptField + " in the concept field"); } } -} +}
\ No newline at end of file |