Renaming openecomp to onap
[aai/champ.git] / src / main / java / org / onap / aai / champ / model / ChampObjectIndex.java
1 /**
2  * ============LICENSE_START==========================================
3  * org.onap.aai
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ===================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.champ.model;
23
24 import org.onap.aai.champ.model.fluent.index.CreateObjectIndexable;
25 import org.onap.aai.champ.model.fluent.index.impl.CreateObjectIndexableImpl;
26
27 public final class ChampObjectIndex {
28
29         private final String name;
30         private final String type;
31         private final ChampField field;
32
33         public static CreateObjectIndexable create() {
34                 return new CreateObjectIndexableImpl();
35         }
36
37         private ChampObjectIndex() {
38                 throw new RuntimeException("Cannot call ChampObjectIndex() constructor");
39         }
40
41         private ChampObjectIndex(Builder builder) {
42                 this.name = builder.name;
43                 this.type = builder.type;
44                 this.field = builder.field;
45         }
46
47         public String getName() { return name; }
48         public String getType() { return type; }
49         public ChampField getField() { return field; }
50
51         public static class Builder {
52                 private final String name;
53                 private final String type;
54                 private final ChampField field;
55
56                 public Builder(String name, String type, ChampField field) {
57                         this.name = name;
58                         this.type = type;
59                         this.field = field;
60                 }
61
62                 public ChampObjectIndex build() {
63                         return new ChampObjectIndex(this);
64                 }
65         }
66
67         @Override
68         public String toString() {
69                 return "{name: " + getName()
70                         + ", type: " + getType()
71                         + ", field: " + getField() + "}";
72         }
73
74         @Override
75         public boolean equals(Object object) {
76                 if (this == object) return true;
77                 
78                 if (object instanceof ChampObjectIndex) {
79                         final ChampObjectIndex objectIndex = (ChampObjectIndex) object;
80                         
81                         if (getName().equals(objectIndex.getName()) &&
82                                 getField().getName().equals(objectIndex.getField().getName())) return true;
83                 }
84                 
85                 return false;
86         }
87 }