2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
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.apex.model.contextmodel.handling;
23 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
24 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
25 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
26 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
27 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
28 import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
29 import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
32 * This class compares the context in two AxContext objects and returns the differences. The
33 * differences are returned in a {@link KeyedMapDifference} object that contains the left, equal,
34 * and right context schemas or albums.
36 * @author Liam Fallon (liam.fallon@ericsson.com)
38 public class ContextComparer {
41 * Compare two {@link AxContextAlbums} objects, comparing their context albums one after
44 * @param left the left context
45 * @param right the right context
46 * @return the difference
48 public KeyedMapDifference<AxArtifactKey, AxContextAlbum> compare(final AxContextAlbums left,
49 final AxContextAlbums right) {
50 // Find the difference between the AxContext objects
51 return new KeyedMapComparer<AxArtifactKey, AxContextAlbum>().compareMaps(left.getAlbumsMap(),
52 right.getAlbumsMap());
56 * Compare two {@link AxContextSchema} objects, comparing their context schemas one after
59 * @param left the left context
60 * @param right the right context
61 * @return the difference
63 public KeyedMapDifference<AxArtifactKey, AxContextSchema> compare(final AxContextSchemas left,
64 final AxContextSchemas right) {
65 // Find the difference between the AxContext objects
66 return new KeyedMapComparer<AxArtifactKey, AxContextSchema>().compareMaps(left.getSchemasMap(),
67 right.getSchemasMap());