2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.meta;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import com.google.common.base.MoreObjects.ToStringHelper;
15 import java.util.Optional;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.opendaylight.yangtools.yang.common.QName;
21 * Abstract utility class to handle StatementArgumentDefinition aspect of {@link StatementDefinition}. Most users should
22 * use this class or {@link DefaultStatementDefinition}.
26 public abstract class AbstractStatementDefinition implements StatementDefinition {
27 private final QName statementName;
28 private final @Nullable QName argumentName;
29 private final boolean yinElement;
31 protected AbstractStatementDefinition(final QName statementName) {
32 this(statementName, false, null);
35 protected AbstractStatementDefinition(final QName statementName, final boolean yinElement,
36 final @Nullable QName argumentName) {
37 this.statementName = requireNonNull(statementName);
38 this.yinElement = yinElement;
39 this.argumentName = argumentName;
43 public final QName getStatementName() {
48 public final Optional<ArgumentDefinition> getArgumentDefinition() {
49 return ArgumentDefinition.ofNullable(argumentName, yinElement);
53 public final String toString() {
54 return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
57 protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
58 helper.add("name", statementName);
59 if (argumentName != null) {
60 helper.add("argument", argumentName).add("yin-element", yinElement);