*
* @return set of action nodes
*/
- @NonNull Collection<? extends ActionDefinition> getActions();
+ @NonNull Collection<? extends @NonNull ActionDefinition> getActions();
/**
* Find an action based on its QName. Default implementation searches the set returned by {@link #getActions()}.
package org.opendaylight.yangtools.yang.model.api;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Interface for all nodes which are possible targets of augmentation. The
*
* @return set of augmentations targeting this element.
*/
- Collection<? extends AugmentationSchemaNode> getAvailableAugmentations();
+ @NonNull Collection<? extends @NonNull AugmentationSchemaNode> getAvailableAugmentations();
}
import java.util.Collection;
import java.util.List;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
* @return set of ChoiceCaseNode objects defined in this node which represents set of arguments of the YANG
* <code>case</code> substatement of the <code>choice</code> statement.
*/
- Collection<? extends CaseSchemaNode> getCases();
+ Collection<? extends @NonNull CaseSchemaNode> getCases();
/**
* Returns the concrete case according to specified Q name.
* @throws NullPointerException if localname is null
*/
@Beta
- default List<? extends CaseSchemaNode> findCaseNodes(final String localname) {
+ default List<? extends @NonNull CaseSchemaNode> findCaseNodes(final String localname) {
return getCases().stream().filter(node -> localname.equals(node.getQName().getLocalName()))
.collect(ImmutableList.toImmutableList());
}
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
*
* @return typedef statements in lexicographical order
*/
- Collection<? extends TypeDefinition<?>> getTypeDefinitions();
+ @NonNull Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions();
/**
* Returns set of all child nodes defined within this DataNodeContainer. Although the return type is a collection,
*
* @return child nodes in lexicographical order
*/
- Collection<? extends DataSchemaNode> getChildNodes();
+ @NonNull Collection<? extends @NonNull DataSchemaNode> getChildNodes();
/**
* Returns set of all groupings defined within this DataNodeContainer.
*
* @return grouping statements in lexicographical order
*/
- Collection<? extends GroupingDefinition> getGroupings();
+ @NonNull Collection<? extends @NonNull GroupingDefinition> getGroupings();
/**
* Returns the child node corresponding to the specified name.
*
* @return Set of all uses nodes defined within this DataNodeContainer
*/
- Collection<? extends UsesNode> getUses();
+ @NonNull Collection<? extends @NonNull UsesNode> getUses();
/**
* Returns a {@code data node} identified by a QName. This method is distinct from
import com.google.common.annotations.Beta;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviateEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueEffectiveStatement;
*
* @return set of the deviated must statements
*/
- Collection<? extends MustDefinition> getDeviatedMusts();
+ Collection<? extends @NonNull MustDefinition> getDeviatedMusts();
/**
* Returns deviated type statement.
*
* @return collection of the deviated unique statements
*/
- Collection<? extends UniqueEffectiveStatement> getDeviatedUniques();
+ Collection<? extends @NonNull UniqueEffectiveStatement> getDeviatedUniques();
/**
* Returns deviated units statement.
*
* @return Collection of all deviate statements defined in this deviation.
*/
- @NonNull Collection<? extends DeviateDefinition> getDeviates();
+ @NonNull Collection<? extends @NonNull DeviateDefinition> getDeviates();
}
*
* @return collection of unknown schema nodes defined under this node.
*/
- default @NonNull Collection<? extends UnknownSchemaNode> getUnknownSchemaNodes() {
+ default @NonNull Collection<? extends @NonNull UnknownSchemaNode> getUnknownSchemaNodes() {
return ImmutableList.of();
}
* @return set of existing identities from which the new identity is derived or an empty Set if the identity is
* a root identity.
*/
- @NonNull Collection<? extends IdentitySchemaNode> getBaseIdentities();
+ @NonNull Collection<? extends @NonNull IdentitySchemaNode> getBaseIdentities();
}
*
* @return Ordered list of Strings which specify the default values of this leaf-list
*/
- @NonNull Collection<? extends Object> getDefaults();
+ @NonNull Collection<? extends @NonNull Object> getDefaults();
}
*
* @return List of QNames of leaf identifiers of this list, empty if the list has no keys.
*/
- @NonNull List<QName> getKeyDefinition();
+ @NonNull List<@NonNull QName> getKeyDefinition();
/**
* YANG 'ordered-by' statement. It defines whether the order of entries within a list are determined by the user
*
* @return Collection of unique constraints of this list schema node
*/
- @NonNull Collection<? extends UniqueEffectiveStatement> getUniqueConstraints();
+ @NonNull Collection<? extends @NonNull UniqueEffectiveStatement> getUniqueConstraints();
}
import com.google.common.annotations.Beta;
import java.util.Collection;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.common.YangVersion;
* @return set of module imports which are specified in the module as the argument of YANG {@code import}
* statements.
*/
- Collection<? extends ModuleImport> getImports();
+ Collection<? extends @NonNull ModuleImport> getImports();
// FIXME: YANGTOOLS-1006: this should be only in Module
- Collection<? extends Submodule> getSubmodules();
+ Collection<? extends @NonNull Submodule> getSubmodules();
/**
* Returns {@link FeatureDefinition} instances which contain data from {@code feature} statements defined in the
* @return feature statements in lexicographical order which are specified in the module as the argument of YANG
* {@code feature} statements.
*/
- Collection<? extends FeatureDefinition> getFeatures();
+ Collection<? extends @NonNull FeatureDefinition> getFeatures();
/**
* Returns {@link AugmentationSchemaNode} instances which contain data from {@code augment} statements defined
* @return set of the augmentation schema instances which are specified in the module as YANG {@code augment}
* statement and are lexicographically ordered
*/
- Collection<? extends AugmentationSchemaNode> getAugmentations();
+ Collection<? extends @NonNull AugmentationSchemaNode> getAugmentations();
/**
* Returns {@link RpcDefinition} instances which contain data from {@code rpc} statements defined in the module.
* @return set of the RPC definition instances which are specified in the module as YANG {@code rpc} statements and
* are lexicographicaly ordered
*/
- Collection<? extends RpcDefinition> getRpcs();
+ Collection<? extends @NonNull RpcDefinition> getRpcs();
/**
* Returns {@link Deviation} instances which contain data from {@code deviation} statements defined in the module.
*
* @return set of the deviation instances
*/
- Collection<? extends Deviation> getDeviations();
+ Collection<? extends @NonNull Deviation> getDeviations();
/**
* Returns {@link IdentitySchemaNode} instances which contain data from {@code identity} statements defined in the
* @return set of identity schema node instances which are specified in the module as YANG {@code identity}
* statements and are lexicographically ordered
*/
- Collection<? extends IdentitySchemaNode> getIdentities();
+ Collection<? extends @NonNull IdentitySchemaNode> getIdentities();
/**
* Returns {@link ExtensionDefinition} instances which contain data from {@code extension} statements defined in
* @return set of extension definition instances which are specified in the module as YANG {@code extension}
* statements and are lexicographically ordered
*/
- Collection<? extends ExtensionDefinition> getExtensionSchemaNodes();
+ Collection<? extends @NonNull ExtensionDefinition> getExtensionSchemaNodes();
}
package org.opendaylight.yangtools.yang.model.api;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Mix-in interface for nodes which can define must constraints.
*/
public interface MustConstraintAware {
/**
- * Specifies the rules which the node which contains <code>must</code> YANG substatement has to match.
+ * Specifies the rules which the node which contains {@code must} YANG substatement has to match.
*
- * @return collection of <code>MustDefinition</code> (XPath) instances which represents the concrete data
- * constraints
+ * @return collection of {@code MustDefinition} (XPath) instances which represents the concrete data constraints
*/
- Collection<? extends MustDefinition> getMustConstraints();
+ Collection<? extends @NonNull MustDefinition> getMustConstraints();
}
*
* @return set of notification nodes
*/
- @NonNull Collection<? extends NotificationDefinition> getNotifications();
+ @NonNull Collection<? extends @NonNull NotificationDefinition> getNotifications();
/**
* Find a notification based on its QName. Default implementation searches the set returned by
import com.google.common.annotations.Beta;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
/**
* Common interface for an operation.
*
* @return Set of type definitions declared under this operation.
*/
- Collection<? extends TypeDefinition<?>> getTypeDefinitions();
+ Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions();
/**
* Returns the set of grouping statements declared under this operation.
*
* @return Set of grouping statements declared under this operation.
*/
- Collection<? extends GroupingDefinition> getGroupings();
+ Collection<? extends @NonNull GroupingDefinition> getGroupings();
/**
* Returns definition of input parameters for this operation.
* @return set of <code>DataSchemaNode</code> instances which represents
* YANG data nodes at the module top level
*/
- Collection<? extends DataSchemaNode> getDataDefinitions();
+ @NonNull Collection<? extends @NonNull DataSchemaNode> getDataDefinitions();
/**
* Returns modules which are part of the schema context. Returned set is required to have its iteration ordered
*
* @return set of the modules which belong to the schema context
*/
- Collection<? extends Module> getModules();
+ @NonNull Collection<? extends @NonNull Module> getModules();
/**
* Returns rpc definition instances which are defined as the direct
* @return set of <code>RpcDefinition</code> instances which represents
* nodes defined via <code>rpc</code> YANG keyword
*/
- Collection<? extends RpcDefinition> getOperations();
+ @NonNull Collection<? extends @NonNull RpcDefinition> getOperations();
/**
* Returns extension definition instances which are defined as the direct
* @return set of <code>ExtensionDefinition</code> instances which
* represents nodes defined via <code>extension</code> YANG keyword
*/
- Collection<? extends ExtensionDefinition> getExtensions();
+ @NonNull Collection<? extends ExtensionDefinition> getExtensions();
/**
* Returns the module matching specified {@link QNameModule}, if present.
* string with the module name
* @return set of module instances with specified name.
*/
- default Collection<? extends Module> findModules(final String name) {
+ default @NonNull Collection<? extends @NonNull Module> findModules(final String name) {
return Collections2.filter(getModules(), m -> name.equals(m.getName()));
}
* @return module instance which has namespace equal to the
* <code>namespace</code> or <code>null</code> in other cases
*/
- default Collection<? extends Module> findModules(final URI namespace) {
+ default @NonNull Collection<? extends @NonNull Module> findModules(final URI namespace) {
return Collections2.filter(getModules(), m -> namespace.equals(m.getNamespace()));
}
@Override
default Optional<NotificationDefinition> findNotification(final QName qname) {
- final Optional<Collection<? extends NotificationDefinition>> defs = findModule(qname.getModule())
+ final Optional<Collection<? extends @NonNull NotificationDefinition>> defs = findModule(qname.getModule())
.map(Module::getNotifications);
if (defs.isPresent()) {
for (NotificationDefinition def : defs.get()) {
@Override
@Deprecated
- default Collection<? extends MustDefinition> getMustConstraints() {
+ default Collection<? extends @NonNull MustDefinition> getMustConstraints() {
return ImmutableSet.of();
}
*
* @return collection of all effective substatements.
*/
- @NonNull Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements();
+ @NonNull Collection<? extends @NonNull EffectiveStatement<?, ?>> effectiveSubstatements();
/**
* Find the first effective substatement of specified type.
package org.opendaylight.yangtools.yang.model.api.type;
import com.google.common.collect.RangeSet;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
/**
*
* @return Set of allowed lengths.
*/
- RangeSet<T> getAllowedRanges();
+ RangeSet<@NonNull T> getAllowedRanges();
}
requires org.opendaylight.yangtools.util;
requires org.slf4j;
+
+ // Annotations
+ requires static transitive org.eclipse.jdt.annotation;
}
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
Multimaps.newSetMultimap(new HashMap<>(), HashSet::new);
final List<IdentitySchemaNode> identities = new ArrayList<>();
for (Module module : getModules()) {
- final Collection<? extends IdentitySchemaNode> ids = module.getIdentities();
+ final Collection<? extends @NonNull IdentitySchemaNode> ids = module.getIdentities();
for (IdentitySchemaNode identity : ids) {
for (IdentitySchemaNode base : identity.getBaseIdentities()) {
tmp.put(base, identity);
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Function;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
}
//dealing with imported module other than root and directly importing root
- private static Collection<Module> getImportedModules(final Map<ModuleId, ? extends Module> allModules,
- final Collection<? extends Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
+ private static Collection<Module> getImportedModules(final Map<ModuleId, ? extends @NonNull Module> allModules,
+ final Collection<? extends @NonNull Module> baseModules,
+ final TreeMultimap<String, Module> nameToModulesAll) {
List<Module> relatedModules = new LinkedList<>();
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNode;
import org.opendaylight.yangtools.rfc7952.model.api.AnnotationSchemaNodeAwareSchemaContext;
import org.opendaylight.yangtools.yang.common.QName;
private final ImmutableSet<Module> modules;
private final ImmutableMap<QName, AnnotationSchemaNode> annotations;
- protected SimpleSchemaContext(final Collection<? extends Module> modules) {
+ protected SimpleSchemaContext(final Collection<? extends @NonNull Module> modules) {
/*
* Instead of doing this on each invocation of getModules(), pre-compute it once and keep it around -- better
* than the set we got in.
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.RangeSet;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
final class ResolvedRangeConstraint<T extends Number & Comparable<T>> implements RangeConstraint<T>, Immutable {
+ private final ImmutableRangeSet<@NonNull T> ranges;
private final ConstraintMetaDefinition meta;
- private final ImmutableRangeSet<T> ranges;
ResolvedRangeConstraint(final ConstraintMetaDefinition meta, final RangeSet<T> ranges) {
this.meta = requireNonNull(meta);
}
@Override
- public RangeSet<T> getAllowedRanges() {
+ public RangeSet<@NonNull T> getAllowedRanges() {
return ranges;
}
}
* @throws ClassCastException if masked object does not match EffectiveStatement
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
- protected static final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> unmaskList(
+ protected static final @NonNull ImmutableList<? extends @NonNull EffectiveStatement<?, ?>> unmaskList(
final @NonNull Object masked) {
return (ImmutableList) unmaskList(masked, EffectiveStatement.class);
}
// Marker interface requiring all mixins to be derived from EffectiveStatement.
private interface Mixin<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
@SuppressWarnings("unchecked")
- default <T> @NonNull Collection<? extends T> filterEffectiveStatements(final Class<T> type) {
+ default <T> @NonNull Collection<? extends @NonNull T> filterEffectiveStatements(final Class<T> type) {
// Yeah, this is not nice, but saves one transformation
return (Collection<? extends T>) Collections2.filter(effectiveSubstatements(), type::isInstance);
}
*/
public interface MustConstraintMixin<A, D extends DeclaredStatement<A>> extends Mixin<A, D>, MustConstraintAware {
@Override
- default Collection<? extends MustDefinition> getMustConstraints() {
+ default Collection<? extends @NonNull MustDefinition> getMustConstraints() {
return filterEffectiveStatements(MustDefinition.class);
}
}
}
@Override
- default Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
+ default Collection<? extends @NonNull TypeDefinition<?>> getTypeDefinitions() {
return filterTypeDefinitions(this);
}
@Override
- default Collection<? extends GroupingDefinition> getGroupings() {
+ default Collection<? extends @NonNull GroupingDefinition> getGroupings() {
return filterEffectiveStatements(GroupingDefinition.class);
}
}
static <T extends ContainerLike> T findAsContainer(final EffectiveStatement<?, ?> stmt,
- final Class<? extends EffectiveStatement<QName, ?>> type, Class<T> target) {
+ final Class<? extends EffectiveStatement<QName, ?>> type, final Class<T> target) {
return target.cast(stmt.findFirstEffectiveSubstatement(type).get());
}
- static Collection<? extends TypeDefinition<?>> filterTypeDefinitions(final Mixin<?, ?> stmt) {
+ static Collection<? extends @NonNull TypeDefinition<?>> filterTypeDefinitions(final Mixin<?, ?> stmt) {
return Collections2.transform(stmt.filterEffectiveStatements(TypedefEffectiveStatement.class),
TypedefEffectiveStatement::getTypeDefinition);
}
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
import org.opendaylight.yangtools.yang.model.api.DeviateKind;
import org.opendaylight.yangtools.yang.model.api.MustDefinition;
}
@Override
- public Collection<? extends MustDefinition> getDeviatedMusts() {
+ public Collection<? extends @NonNull MustDefinition> getDeviatedMusts() {
return allSubstatementsOfType(MustDefinition.class);
}
}
@Override
- public Collection<? extends UniqueEffectiveStatement> getDeviatedUniques() {
+ public Collection<? extends @NonNull UniqueEffectiveStatement> getDeviatedUniques() {
return allSubstatementsOfType(UniqueEffectiveStatement.class);
}
import java.util.Collection;
import java.util.List;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.YangConstants;
return ctx.getModules().iterator().next();
}
- public static Optional<? extends Module> findModule(final SchemaContext context, final String moduleName) {
+ public static Optional<? extends @NonNull Module> findModule(final SchemaContext context, final String moduleName) {
return context.getModules().stream().filter(module -> moduleName.equals(module.getName())).findAny();
}