Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / sync / entity / IndexableCrossEntityReference.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.sync.entity;
26
27 import java.util.ArrayList;
28
29 import org.onap.aai.sparky.util.NodeUtils;
30
31 import com.fasterxml.jackson.annotation.JsonIgnore;
32 import com.fasterxml.jackson.core.JsonProcessingException;
33
34
35 /**
36  * The Class IndexableCrossEntityReference.
37  */
38
39 public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
40
41   protected String crossReferenceEntityValues;
42   protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>();
43
44   /**
45    * Instantiates a new indexable cross entity reference.
46    */
47   public IndexableCrossEntityReference() {
48     super();
49   }
50
51   /**
52    * Adds the cross entity reference value.
53    *
54    * @param crossEntityReferenceValue the cross entity reference value
55    */
56   public void addCrossEntityReferenceValue(String crossEntityReferenceValue) {
57     if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) {
58       crossEntityReferenceCollection.add(crossEntityReferenceValue);
59     }
60   }
61
62   public String getCrossReferenceEntityValues() {
63     return crossReferenceEntityValues;
64   }
65
66   public void setCrossReferenceEntityValues(String crossReferenceEntityValues) {
67     this.crossReferenceEntityValues = crossReferenceEntityValues;
68   }
69
70   /*
71    * (non-Javadoc)
72    * 
73    * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
74    */
75   @Override
76   public void deriveFields() {
77     this.id = NodeUtils.generateUniqueShaDigest(link);
78     this.crossReferenceEntityValues = NodeUtils.concatArray(crossEntityReferenceCollection, ";");
79   }
80
81   @JsonIgnore // Since this is a "get" we need to JSON ignore otherwise it will be called when converting to JSON
82   @Override
83   public String getAsJson() throws JsonProcessingException {
84
85     return NodeUtils.convertObjectToJson(this, false);
86
87   }
88
89   @Override
90   public String toString() {
91     return "IndexableCrossEntityReference ["
92         + (crossReferenceEntityValues != null
93             ? "crossReferenceEntityValues=" + crossReferenceEntityValues + ", " : "")
94         + (crossEntityReferenceCollection != null
95             ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "");
96   }
97 }