Reorganize dashboard into subfolders
[portal/ric-dashboard.git] / dashboard / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / model / RicRegion.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2020 AT&T Intellectual Property
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.oransc.ric.portal.dashboard.model;
22
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Objects;
26
27 /**
28  * Transport model for RIC region which has a list of instances.
29  */
30 public class RicRegion implements IDashboardResponse {
31
32         private String name;
33         private List<RicInstance> instances;
34
35         /**
36          * Builds an empty object.
37          */
38         public RicRegion() {
39                 // no-arg constructor
40         }
41
42         /**
43          * Convenience constructor for minimal value set.
44          * 
45          * @param name
46          *                 Name
47          */
48         public RicRegion(String name) {
49                 this.name = name;
50         }
51
52         public String getName() {
53                 return name;
54         }
55
56         public void setName(String s) {
57                 this.name = s;
58         }
59
60         public RicRegion name(String name) {
61                 this.name = name;
62                 return this;
63         }
64
65         public List<RicInstance> getInstances() {
66                 return instances;
67         }
68
69         public void setInstances(List<RicInstance> instances) {
70                 this.instances = instances;
71         }
72
73         /**
74          * Gets a list of key-name pairs.
75          * 
76          * @return List of RicInstanceKeyName objects.
77          */
78         public List<RicInstanceKeyName> getKeyNameList() {
79                 List<RicInstanceKeyName> list = new ArrayList<>();
80                 for (RicInstance i : instances)
81                         list.add(i.toKeyName());
82                 return list;
83         }
84
85         @Override
86         public String toString() {
87                 return this.getClass().getSimpleName() + "[name=" + getName() + ", instances=" + instances + "]";
88         }
89
90         @Override
91         public int hashCode() {
92                 final int prime = 31;
93                 int result = 1;
94                 result = prime * result + ((name == null) ? 0 : name.hashCode());
95                 result = result * result + ((instances == null) ? 0 : instances.hashCode());
96                 return result;
97         }
98
99         @Override
100         public boolean equals(Object obj) {
101                 if (this == obj)
102                         return true;
103                 if (obj == null)
104                         return false;
105                 if (getClass() != obj.getClass())
106                         return false;
107                 RicRegion other = (RicRegion) obj;
108                 return Objects.equals(name, other.name) && instances.size() == other.instances.size();
109         }
110
111 }