2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.model.api.type;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.Maps;
13 import java.util.Arrays;
15 import java.util.Optional;
16 import javax.annotation.Nonnull;
19 * Enum describing the effect of a YANG modifier statement.
22 * As of YANG 1.1 (RFC7950) there is only one modifier value available and that
23 * is "invert-match". If there are more possible values added in the future,
24 * this enum can be extended with more enum constants.
26 public enum ModifierKind {
27 INVERT_MATCH("invert-match");
29 private static final Map<String, ModifierKind> MODIFIER_KIND_MAP = Maps.uniqueIndex(
30 Arrays.asList(ModifierKind.values()), ModifierKind::getKeyword);
32 private final String keyword;
34 ModifierKind(final String keyword) {
35 this.keyword = Preconditions.checkNotNull(keyword);
39 * YANG keyword of this modifier.
41 * @return String that corresponds to the YANG keyword.
43 public @Nonnull String getKeyword() {
48 * Returns ModifierKind based on supplied Yang keyword.
51 * Yang keyword in string form
52 * @return ModifierKind based on supplied YANG keyword
53 * @throws NullPointerException if keyword is null
55 public static Optional<ModifierKind> parse(final String keyword) {
56 return Optional.ofNullable(MODIFIER_KIND_MAP.get(Preconditions.checkNotNull(keyword)));