22056db341d393c2939ee4e443a2a45e6b992397
[policy/apex-pdp.git] /
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.context.test.concepts;
22
23 import java.io.Serializable;
24 import java.util.Arrays;
25 import java.util.Set;
26 import java.util.SortedSet;
27 import java.util.TreeSet;
28
29 /**
30  * The Class TestContextItem00B.
31  */
32 public class TestContextTreeSetItem implements Serializable {
33     private static final long serialVersionUID = 1254589722957250388L;
34
35     private static final int HASH_PRIME_1 = 31;
36
37     private SortedSet<String> setValue = new TreeSet<>();
38
39     /**
40      * The Constructor.
41      */
42     public TestContextTreeSetItem() {}
43
44     /**
45      * The Constructor.
46      *
47      * @param setArray the set array
48      */
49     public TestContextTreeSetItem(final String[] setArray) {
50         this.setValue = new TreeSet<>(Arrays.asList(setArray));
51     }
52
53     /**
54      * The Constructor.
55      *
56      * @param setValue the set value
57      */
58     public TestContextTreeSetItem(final SortedSet<String> setValue) {
59         this.setValue = setValue;
60     }
61
62     /**
63      * Gets the set value.
64      *
65      * @return the sets the value
66      */
67     public Set<String> getSetValue() {
68         if (setValue == null) {
69             setValue = new TreeSet<>();
70         }
71         return setValue;
72     }
73
74     /**
75      * Sets the set value.
76      *
77      * @param setValue the sets the value
78      */
79     public void setSetValue(final SortedSet<String> setValue) {
80         this.setValue = setValue;
81     }
82
83     /*
84      * (non-Javadoc)
85      *
86      * @see java.lang.Object#hashCode()
87      */
88     @Override
89     public int hashCode() {
90         final int prime = HASH_PRIME_1;
91         int result = 1;
92         result = prime * result + ((setValue == null) ? 0 : setValue.hashCode());
93         return result;
94     }
95
96     /*
97      * (non-Javadoc)
98      *
99      * @see java.lang.Object#equals(java.lang.Object)
100      */
101     @Override
102     public boolean equals(final Object obj) {
103         if (this == obj) {
104             return true;
105         }
106         if (obj == null) {
107             return false;
108         }
109         if (getClass() != obj.getClass()) {
110             return false;
111         }
112         final TestContextTreeSetItem other = (TestContextTreeSetItem) obj;
113         if (setValue == null) {
114             if (other.setValue != null) {
115                 return false;
116             }
117         } else if (!setValue.equals(other.setValue)) {
118             return false;
119         }
120         return true;
121     }
122
123     /*
124      * (non-Javadoc)
125      *
126      * @see java.lang.Object#toString()
127      */
128     @Override
129     public String toString() {
130         return "TestContextItem00B [setValue=" + setValue + "]";
131     }
132 }