DCAE-D be initial commit
[sdc/dcae-d/dt-be-main.git] / dcaedt_catalog / service / src / main / java / org / onap / sdc / dcae / catalog / engine / ElementsLookup.java
1 package org.onap.sdc.dcae.catalog.engine;
2
3 import java.util.Map;
4 import java.util.Collections;
5
6 import org.json.JSONObject;
7 import org.onap.sdc.dcae.catalog.engine.CatalogRequest;
8
9 import com.fasterxml.jackson.annotation.JsonIgnore;
10
11 /** 
12  */
13 public class ElementsLookup extends CatalogRequest {
14
15         private String                                          annotation;
16         private Map<String,Object> selector;
17
18         public void setAnnotation(String theAnnon) {
19                 this.annotation = theAnnon;
20         }
21
22         public String getAnnotation() {
23                 return this.annotation;
24         }
25
26         public Map<String,Object> getSelector() {
27                 return this.selector == null ? Collections.EMPTY_MAP : this.selector;
28         }
29
30         public void setSelector(Map<String,Object> theSelector) {
31                 this.selector = theSelector;
32         }
33
34         public Object getSelectorEntry(String theName) {
35                 return getSelector().get(theName);
36         }
37
38         /**
39    * Because the JSONObject(Map) constructor would not copy entries wth null values.
40    */
41         @JsonIgnore
42         public JSONObject getJSONSelector() {
43                 JSONObject jsonSelector = new JSONObject();
44                 for (Map.Entry<String, Object> entry: this.selector.entrySet()) {
45                         jsonSelector.put(entry.getKey(), entry.getValue() != null ? entry.getValue() : JSONObject.NULL);
46                 }
47                 return jsonSelector;
48         }
49 }