Update license date and text
[aai/champ.git] / champ-lib / champ-core / src / main / java / org / onap / aai / champcore / model / ChampObjectIndex.java
1 /**
2  * ============LICENSE_START==========================================
3  * org.onap.aai
4  * ===================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 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  */
21 package org.onap.aai.champcore.model;
22
23 import org.onap.aai.champcore.model.fluent.index.CreateObjectIndexable;
24 import org.onap.aai.champcore.model.fluent.index.impl.CreateObjectIndexableImpl;
25
26 public final class ChampObjectIndex {
27
28         private final String name;
29         private final String type;
30         private final ChampField field;
31
32         public static CreateObjectIndexable create() {
33                 return new CreateObjectIndexableImpl();
34         }
35
36         private ChampObjectIndex() {
37                 throw new RuntimeException("Cannot call ChampObjectIndex() constructor");
38         }
39
40         private ChampObjectIndex(Builder builder) {
41                 this.name = builder.name;
42                 this.type = builder.type;
43                 this.field = builder.field;
44         }
45
46         public String getName() { return name; }
47         public String getType() { return type; }
48         public ChampField getField() { return field; }
49
50         public static class Builder {
51                 private final String name;
52                 private final String type;
53                 private final ChampField field;
54
55                 public Builder(String name, String type, ChampField field) {
56                         this.name = name;
57                         this.type = type;
58                         this.field = field;
59                 }
60
61                 public ChampObjectIndex build() {
62                         return new ChampObjectIndex(this);
63                 }
64         }
65
66         @Override
67         public String toString() {
68                 return "{name: " + getName()
69                         + ", type: " + getType()
70                         + ", field: " + getField() + "}";
71         }
72
73         @Override
74         public boolean equals(Object object) {
75                 if (this == object) return true;
76                 
77                 if (object instanceof ChampObjectIndex) {
78                         final ChampObjectIndex objectIndex = (ChampObjectIndex) object;
79                         
80                         if (getName().equals(objectIndex.getName()) &&
81                                 getField().getName().equals(objectIndex.getField().getName())) return true;
82                 }
83                 
84                 return false;
85         }
86 }