17a4ec16fdd18b5ddefda6453badf1d0fa1c6a2c
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / Status.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.api;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12
13 /**
14  * Enumeration describing YANG 'status' statement. If no status is specified, the
15  * default is CURRENT.
16  */
17 @NonNullByDefault
18 public enum Status {
19     /**
20      * CURRENT means that the definition is current and valid.
21      */
22     CURRENT("current"),
23     /**
24      * DEPRECATED indicates an obsolete definition, but it permits new/
25      * continued implementation in order to foster interoperability with
26      * older/existing implementations.
27      */
28     DEPRECATED("deprecated"),
29     /**
30      * OBSOLETE means the definition is obsolete and SHOULD NOT be implemented
31      * and/or can be removed from implementations.
32      */
33     OBSOLETE("obsolete");
34
35     private final String argumentString;
36
37     Status(final String argumentString) {
38         this.argumentString = argumentString;
39     }
40
41     @Beta
42     public String getArgumentString() {
43         return argumentString;
44     }
45
46     @Beta
47     public static Status forArgumentString(final String argumentString) {
48         switch (argumentString) {
49             case "current":
50                 return CURRENT;
51             case "deprecated":
52                 return DEPRECATED;
53             case "obsolete":
54                 return OBSOLETE;
55             default:
56                 throw new IllegalArgumentException("Invalid status string '" + argumentString + "'");
57         }
58     }
59 }