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.fluent.index.impl;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.onap.aai.champcore.model.ChampField;
27 import org.onap.aai.champcore.model.ChampObject;
28 import org.onap.aai.champcore.model.ChampObjectIndex;
29 import org.onap.aai.champcore.model.fluent.BuildStep;
30 import org.onap.aai.champcore.model.fluent.index.CreateObjectIndexable;
31 import org.onap.aai.champcore.model.fluent.index.ObjectIndexFieldStep;
32 import org.onap.aai.champcore.model.fluent.index.ObjectIndexTypeStep;
34 public final class CreateObjectIndexableImpl implements CreateObjectIndexable {
37 public ObjectIndexTypeStep ofName(String name) {
38 return new ObjectIndexTypeStep() {
41 public ObjectIndexFieldStep onType(String objectType) {
42 return new ObjectIndexFieldStep() {
45 public BuildStep<ChampObjectIndex> forFields(List<String> fieldNames) {
46 return new BuildStep<ChampObjectIndex> () {
49 public ChampObjectIndex build() {
50 List<ChampField> fields = new ArrayList<ChampField>();
51 for (String fn : fieldNames) {
52 fields.add(new ChampField.Builder(fn).build());
54 return new ChampObjectIndex.Builder(
55 name, objectType, fields).build();
63 public ObjectIndexFieldStep onAnyType() {
64 return new ObjectIndexFieldStep() {
67 public BuildStep<ChampObjectIndex> forFields(List<String> fieldNames) {
68 return new BuildStep<ChampObjectIndex> () {
71 public ChampObjectIndex build() {
72 List<ChampField> fields = new ArrayList<ChampField>();
73 for (String fn : fieldNames) {
74 fields.add(new ChampField.Builder(fn).build());
76 return new ChampObjectIndex.Builder(
77 name, ChampObject.ReservedTypes.ANY.toString(), fields).build();