DCAE-D be initial commit
[sdc/dcae-d/dt-be-main.git] / dcaedt_catalog / commons / src / main / java / org / onap / sdc / dcae / catalog / commons / Proxies.java
1 package org.onap.sdc.dcae.catalog.commons;
2
3 import java.util.Map;
4 import java.lang.reflect.ParameterizedType;
5
6 import org.json.JSONObject;
7
8 import org.onap.sdc.dcae.catalog.commons.ProxyBuilder;
9
10
11 public class Proxies {
12
13         private Proxies() {
14         }
15
16
17         private static ProxyBuilder builder = new ProxyBuilder();
18
19         public static <T> T build(Map theData, Class<T> theType) {
20                 return builder.build(new JSONObject(theData), theType);
21         }
22         
23         public static <T> T build(Map theData, Map theContextData, Class<T> theType) {
24                 return builder.build(new JSONObject(theData), theContextData, theType);
25         }
26
27         public static <T> T build(JSONObject theData, Class<T> theType) {
28                 return builder.build(theData, theType);
29         }
30
31         public static <T> Class<T> typeArgument(Class theType) {
32                 return (Class<T>)       
33                                                 ((ParameterizedType)theType.getGenericSuperclass()).
34                                                         getActualTypeArguments()[0];
35         }
36   
37 }