Populate data/ hierarchy
[yangtools.git] / yang / rfc6643-model-api / src / main / java / org / opendaylight / yangtools / rfc6643 / model / api / MaxAccess.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc6643.model.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableMap;
14 import com.google.common.collect.Maps;
15 import java.util.Arrays;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.jdt.annotation.Nullable;
18
19 /**
20  * Maximum allowed access, as defined by
21  * <a href="https://tools.ietf.org/html/rfc2578#section-7.3">RFC2578 Section 7.3</a>.
22  */
23 @Beta
24 public enum MaxAccess {
25     /**
26      * Indicates the annotated object is an auxiliary object, as per
27      * <a href="https://tools.ietf.org/html/rfc2578#section-7.7">RFC2578 Section 7.7</a>.
28      */
29     NOT_ACCESSIBLE("not-accessible"),
30     /**
31      * Indicates the annotated object is accessible only for notifications.
32      */
33     ACCESSIBLE_FOR_NOTIFY("accessible-for-notify"),
34     /**
35      * Indicates that {@code read} access makes 'protocol sense', but  {@code write} and {@code create} do not.
36      */
37     READ_ONLY("read-only"),
38     /**
39      * Indicates that {@code read} and {@code write} access make 'protocol sense', but {@code create} does not.
40      */
41     READ_WRITE("read-write"),
42     /**
43      * Indicates that {@code read}, {@code write} and {@code create} access make 'protocol sense'.
44      */
45     READ_CREATE("read-create");
46
47     private static final ImmutableMap<String, MaxAccess> VALUES =
48             Maps.uniqueIndex(Arrays.asList(MaxAccess.values()), MaxAccess::stringLiteral);
49
50     private @NonNull String str;
51
52     MaxAccess(final @NonNull String str) {
53         this.str = str;
54     }
55
56     public @NonNull String stringLiteral() {
57         return str;
58     }
59
60     public static @Nullable MaxAccess forStringLiteral(final @NonNull String str) {
61         return VALUES.get(requireNonNull(str));
62     }
63 }