JUnit test for policy/engine PolicyEngineAPI
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / onap / policy / std / Matches.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.std;
22
23 import java.util.Map;
24
25 public class Matches {
26     private String onapName = null;
27
28     private String configName = null;
29
30     private Map<String, String> configAttributes = null;
31
32     public String getOnapName() {
33         return onapName;
34     }
35
36     public void setOnapName(final String onapName) {
37         this.onapName = onapName;
38     }
39
40     public String getConfigName() {
41         return configName;
42     }
43
44     public void setConfigName(final String configName) {
45         this.configName = configName;
46     }
47
48     public Map<String, String> getConfigAttributes() {
49         return configAttributes;
50     }
51
52     public void setConfigAttributes(final Map<String, String> configAttributes) {
53         this.configAttributes = configAttributes;
54     }
55
56     @Override
57     public int hashCode() {
58         final int prime = 31;
59         int result = 1;
60         result = prime * result + ((configAttributes == null) ? 0 : configAttributes.hashCode());
61         result = prime * result + ((configName == null) ? 0 : configName.hashCode());
62         result = prime * result + ((onapName == null) ? 0 : onapName.hashCode());
63         return result;
64     }
65
66     @Override
67     public boolean equals(final Object obj) {
68         if (obj instanceof Matches) {
69             final Matches other = (Matches) obj;
70             return isEqual(onapName, other.onapName) && isEqual(configName, other.configName)
71                     && isEqual(configAttributes, other.configAttributes);
72         }
73         return false;
74     }
75
76     private boolean isEqual(final Object objectA, final Object objectB) {
77         if (objectA == null) {
78             return objectB == null;
79         }
80         return objectA.equals(objectB);
81     }
82
83 }