+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api.stmt;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * References ABNF rule defined in RFC6020 - YANG Specification.
- *
- * <p>
- * An interface / class annotated with this annotation
- * is Java representation of data represented by ABNF rule
- * provided as {@link #value()}. Java representation
- * does not need to be direct,
- * but must retain all information in some, publicly
- * accessible form for consumers.
- * </p>
- * <p>
- * Note that this annotation is used currently only for documentation
- * and does not affect any runtime behaviour.
- * </p>
- */
-@Deprecated(since = "9.0.2", forRemoval = true)
-@Documented
-@Retention(RetentionPolicy.SOURCE)
-@interface Rfc6020AbnfRule {
-
- String[] value();
-}
package org.opendaylight.yangtools.yang.model.api.stmt;
import java.util.Collection;
-import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
/**
* Declared representation of a {@code type} statement.
*/
-@Rfc6020AbnfRule("type-stmt")
public interface TypeStatement extends DeclaredStatement<QName> {
@Override
default StatementDefinition statementDefinition() {
return YangStmtMapping.TYPE;
}
- @Rfc6020AbnfRule("numerical-restrictions")
// FIXME: 7.0.0: this interface does not have an implementation
interface NumericalRestrictions extends TypeStatement {
default @Nullable RangeStatement getRange() {
}
}
- @Rfc6020AbnfRule("decimal64-specification")
interface Decimal64Specification extends TypeStatement {
default @NonNull FractionDigitsStatement getFractionDigits() {
- return findFirstDeclaredSubstatement(FractionDigitsStatement.class).get();
+ return findFirstDeclaredSubstatement(FractionDigitsStatement.class).orElseThrow();
}
default @Nullable RangeStatement getRange() {
- final Optional<RangeStatement> opt = findFirstDeclaredSubstatement(RangeStatement.class);
- return opt.isPresent() ? opt.get() : null;
+ final var opt = findFirstDeclaredSubstatement(RangeStatement.class);
+ return opt.isPresent() ? opt.orElseThrow() : null;
}
}
- @Rfc6020AbnfRule("string-restrictions")
// FIXME: 7.0.0: this interface does not have an implementation
interface StringRestrictions extends TypeStatement {
default @Nullable LengthStatement getLength() {
- final Optional<LengthStatement> opt = findFirstDeclaredSubstatement(LengthStatement.class);
- return opt.isPresent() ? opt.get() : null;
+ final var opt = findFirstDeclaredSubstatement(LengthStatement.class);
+ return opt.isPresent() ? opt.orElseThrow() : null;
}
default @NonNull Collection<? extends PatternStatement> getPatterns() {
}
}
- @Rfc6020AbnfRule("enum-specification")
interface EnumSpecification extends TypeStatement {
-
default @NonNull Collection<? extends EnumStatement> getEnums() {
return declaredSubstatements(EnumStatement.class);
}
}
- @Rfc6020AbnfRule("leafref-specification")
interface LeafrefSpecification extends TypeStatement {
default @NonNull PathStatement getPath() {
- return findFirstDeclaredSubstatement(PathStatement.class).get();
+ return findFirstDeclaredSubstatement(PathStatement.class).orElseThrow();
}
/**
- * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
- * null.
+ * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns null.
*
* @return require-instance statement, if present.
*/
default @Nullable RequireInstanceStatement getRequireInstance() {
- final Optional<RequireInstanceStatement> opt =
- findFirstDeclaredSubstatement(RequireInstanceStatement.class);
- return opt.isPresent() ? opt.get() : null;
+ final var opt = findFirstDeclaredSubstatement(RequireInstanceStatement.class);
+ return opt.isPresent() ? opt.orElseThrow() : null;
}
}
- @Rfc6020AbnfRule("instanceidentifier-specification")
interface InstanceIdentifierSpecification extends TypeStatement {
/**
* Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
* @return require-instance statement, if present.
*/
default @Nullable RequireInstanceStatement getRequireInstance() {
- final Optional<RequireInstanceStatement> opt =
- findFirstDeclaredSubstatement(RequireInstanceStatement.class);
- return opt.isPresent() ? opt.get() : null;
+ final var opt = findFirstDeclaredSubstatement(RequireInstanceStatement.class);
+ return opt.isPresent() ? opt.orElseThrow() : null;
}
}
- @Rfc6020AbnfRule("identityref-specification")
interface IdentityRefSpecification extends TypeStatement {
/**
* Returns the base statements.
}
}
- @Rfc6020AbnfRule("bits-specification")
interface BitsSpecification extends TypeStatement {
default @NonNull Collection<? extends BitStatement> getBits() {
return declaredSubstatements(BitStatement.class);
}
}
- @Rfc6020AbnfRule("union-specification")
interface UnionSpecification extends TypeStatement {
default @NonNull Collection<? extends TypeStatement> getTypes() {
return declaredSubstatements(TypeStatement.class);
}
}
- @Rfc6020AbnfRule("binary-specification")
interface BinarySpecification extends TypeStatement {
default @NonNull Collection<? extends LengthStatement> getLength() {
return declaredSubstatements(LengthStatement.class);