Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / cloud / stack / src / main / java / org / iotivity / cloud / base / protocols / coap / enums / CoapMethod.java
1 package org.iotivity.cloud.base.protocols.coap.enums;
2
3 public enum CoapMethod {
4     GET(1), POST(2), PUT(3), DELETE(4);
5
6     public static CoapMethod valueOf(int code) {
7         switch (code) {
8             case 1:
9                 return CoapMethod.GET;
10
11             case 2:
12                 return CoapMethod.POST;
13
14             case 3:
15                 return CoapMethod.PUT;
16
17             case 4:
18                 return CoapMethod.DELETE;
19         }
20
21         throw new IllegalArgumentException("Invalid Method value");
22     }
23
24     private final int code;
25
26     private CoapMethod(int code) {
27         this.code = code;
28     }
29
30     public int getCode() {
31         return code;
32     }
33 }