summaryrefslogtreecommitdiffstats
path: root/dcaedt_catalog/commons/src/main/java/org/onap/sdc/dcae/catalog/commons/Proxies.java
blob: 898359967f59b0a0f70bacc1ad1eaa63d6cb4582 (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
package org.onap.sdc.dcae.catalog.commons;

import java.util.Map;
import java.lang.reflect.ParameterizedType;

import org.json.JSONObject;

import org.onap.sdc.dcae.catalog.commons.ProxyBuilder;


public class Proxies {

	private Proxies() {
	}


	private static ProxyBuilder builder = new ProxyBuilder();

	public static <T> T build(Map theData, Class<T> theType) {
		return builder.build(new JSONObject(theData), theType);
	}
	
	public static <T> T build(Map theData, Map theContextData, Class<T> theType) {
		return builder.build(new JSONObject(theData), theContextData, theType);
	}

	public static <T> T build(JSONObject theData, Class<T> theType) {
		return builder.build(theData, theType);
	}

	public static <T> Class<T> typeArgument(Class theType) {
		return (Class<T>)	
						((ParameterizedType)theType.getGenericSuperclass()).
							getActualTypeArguments()[0];
	}
  
}