73cb0f227d349ec53794c4eb9a1231879e4ea10d
[aai/aai-common.git] / aai-core / src / main / java / org / openecomp / aai / restcore / MediaType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
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.openecomp.aai.restcore;
22
23 /**
24  * The Enum MediaType.
25  */
26 public enum MediaType {
27         APPLICATION_JSON_TYPE("application/json"),
28         APPLICATION_XML_TYPE("application/xml");
29         
30         private final String text;
31
32     /**
33      * Instantiates a new media type.
34      *
35      * @param text the text
36      */
37     private MediaType(final String text) {
38         this.text = text;
39     }
40     
41     /**
42      * Gets the enum.
43      *
44      * @param value the value
45      * @return the enum
46      */
47     public static MediaType getEnum(String value) {
48         
49         for(MediaType v : values()) {
50             if(v.toString().equalsIgnoreCase(value)) {
51                 return v;
52             } 
53         }
54         
55         throw new IllegalArgumentException("bad value: " + value);
56  
57     }
58     
59     /**
60          * @{inheritDoc}
61          */
62     @Override
63     public String toString() {
64         return text;
65     }
66 }