15a913a4c4efacc4c1e66ebf8cea14f266aff84f
[so.git] / cloudify-client / src / main / java / org / onap / so / cloudify / base / client / Entity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.cloudify.base.client;
22
23 public class Entity<T> {
24         
25         private T entity;
26         
27         private String contentType;
28         
29         public static <T> Entity<T> json(T entity) {
30                 return new Entity<T>(entity, "application/json");
31         }
32         
33         public static <T> Entity<T> stream(T entity) {
34                 return new Entity<T>(entity, "application/octet-stream");
35         }
36
37         public Entity(T entity, String contentType) {
38                 super();
39                 this.entity = entity;
40                 this.contentType = contentType;
41         }
42
43         /**
44          * @return the entity
45          */
46         public T getEntity() {
47                 return entity;
48         }
49
50         /**
51          * @param entity the entity to set
52          */
53         public void setEntity(T entity) {
54                 this.entity = entity;
55         }
56
57         /**
58          * @return the contentType
59          */
60         public String getContentType() {
61                 return contentType;
62         }
63
64         /**
65          * @param contentType the contentType to set
66          */
67         public void setContentType(String contentType) {
68                 this.contentType = contentType;
69         }
70         
71 }