summaryrefslogtreecommitdiffstats
path: root/common-be/src/main/java/org/openecomp/sdc/be/datatypes/tosca/ToscaDataDefinition.java
blob: d0f480b588b2726894c916b1fd80f8830e5f6a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package org.openecomp.sdc.be.datatypes.tosca;

import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonValue;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;

public abstract class ToscaDataDefinition {
	
	protected Map<String, Object> toscaPresentation;

	
	public ToscaDataDefinition(){
		toscaPresentation = new HashMap<String, Object>();
	}
	@JsonCreator
	public ToscaDataDefinition(Map<String, Object> art){
		toscaPresentation = art;
	}
	@JsonValue
	public Object getToscaPresentationValue(JsonPresentationFields name) {
		if (toscaPresentation != null && toscaPresentation.containsKey(name.getPresentation())) {
			return toscaPresentation.get(name.getPresentation());
		}
		return null;
	}
	
	public void setToscaPresentationValue(JsonPresentationFields name, Object value) {
		if (toscaPresentation == null && value !=null) {
			toscaPresentation = new HashMap<String, Object>();			
		}
		toscaPresentation.put(name.getPresentation(), value);
		
	}
	public void setOwnerIdIfEmpty(String ownerId){
		if (  getOwnerId() == null ){
			setOwnerId(ownerId);
		}
	}
	public void setOwnerId(String ownerId){
		setToscaPresentationValue(JsonPresentationFields.OWNER_ID, ownerId);
	}

	public String getOwnerId(){
		return (String) getToscaPresentationValue(JsonPresentationFields.OWNER_ID);
	}
}