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
8 package org.opendaylight.yangtools.yang.model.api.type;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.Maps;
13 import java.util.Arrays;
15 import java.util.Optional;
16 import org.eclipse.jdt.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 is "invert-match". If there are more
23 * possible values added in the future, this enum can be extended with more enum constants.
25 public enum ModifierKind {
26 INVERT_MATCH("invert-match");
28 private static final Map<String, ModifierKind> MODIFIER_KIND_MAP = Maps.uniqueIndex(
29 Arrays.asList(ModifierKind.values()), ModifierKind::getKeyword);
31 private final @NonNull String keyword;
33 ModifierKind(final @NonNull String keyword) {
34 this.keyword = requireNonNull(keyword);
38 * YANG keyword of this modifier.
40 * @return String that corresponds to the YANG keyword.
42 public @NonNull String getKeyword() {
47 * Returns ModifierKind based on supplied YANG keyword.
49 * @param keyword YANG keyword in string form
50 * @return ModifierKind based on supplied YANG keyword
51 * @throws NullPointerException if keyword is null
53 public static Optional<ModifierKind> parse(final @NonNull String keyword) {
54 return Optional.ofNullable(MODIFIER_KIND_MAP.get(requireNonNull(keyword)));