<artifactId>yang-model-export</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-model-immutable</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-util</artifactId>
<module>yang-data-transform</module>
<module>yang-data-codec-gson</module>
<module>yang-data-codec-xml</module>
- <module>yang-model-api</module>
<module>yang-maven-plugin</module>
<module>yang-maven-plugin-it</module>
<module>yang-maven-plugin-spi</module>
+ <module>yang-model-api</module>
+ <module>yang-model-export</module>
+ <module>yang-model-immutable</module>
<module>yang-model-util</module>
<module>yang-parser-api</module>
<module>yang-parser-impl</module>
- <module>yang-model-export</module>
<module>yang-data-jaxen</module>
<module>yang-system-test</module>
<module>yang-test-util</module>
/**
* The ChoiceCaseNode interface is used to define branches of the ChoiceNode.
*/
-public interface ChoiceCaseNode extends DataSchemaNode, DataNodeContainer,
- AugmentationTarget {
+public interface ChoiceCaseNode extends DataSchemaNode, DataNodeContainer, AugmentationTarget {
}
*/
package org.opendaylight.yangtools.yang.model.api;
-
/**
* The ContainerSchemaNode is used to define an interior data node in the schema
* tree. There are two styles of containers, those that exist only for
import javax.annotation.Nullable;
/**
- *
* Node which can have documentation assigned.
- *
*/
public interface DocumentedNode {
* if defined.
* </p>
*/
-public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, DataSchemaNode, NotificationNodeContainer,
- ActionNodeContainer {
+public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, DataSchemaNode,
+ NotificationNodeContainer, ActionNodeContainer {
/**
* @return List of QNames of leaf identifiers of this list
/**
* Interface describing YANG 'rpc' statement.
+ *
* <p>
* The rpc statement defines an rpc node in the schema tree. Under the rpc node,
* a schema node with the name 'input', and a schema node with the name 'output'
* are also defined.
- * </p>
*/
public interface RpcDefinition extends OperationDefinition {
package org.opendaylight.yangtools.yang.model.api;
import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
import java.net.URI;
import java.util.Date;
import java.util.Set;
* @return module instance which has namespace equal to the
* <code>namespace</code> or <code>null</code> in other cases
*/
- Set<Module> findModuleByNamespace(final URI namespace);
+ default Set<Module> findModuleByNamespace(final URI namespace) {
+ return Sets.filter(getModules(), m -> namespace.equals(m.getNamespace()));
+ }
/**
* Returns module instance based on given namespace and revision. If
*
* @param namespace
* @param revision
- * @return
+ * @return Matching module or null if a match is not found
*/
- Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision);
-
+ default Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision) {
+ if (namespace == null) {
+ return null;
+ }
+ for (Module module : findModuleByNamespace(namespace)) {
+ if (revision == null || revision.equals(module.getRevision())) {
+ return module;
+ }
+ }
+ return null;
+ }
/**
* Get yang source code represented as string for matching
/**
* Contains the methods for getting data and checking properties of the YANG
* <code>uses</code> substatement.
- *
*/
public interface UsesNode extends DocumentedNode.WithStatus {
* <dt>argument
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ExtensionDefinition#getArgument()}
*
- *
* <dt>augment
* <dd>{@link org.opendaylight.yangtools.yang.model.api.AugmentationSchema}
*
* <dd>{@link org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition#getIdentity()}
*
* <dt>belongs-to
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement#getBelongsTo()}
*
* <dt>bit
* <dd>{@link org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode}
*
* <dt>default
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.LeafSchemaNode#getDefault()}
*
* <dt>description
* <dd>{@link org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.Deviation}
*
* <dt>deviate
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.DeviateKind}
*
* <dt>feature
* <dd>{@link org.opendaylight.yangtools.yang.model.api.FeatureDefinition}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.GroupingDefinition}
*
* <dt>identity
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode}
*
* <dt>if-feature
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement}
*
* <dt>import
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ModuleImport}
*
* <dt>include
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement}
*
* <dt>input
* <dd>{@link org.opendaylight.yangtools.yang.model.api.RpcDefinition#getInput()}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()}
*
* <dt>refine
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement}
*
* <dt>require-instance
* <dd>{@link org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition#requireInstance()}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()}
*
* <dt>submodule
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement}
*
* <dt>type
* <dd>{@link org.opendaylight.yangtools.yang.model.api.TypeDefinition}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.TypeDefinition}
*
* <dt>unique
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.UniqueConstraint}
*
* <dt>units
* <dd>{@link org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ConstraintDefinition#getWhenCondition()}
*
* <dt>yang-version
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.Module#getYangVersion()}
*
* <dt>yin-element
- * <dd>
- *
- *
- *
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.ExtensionDefinition#isYinElement()}
*
* <dt>add
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.DeviateKind#ADD}
*
* <dt>current
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.Status#CURRENT}
*
* <dt>delete
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.DeviateKind#DELETE}
*
* <dt>deprecated
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.Status#DEPRECATED}
*
* <dt>false
- * <dd>
+ * <dd>{@link java.lang.Boolean#FALSE}
*
* <dt>max
- * <dd>
+ * <dd>Not exposed
*
* <dt>min
- * <dd>
+ * <dd>Not exposed
*
* <dt>not-supported
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.DeviateKind#NOT_SUPPORTED}
*
* <dt>obsolete
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.Status#OBSOLETE}
*
* <dt>replace
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.DeviateKind#REPLACE}
*
* <dt>system
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.ListSchemaNode#isUserOrdered()}
*
* <dt>true
- * <dd>
+ * <dd>{@link java.lang.Boolean#TRUE}
*
* <dt>unbounded
- * <dd>
+ * <dd>Not exposed
*
* <dt>user
- * <dd>
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.ListSchemaNode#isUserOrdered()}
* </dl>
*
*
/**
* The binary built-in type represents any binary data, i.e., a sequence of
- * octets. <br>
+ * octets.
* <br>
* Binary values are encoded with the base64 encoding scheme (see <a
* href="https://tools.ietf.org/html/rfc4648#section-4">[RFC4648], Section
* href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.
*
* <br>
- * <br>
* This interface was modeled according to definition in <a
* href="https://tools.ietf.org/html/rfc6020#section-9.8">[RFC-6020] The binary
* Built-In Type</a>
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- *
* Marker interface which marks that type definition represents the built-in
* YANG <code>boolean</code> type.
- *
*/
public interface BooleanTypeDefinition extends TypeDefinition<BooleanTypeDefinition> {
/**
* Contains methods for getting data from the YANG <code>type</code>
* substatement for <code>decimal64</code> built-in type.
- *
*/
public interface DecimalTypeDefinition extends TypeDefinition<DecimalTypeDefinition> {
@Nonnull List<EnumPair> getValues();
/**
- *
* Contains the methods for accessing the data about the concrete
* enumeration item which represents <code>enum</code> YANG type.
*/
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- *
* Contains method for getting data from <code>identityref</code> built-in YANG
* type.
- *
*/
public interface IdentityrefTypeDefinition extends TypeDefinition<IdentityrefTypeDefinition> {
-
/**
* Returns identity to which the instance of this type refers.
*
* statement
*/
IdentitySchemaNode getIdentity();
-
}
/**
* Contains the method for getting the data from the YANG <code>pattern</code>
* which is substatement of <code>type</code> statement.
- *
*/
public interface PatternConstraint extends ConstraintMetaDefinition {
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- *
* Contains method for getting data from the <code>string</code> YANG built-in
* type.
*/
package org.opendaylight.yangtools.yang.model.api.type;
import java.util.List;
-
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
* Contains the method which access union item in the union type.
- *
*/
public interface UnionTypeDefinition extends TypeDefinition<UnionTypeDefinition> {
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2013 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>bundle-parent</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-model-immutable</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yangtools-artifacts</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>yang-model-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.immutables</groupId>
+ <artifactId>value</artifactId>
+ <version>2.3.9</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <!--
+ Maven Site Configuration
+
+ The following configuration is necessary for maven-site-plugin to
+ correctly identify the correct deployment path for OpenDaylight Maven
+ sites.
+ -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+ <distributionManagement>
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+
+@Value.Immutable
+abstract class AbstractChoiceCaseNode extends AbstractDataNodeContainer implements ChoiceCaseNode {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+
+@Value.Immutable
+abstract class AbstractContainerSchemaNode extends CommonContainerSchemaNode implements ContainerSchemaNode {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import java.util.Collection;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+
+abstract class AbstractDataNodeContainer implements DataNodeContainer {
+
+ abstract Map<QName, DataSchemaNode> children();
+
+ @Override
+ public final Collection<DataSchemaNode> getChildNodes() {
+ return children().values();
+ }
+
+ @Override
+ public final DataSchemaNode getDataChildByName(final QName name) {
+ return children().get(name);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+
+@Value.Immutable
+abstract class AbstractListSchemaNode extends AbstractDataNodeContainer implements ListSchemaNode {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+@Value.Immutable
+abstract class AbstractModule extends AbstractDataNodeContainer implements Module {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+
+@Value.Immutable
+abstract class AbstractNotificationDefinition extends AbstractDataNodeContainer implements NotificationDefinition {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import com.google.common.base.Optional;
+import java.util.Date;
+import org.immutables.value.Value;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+@Value.Immutable
+abstract class AbstractSchemaContext extends CommonContainerSchemaNode implements SchemaContext {
+
+ @Override
+ public final Optional<String> getModuleSource(final ModuleIdentifier moduleIdentifier) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ @Override
+ public Module findModuleByName(final String name, final Date revision) {
+ throw new UnsupportedOperationException("Not implemented");
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.immutable;
+
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+
+/**
+ * Common abstract class capturing {@link AbstractDataNodeContainer} and {@link ContainerSchemaNode}.
+ *
+ * @author Robert Varga
+ */
+abstract class CommonContainerSchemaNode extends AbstractDataNodeContainer implements ContainerSchemaNode {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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
+ */
+/**
+ * Generated immutable implementations for org.opendaylight.yangtools.yang.model.api interfaces.
+ *
+ * @author Robert Varga
+ */
+@Include(value = {
+ org.opendaylight.yangtools.yang.model.api.ActionDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.AnyDataSchemaNode.class,
+ org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode.class,
+ org.opendaylight.yangtools.yang.model.api.ExtensionDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.FeatureDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode.class,
+ org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode.class,
+ org.opendaylight.yangtools.yang.model.api.LeafSchemaNode.class,
+ org.opendaylight.yangtools.yang.model.api.ModuleImport.class,
+ org.opendaylight.yangtools.yang.model.api.RpcDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit.class,
+ org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair.class,
+ org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.LengthConstraint.class,
+ org.opendaylight.yangtools.yang.model.api.type.PatternConstraint.class,
+ org.opendaylight.yangtools.yang.model.api.type.RangeConstraint.class,
+ org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition.class,
+ org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition.class,
+})
+@Style(
+ builderVisibility = BuilderVisibility.PUBLIC,
+ strictBuilder = true,
+ visibility = ImplementationVisibility.PRIVATE)
+package org.opendaylight.yangtools.yang.model.immutable;
+
+import org.immutables.value.Value.Include;
+import org.immutables.value.Value.Style;
+import org.immutables.value.Value.Style.BuilderVisibility;
+import org.immutables.value.Value.Style.ImplementationVisibility;