Cleanup documentation warnings in RcsSetResponse.java
[platform/upstream/iotivity.git] / service / resource-encapsulation / android / service / src / main / java / org / iotivity / service / server / RcsSetResponse.java
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
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  *
19  ******************************************************************/
20
21 package org.iotivity.service.server;
22
23 import org.iotivity.service.RcsResourceAttributes;
24
25 /**
26  * This class provides methods to create the response for a received set
27  * request.
28  *
29  * @see RcsResourceObject
30  * @see RcsSetResponse
31  */
32 public final class RcsSetResponse extends RcsResponse {
33     /**
34      * Options for handling a set request.
35      *
36      * This overrides {@link RcsResourceObject.SetRequestHandlerPolicy}.
37      *
38      */
39     public enum AcceptanceMethod {
40         /**
41          * Follow {@link RcsResourceObject.SetRequestHandlerPolicy}.
42          */
43         DEFAULT,
44
45         /**
46          * Accept the request attributes even if there is an unknown key or
47          * mismatched type.
48          */
49         ACCEPT,
50
51         /**
52          * Ignore the request attributes.
53          */
54         IGNORE
55     };
56
57     private AcceptanceMethod mAcceptanceMethod = AcceptanceMethod.DEFAULT;
58
59     /**
60      * Creates a default RcsSetResponse with {@link AcceptanceMethod#DEFAULT}.
61      * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
62      * attributes of {@link RcsResourceObject} will be set as the result
63      * attributes.
64      * @return the created default RcsSetResponse
65      */
66     public static RcsSetResponse defaultAction() {
67         return new RcsSetResponse();
68     }
69
70     /**
71      * Creates a default RcsSetResponse with {@link AcceptanceMethod#ACCEPT}
72      * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
73      * attributes of {@link RcsResourceObject} will be set as the result
74      * attributes.
75      *
76      * @return the created default RcsSetResponse
77      */
78     public static RcsSetResponse accept() {
79         return new RcsSetResponse()
80                 .setAcceptanceMethod(AcceptanceMethod.ACCEPT);
81     }
82
83     /**
84      * Creates a RcsSetResponse with {@link AcceptanceMethod#ACCEPT} and error
85      * code passed.
86      * The attributes of the {@link RcsResourceObject} will be set as the result
87      * attributes.
88      *
89      * @param errorCode
90      *            error code to be set in response
91      * @return the created RcsSetResponse
92      */
93     public static RcsSetResponse accept(int errorCode) {
94         return new RcsSetResponse(errorCode)
95                 .setAcceptanceMethod(AcceptanceMethod.ACCEPT);
96     }
97
98     /**
99      * Creates a default RcsSetResponse with {@link AcceptanceMethod#IGNORE}.
100      * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
101      * attributes of {@link RcsResourceObject} will be set as the result
102      * attributes.
103      *
104      * @return the created default RcsSetResponse
105      */
106     public static RcsSetResponse ignore() {
107         return new RcsSetResponse()
108                 .setAcceptanceMethod(AcceptanceMethod.IGNORE);
109     }
110
111     /**
112      * Creates a RcsSetResponse with {@link AcceptanceMethod#IGNORE} and error
113      * code passed. The attributes of the {@link RcsResourceObject} will be set
114      * as the result attributes.
115      *
116      * @param errorCode
117      *            error code to be set in response
118      * @return the created RcsSetResponse
119      */
120     public static RcsSetResponse ignore(int errorCode) {
121         return new RcsSetResponse(errorCode)
122                 .setAcceptanceMethod(AcceptanceMethod.IGNORE);
123     }
124
125     /**
126      * Creates a RcsSetResponse with error code passed and
127      * {@link AcceptanceMethod#DEFAULT}. The attributes of the
128      * {@link RcsResourceObject} will be set as the result attributes.
129      *
130      * @param errorCode
131      *            error code to be set in response
132      * @return the created RcsSetResponse
133      */
134     public static RcsSetResponse create(int errorCode) {
135         return new RcsSetResponse(errorCode);
136     }
137
138     /**
139      * Creates a RcsSetResponse with custom attributes and
140      * {@link AcceptanceMethod#DEFAULT}. This sends the passed attributes as the
141      * result attributes instead of one the {@link RcsResourceObject} holds.
142      *
143      * @param attributes
144      *            attributes to be sent as the result
145      * @return the created RcsSetResponse
146      */
147     public static RcsSetResponse create(RcsResourceAttributes attributes) {
148         return new RcsSetResponse(attributes);
149     }
150
151     /**
152      * Creates a RcsSetResponse with error code passed and
153      * {@link AcceptanceMethod#DEFAULT}. This sends the passed attributes as the
154      * result attributes instead of one the {@link RcsResourceObject} holds.
155      *
156      * @param attributes
157      *            attributes to be sent as the result
158      * @param errorCode
159      *            error code for response
160      * @return the created RcsSetResponse
161      */
162     public static RcsSetResponse create(RcsResourceAttributes attributes,
163             int errorCode) {
164         return new RcsSetResponse(attributes, errorCode);
165     }
166
167     /**
168      * Get the acceptance method.
169      * @return the acceptance method
170      */
171     public AcceptanceMethod getAcceptanceMethod() {
172         return mAcceptanceMethod;
173     }
174
175     /**
176      * Sets the acceptance method.
177      *
178      * @param method
179      *            method to be set
180      *
181      * @return The reference to this RcsSetResponse
182      *
183      */
184     public RcsSetResponse setAcceptanceMethod(AcceptanceMethod method) {
185         mAcceptanceMethod = method;
186         return this;
187     }
188
189     private RcsSetResponse() {
190         super();
191     }
192
193     private RcsSetResponse(int errorCode) {
194         super(errorCode);
195     }
196
197     private RcsSetResponse(RcsResourceAttributes attrs) {
198         super(attrs);
199     }
200
201     private RcsSetResponse(RcsResourceAttributes attrs, int errorCode) {
202         super(attrs, errorCode);
203     }
204
205 }