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 static java.util.Objects.requireNonNull;
13 import com.google.common.collect.Maps;
14 import java.util.Arrays;
16 import java.util.Optional;
17 import javax.annotation.Nonnull;
20 * Enum describing the effect of a YANG modifier statement.
23 * As of YANG 1.1 (RFC7950) there is only one modifier value available and that
24 * is "invert-match". If there are more possible values added in the future,
25 * this enum can be extended with more enum constants.
27 public enum ModifierKind {
28 INVERT_MATCH("invert-match");
30 private static final Map<String, ModifierKind> MODIFIER_KIND_MAP = Maps.uniqueIndex(
31 Arrays.asList(ModifierKind.values()), ModifierKind::getKeyword);
33 private final String keyword;
35 ModifierKind(final String keyword) {
36 this.keyword = requireNonNull(keyword);
40 * YANG keyword of this modifier.
42 * @return String that corresponds to the YANG keyword.
44 public @Nonnull String getKeyword() {
49 * Returns ModifierKind based on supplied Yang keyword.
52 * Yang keyword in string form
53 * @return ModifierKind based on supplied YANG keyword
54 * @throws NullPointerException if keyword is null
56 public static Optional<ModifierKind> parse(final String keyword) {
57 return Optional.ofNullable(MODIFIER_KIND_MAP.get(requireNonNull(keyword)));