2 * ============LICENSE_START==========================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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============================================
21 package org.onap.aai.champcore.model;
23 import java.util.List;
24 import java.util.Objects;
25 import org.onap.aai.champcore.model.fluent.index.CreateObjectIndexable;
26 import org.onap.aai.champcore.model.fluent.index.impl.CreateObjectIndexableImpl;
28 public final class ChampObjectIndex {
30 private final String name;
31 private final String type;
32 private final List<ChampField> fields;
34 public static CreateObjectIndexable create() {
35 return new CreateObjectIndexableImpl();
38 private ChampObjectIndex() {
39 throw new RuntimeException("Cannot call ChampObjectIndex() constructor");
42 private ChampObjectIndex(Builder builder) {
43 this.name = builder.name;
44 this.type = builder.type;
45 this.fields = builder.fields;
48 public String getName() { return name; }
49 public String getType() { return type; }
50 public List<ChampField> getFields() { return fields; }
52 public static class Builder {
53 private final String name;
54 private final String type;
55 private final List<ChampField> fields;
57 public Builder(String name, String type, List<ChampField> fields) {
63 public ChampObjectIndex build() {
64 return new ChampObjectIndex(this);
69 public String toString() {
70 return "{name: " + getName()
71 + ", type: " + getType()
72 + ", fields: " + getFields() + "}";
76 public boolean equals(Object object) {
77 if (this == object) return true;
79 if (object instanceof ChampObjectIndex) {
80 final ChampObjectIndex objectIndex = (ChampObjectIndex) object;
82 if ( getName().equals(objectIndex.getName()) && (getFields().hashCode() == objectIndex.getFields().hashCode()) ) {
91 public int hashCode() {
92 return Objects.hash(getName(), getFields().hashCode());