Cleanup DocumentedNode 21/64821/19
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 27 Oct 2017 18:05:33 +0000 (20:05 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Nov 2017 13:58:50 +0000 (14:58 +0100)
Make description/reference work on Optional and fixup users.

Change-Id: I744b9c59c8c3cc160636ef8c3ff18298c66a275a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
72 files changed:
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/ContainerSchemaNodes.java
yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/RpcAsContainer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DocumentedNode.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaContext.java
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EffectiveAugmentationSchema.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/RangeConstraintImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractBaseType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractDerivedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/AbstractRestrictedType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ConcreteTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/JavaLengthConstraints.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/RangeRestrictedTypeBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/ResolvedLengthConstraint.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BooleanTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/EmptyTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/LeafrefTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/PatternConstraintImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/EnumPairImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/AbstractConstraintEffectiveStatement.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsSpecificationEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitsTypeEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumTypeEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5481Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5942Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6180Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveSchemaContextTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveUsesRefineAndConstraintsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserSimpleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserWithContextTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileExtensionStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileGroupingStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileLeafListStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileListStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileMetaStmtsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileRpcStmtTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/yin/YinFileTypeDefStmtTest.java

index d98c808b0a91edf67393ac98ef38f2e5df62f98f..a3a817e507384163a9b43caafec68abd94719e17 100644 (file)
@@ -213,13 +213,13 @@ public class YangModeledAnyXMLDeserializationTest {
         }
 
         @Override
-        public String getDescription() {
-            return null;
+        public Optional<String> getDescription() {
+            return Optional.empty();
         }
 
         @Override
-        public String getReference() {
-            return null;
+        public Optional<String> getReference() {
+            return Optional.empty();
         }
 
         @Nonnull
index 9222f3dbc59f13fadfbff4db49218cea3125a237..b646a63a6c66b32c0ed2019c70b9569f3a962ae2 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
@@ -102,15 +101,13 @@ public final class ContainerSchemaNodes {
             return schemaNode.getPath();
         }
 
-        @Nullable
         @Override
-        public String getDescription() {
+        public Optional<String> getDescription() {
             return schemaNode.getDescription();
         }
 
-        @Nullable
         @Override
-        public String getReference() {
+        public Optional<String> getReference() {
             return schemaNode.getReference();
         }
 
index ec4616fa4a1729a8bdc79e7b43c9e80880cb56a9..f437906d61e730f6bc8d0cb24c2bc6c289ea030b 100644 (file)
@@ -34,12 +34,12 @@ public final class RpcAsContainer implements ContainerSchemaNode {
     private final RpcDefinition delegate;
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return delegate.getDescription();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return delegate.getReference();
     }
 
index 07ae031d9380c4158b0ad45778ea0afbd48d83ec..b66e447587bd2f38d787bf15752d2af5b6d6f13a 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import com.google.common.collect.ImmutableList;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 /**
  * Node which can have documentation assigned.
@@ -19,29 +19,23 @@ public interface DocumentedNode {
     /**
      * Returns the value of the argument of YANG <code>description</code> keyword.
      *
-     * @return string with the description, or null if description was not provided.
+     * @return string with the description, or empty if description was not provided.
      */
-    // FIXME: version 2.0.0: make this method non-default
-    @Nullable default String getDescription() {
-        return null;
-    }
+    Optional<String> getDescription();
 
     /**
      * Returns the value of the argument of YANG <code>reference</code> keyword.
      *
-     * @return string with reference to some other document, or null if reference was not provided.
+     * @return string with reference to some other document, or empty if reference was not provided.
      */
-    // FIXME: version 2.0.0: make this method non-default
-    @Nullable default String getReference() {
-        return null;
-    }
+    Optional<String> getReference();
 
     /**
-     * Returns unknown schema nodes which belongs to this instance.
+     * Returns unknown schema nodes which belongs to this instance. Default implementation returns an empty list.
      *
      * @return list of unknown schema nodes defined under this node.
      */
-    default @Nonnull List<UnknownSchemaNode> getUnknownSchemaNodes() {
+    @Nonnull default List<UnknownSchemaNode> getUnknownSchemaNodes() {
         return ImmutableList.of();
     }
 
index 3a4ea43c6b500768bd49bd1c838326299fccd4f6..90daf966ce7c5e6be70be77520285a94c761a842 100644 (file)
@@ -137,26 +137,6 @@ public interface Module extends DataNodeContainer, DocumentedNode, NotificationN
      */
     YangVersion getYangVersion();
 
-    /**
-     * Returns the module description.
-     *
-     * @return string with the module description which is specified as argument
-     *         of YANG {@link Module <b><font
-     *         color="#b8860b">description</font></b>} keyword
-     */
-    @Override
-    String getDescription();
-
-    /**
-     * Returns the module reference.
-     *
-     * @return string with the module reference which is specified as argument
-     *         of YANG {@link Module <b><font
-     *         color="#008b8b">reference</font></b>} keyword
-     */
-    @Override
-    String getReference();
-
     /**
      * Returns the module organization.
      *
index d7644eb91b75dffc25acadac63e83242291c44bd..71437d4f724ff2d543852893b4ad7dc25ce7302c 100644 (file)
@@ -148,4 +148,14 @@ public interface SchemaContext extends ContainerSchemaNode {
     default Set<ActionDefinition> getActions() {
         return ImmutableSet.of();
     }
+
+    @Override
+    default Optional<String> getDescription() {
+        return Optional.empty();
+    }
+
+    @Override
+    default Optional<String> getReference() {
+        return Optional.empty();
+    }
 }
index b09401702148620d548e0aabeb0a447c24d2735d..84c0caccd6af28e10d3805d5b98b7a040f925efc 100644 (file)
@@ -1171,8 +1171,7 @@ abstract class SchemaContextEmitter {
         private void emitMetaNodes(final Module input) {
             input.getOrganization().ifPresent(this::emitOrganizationNode);
             input.getContact().ifPresent(this::emitContact);
-            emitDescriptionNode(input.getDescription());
-            emitReferenceNode(input.getReference());
+            emitDocumentedNode(input);
         }
 
         private void emitLinkageNodes(final Module input) {
@@ -1266,10 +1265,8 @@ abstract class SchemaContextEmitter {
 
         private void emitImport(final ModuleImport importNode) {
             super.writer.startImportNode(importNode.getModuleName());
-            emitDescriptionNode(importNode.getDescription());
-            emitReferenceNode(importNode.getReference());
+            emitDocumentedNode(importNode);
             emitPrefixNode(importNode.getPrefix());
-
             importNode.getRevision().ifPresent(this::emitRevisionDateNode);
             super.writer.endNode();
         }
@@ -1324,18 +1321,14 @@ abstract class SchemaContextEmitter {
             super.writer.endNode();
         }
 
-        private void emitDescriptionNode(@Nullable final String input) {
-            if (!Strings.isNullOrEmpty(input)) {
-                super.writer.startDescriptionNode(input);
-                super.writer.endNode();
-            }
+        private void emitDescriptionNode(final String input) {
+            super.writer.startDescriptionNode(input);
+            super.writer.endNode();
         }
 
-        private void emitReferenceNode(@Nullable final String input) {
-            if (!Strings.isNullOrEmpty(input)) {
-                super.writer.startReferenceNode(input);
-                super.writer.endNode();
-            }
+        private void emitReferenceNode(final String input) {
+            super.writer.startReferenceNode(input);
+            super.writer.endNode();
         }
 
         private void emitUnitsNode(@Nullable final String input) {
@@ -1365,9 +1358,7 @@ abstract class SchemaContextEmitter {
         private void emitExtension(final ExtensionDefinition extension) {
             super.writer.startExtensionNode(extension.getQName());
             emitArgument(extension.getArgument(), extension.isYinElement());
-            emitStatusNode(extension.getStatus());
-            emitDescriptionNode(extension.getDescription());
-            emitReferenceNode(extension.getReference());
+            emitDocumentedNode(extension);
             emitUnknownStatementNodes(extension.getUnknownSchemaNodes());
             super.writer.endNode();
 
@@ -1391,9 +1382,7 @@ abstract class SchemaContextEmitter {
         private void emitIdentity(final IdentitySchemaNode identity) {
             super.writer.startIdentityNode(identity.getQName());
             emitBaseIdentities(identity.getBaseIdentities());
-            emitStatusNode(identity.getStatus());
-            emitDescriptionNode(identity.getDescription());
-            emitReferenceNode(identity.getReference());
+            emitDocumentedNode(identity);
             super.writer.endNode();
         }
 
@@ -1413,11 +1402,8 @@ abstract class SchemaContextEmitter {
 
             // FIXME: BUG-2444: FIXME: BUG-2444: Expose ifFeature
             // *(ifFeatureNode )
-            emitStatusNode(definition.getStatus());
-            emitDescriptionNode(definition.getDescription());
-            emitReferenceNode(definition.getReference());
+            emitDocumentedNode(definition);
             super.writer.endNode();
-
         }
 
         @SuppressWarnings("unused")
@@ -1436,12 +1422,9 @@ abstract class SchemaContextEmitter {
             emitTypeNodeDerived(typedef);
             emitUnitsNode(typedef.getUnits());
             emitDefaultNode(typedef.getDefaultValue());
-            emitStatusNode(typedef.getStatus());
-            emitDescriptionNode(typedef.getDescription());
-            emitReferenceNode(typedef.getReference());
+            emitDocumentedNode(typedef);
             emitUnknownStatementNodes(typedef.getUnknownSchemaNodes());
             super.writer.endNode();
-
         }
 
         private void emitTypeNode(final SchemaPath parentPath, final TypeDefinition<?> subtype) {
@@ -1516,8 +1499,7 @@ abstract class SchemaContextEmitter {
                 final RangeConstraint first = list.iterator().next();
                 first.getErrorMessage().ifPresent(this::emitErrorMessageNode);
                 first.getErrorAppTag().ifPresent(this::emitErrorAppTagNode);
-                emitDescriptionNode(first.getDescription());
-                emitReferenceNode(first.getReference());
+                emitDocumentedNode(first);
                 super.writer.endNode();
             }
 
@@ -1526,7 +1508,6 @@ abstract class SchemaContextEmitter {
         private void emitDecimal64Specification(final DecimalTypeDefinition typeDefinition) {
             emitFranctionDigitsNode(typeDefinition.getFractionDigits());
             emitRangeNodeOptional(typeDefinition.getRangeConstraints());
-
         }
 
         private void emitFranctionDigitsNode(final Integer fractionDigits) {
@@ -1546,8 +1527,7 @@ abstract class SchemaContextEmitter {
             super.writer.startLengthNode(toLengthString(constraint.getAllowedRanges()));
             constraint.getErrorMessage().ifPresent(this::emitErrorMessageNode);
             constraint.getErrorAppTag().ifPresent(this::emitErrorAppTagNode);
-            emitDescriptionNode(constraint.getDescription());
-            emitReferenceNode(constraint.getReference());
+            emitDocumentedNode(constraint);
             super.writer.endNode();
         }
 
@@ -1601,7 +1581,7 @@ abstract class SchemaContextEmitter {
             super.writer.startPatternNode(pattern.getRawRegularExpression());
             pattern.getErrorMessage().ifPresent(this::emitErrorMessageNode);
             pattern.getErrorAppTag().ifPresent(this::emitErrorAppTagNode);
-            emitDescriptionNode(pattern.getDescription());
+            emitDocumentedNode(pattern);
             emitModifier(pattern.getModifier());
             super.writer.endNode();
         }
@@ -1635,9 +1615,7 @@ abstract class SchemaContextEmitter {
         private void emitEnumNode(final EnumPair enumValue) {
             super.writer.startEnumNode(enumValue.getName());
             emitValueNode(enumValue.getValue());
-            emitStatusNode(enumValue.getStatus());
-            emitDescriptionNode(enumValue.getDescription());
-            emitReferenceNode(enumValue.getReference());
+            emitDocumentedNode(enumValue);
             super.writer.endNode();
         }
 
@@ -1683,9 +1661,7 @@ abstract class SchemaContextEmitter {
         private void emitBit(final Bit bit) {
             super.writer.startBitNode(bit.getName());
             emitPositionNode(bit.getPosition());
-            emitStatusNode(bit.getStatus());
-            emitDescriptionNode(bit.getDescription());
-            emitReferenceNode(bit.getReference());
+            emitDocumentedNode(bit);
             super.writer.endNode();
         }
 
@@ -1732,11 +1708,9 @@ abstract class SchemaContextEmitter {
                 super.writer.startMustNode(mustCondition.getXpath());
                 mustCondition.getErrorMessage().ifPresent(this::emitErrorMessageNode);
                 mustCondition.getErrorAppTag().ifPresent(this::emitErrorAppTagNode);
-                emitDescriptionNode(mustCondition.getDescription());
-                emitReferenceNode(mustCondition.getReference());
+                emitDocumentedNode(mustCondition);
                 super.writer.endNode();
             }
-
         }
 
         private void emitErrorMessageNode(@Nullable final String input) {
@@ -1770,10 +1744,14 @@ abstract class SchemaContextEmitter {
             }
         }
 
+        private void emitDocumentedNode(final DocumentedNode input) {
+            input.getDescription().ifPresent(this::emitDescriptionNode);
+            input.getReference().ifPresent(this::emitReferenceNode);
+        }
+
         private void emitDocumentedNode(final DocumentedNode.WithStatus input) {
             emitStatusNode(input.getStatus());
-            emitDescriptionNode(input.getDescription());
-            emitReferenceNode(input.getReference());
+            emitDocumentedNode((DocumentedNode) input);
         }
 
         private void emitGrouping(final GroupingDefinition grouping) {
@@ -1995,10 +1973,10 @@ abstract class SchemaContextEmitter {
 
         private void emitDocumentedNodeRefine(final DocumentedNode original, final DocumentedNode value) {
             if (Objects.deepEquals(original.getDescription(), value.getDescription())) {
-                emitDescriptionNode(value.getDescription());
+                value.getDescription().ifPresent(this::emitDescriptionNode);
             }
             if (Objects.deepEquals(original.getReference(), value.getReference())) {
-                emitReferenceNode(value.getReference());
+                value.getReference().ifPresent(this::emitReferenceNode);
             }
         }
 
@@ -2119,9 +2097,7 @@ abstract class SchemaContextEmitter {
             // FIXME: BUG-2444: whenNode //Optional
             // FIXME: BUG-2444: *(ifFeatureNode )
 
-            emitStatusNode(augmentation.getStatus());
-            emitDescriptionNode(augmentation.getDescription());
-            emitReferenceNode(augmentation.getReference());
+            emitDocumentedNode(augmentation);
             for (final UsesNode uses : augmentation.getUses()) {
                 emitUsesNode(uses);
             }
@@ -2183,9 +2159,7 @@ abstract class SchemaContextEmitter {
 
         private void emitOperationBody(final OperationDefinition rpc) {
             // FIXME: BUG-2444: *(ifFeatureNode )
-            emitStatusNode(rpc.getStatus());
-            emitDescriptionNode(rpc.getDescription());
-            emitReferenceNode(rpc.getReference());
+            emitDocumentedNode(rpc);
 
             for (final TypeDefinition<?> typedef : rpc.getTypeDefinitions()) {
                 emitTypedefNode(typedef);
index b379152ee69a1be6ee8b4e86124225193eae564c..cd2c5985531810fb012e4096f46ec443dd1604fa 100644 (file)
@@ -147,16 +147,6 @@ public abstract class AbstractSchemaContext implements SchemaContext {
         return SchemaPath.ROOT;
     }
 
-    @Override
-    public String getDescription() {
-        return null;
-    }
-
-    @Override
-    public String getReference() {
-        return null;
-    }
-
     @Nonnull
     @Override
     public Status getStatus() {
index 7120e9d25cf459dfac911a239bfd768d6ab1f6a8..0ccc8036d2c2e606d3d15473ec5fc7ddac135589 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
 /**
  * Proxy for AugmentationSchema. Child node schemas are replaced with actual schemas from parent.
- *
  */
 public final class EffectiveAugmentationSchema implements AugmentationSchemaNode {
     private final AugmentationSchemaNode delegate;
@@ -56,12 +55,12 @@ public final class EffectiveAugmentationSchema implements AugmentationSchemaNode
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return delegate.getDescription();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return delegate.getReference();
     }
 
index bb10b18389ae4f09244e78e234d15b53c4d4b81d..2c986fdd35162c09ef181563d2c68c82f6a437de 100644 (file)
@@ -52,8 +52,8 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
@@ -67,8 +67,8 @@ final class PatternConstraintImpl implements PatternConstraint, Immutable {
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index a25051a6543784b2298e157639284d9ecca11eb4..ce06bfed82f7c5c096e75478ba5f51c30866233c 100644 (file)
@@ -53,8 +53,8 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
@@ -68,8 +68,8 @@ final class RangeConstraintImpl implements RangeConstraint, Immutable {
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index ef9f97d0d1abf879791f23bc474b6a2819a209d2..3d05a9b4bac4e073375b655bda921671f2cd12ee 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.collect.ImmutableList;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -41,13 +42,13 @@ abstract class AbstractBaseType<T extends TypeDefinition<T>> extends AbstractTyp
     }
 
     @Override
-    public final String getDescription() {
-        return null;
+    public final Optional<String> getDescription() {
+        return Optional.empty();
     }
 
     @Override
-    public final String getReference() {
-        return null;
+    public final Optional<String> getReference() {
+        return Optional.empty();
     }
 
     @Nonnull
index c195878b710b892f918641e14c2ebac031daf5ff..eefc4a68b5834a34f27b40d24ba1436c1a854d6f 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -54,13 +55,13 @@ abstract class AbstractDerivedType<T extends TypeDefinition<T>> extends Abstract
     }
 
     @Override
-    public final String getDescription() {
-        return description;
+    public final Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public final String getReference() {
-        return reference;
+    public final Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Nonnull
index d40fdd657715e98087bce98eb822a7174e1d66a6..89d5d129ad476ac503622ff5dc009a5e88deb40a 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 
 import com.google.common.base.Preconditions;
 import java.util.Collection;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -40,12 +41,12 @@ abstract class AbstractRestrictedType<T extends TypeDefinition<T>> extends Abstr
     }
 
     @Override
-    public final String getDescription() {
+    public final Optional<String> getDescription() {
         return baseType.getDescription();
     }
 
     @Override
-    public final String getReference() {
+    public final Optional<String> getReference() {
         return baseType.getReference();
     }
 
index 08246d9a0960122a6cefd938f07d4a585e310903..579c69f827a094a6b51e3e98d714607c65a672bf 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.util.type;
 import com.google.common.base.Preconditions;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -51,13 +52,13 @@ final class BitImpl implements Bit, Immutable {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Nonnull
index 4a9b6d9b94b6a45d1b202a8b8362d2c44b485c68..e61d0f4a6ce3eb1f054dfcbeb5265967c2cf4f6f 100644 (file)
@@ -26,15 +26,9 @@ public abstract class ConcreteTypeBuilder<T extends TypeDefinition<T>> extends D
     ConcreteTypeBuilder(final T baseType, final SchemaPath path) {
         super(baseType, path);
 
-        if (baseType.getDescription() != null) {
-            setDescription(baseType.getDescription());
-        }
-        if (baseType.getReference() != null) {
-            setReference(baseType.getReference());
-        }
-        if (baseType.getStatus() != null) {
-            setStatus(baseType.getStatus());
-        }
+        setStatus(baseType.getStatus());
+        baseType.getDescription().ifPresent(this::setDescription);
+        baseType.getReference().ifPresent(this::setReference);
     }
 
     /**
index 07deab72c158a0376b250b028c1bb231766a8148..a0fd036802cbbd4e533a384825d27d7c03a3776d 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -42,13 +43,13 @@ final class EnumPairImpl implements EnumPair, Immutable {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Nonnull
index 216728f9d1099e5e6b23f9a991c16915c8f3ca43..1f9ea4b59e5da7fd0646f7b3a8f6ec66b680ed8a 100644 (file)
@@ -23,8 +23,8 @@ final class JavaLengthConstraints {
 
     static final LengthConstraint INTEGER_SIZE_CONSTRAINTS = new LengthConstraint() {
         @Override
-        public String getReference() {
-            return null;
+        public Optional<String> getReference() {
+            return Optional.empty();
         }
 
         @Override
@@ -38,8 +38,8 @@ final class JavaLengthConstraints {
         }
 
         @Override
-        public String getDescription() {
-            return null;
+        public Optional<String> getDescription() {
+            return Optional.empty();
         }
 
         @Override
index 03bd31bdb99fdcc8b70c828ad7dc8ac6c15d0005..7fa9863e8978bff230712283860b8806383c69b4 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
 import java.util.Collection;
 import java.util.List;
-import java.util.Optional;
 import java.util.function.Function;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -64,9 +63,8 @@ public abstract class RangeRestrictedTypeBuilder<T extends RangeRestrictedTypeDe
                 final Number rMin = min instanceof UnresolvedNumber
                     ?  ((UnresolvedNumber)min).resolveRange(baseRangeConstraints) : min;
 
-                builder.add(BaseConstraints.newRangeConstraint(rMin, rMax, Optional.ofNullable(c.getDescription()),
-                    Optional.ofNullable(c.getReference()), c.getErrorAppTag().orElse(null),
-                    c.getErrorMessage().orElse(null)));
+                builder.add(BaseConstraints.newRangeConstraint(rMin, rMax, c.getDescription(),
+                    c.getReference(), c.getErrorAppTag().orElse(null), c.getErrorMessage().orElse(null)));
             } else {
                 builder.add(c);
             }
@@ -106,9 +104,8 @@ public abstract class RangeRestrictedTypeBuilder<T extends RangeRestrictedTypeDe
                     throw new IllegalArgumentException(String.format("Constraint %s does not fit into range of %s",
                         c, clazz.getSimpleName()), e);
                 }
-                builder.add(BaseConstraints.newRangeConstraint(min, max, Optional.ofNullable(c.getDescription()),
-                    Optional.ofNullable(c.getReference()), c.getErrorAppTag().orElse(null),
-                    c.getErrorMessage().orElse(null)));
+                builder.add(BaseConstraints.newRangeConstraint(min, max, c.getDescription(), c.getReference(),
+                    c.getErrorAppTag().orElse(null), c.getErrorMessage().orElse(null)));
             } else {
                 builder.add(c);
             }
index 95e5c3e352a9102f779d8e60ddf27021ee75596e..7073fe384af193938e45c511e76ca36baf9fbf0d 100644 (file)
@@ -25,7 +25,7 @@ final class ResolvedLengthConstraint implements LengthConstraint {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return meta.getDescription();
     }
 
@@ -40,7 +40,7 @@ final class ResolvedLengthConstraint implements LengthConstraint {
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return meta.getReference();
     }
 
index cc541dffe261aa3f2af912cb905dcf8ef56e8232..399c24d7ebd86129726836f4ca3e073e555e4534 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.doReturn;
@@ -37,11 +38,11 @@ public class BitsTypeTest {
 
         BitsTypeDefinition bitsType = BaseTypes.bitsTypeBuilder(schemaPath).addBit(bit).build();
 
-        assertNull("Description is not null", bitsType.getDescription());
+        assertFalse(bitsType.getDescription().isPresent());
         assertEquals("QName", qname, bitsType.getQName());
         assertNull("Should be null", bitsType.getUnits());
         assertNotEquals("Description should not be null", null, bitsType.toString());
-        assertNull("Reference is not null", bitsType.getReference());
+        assertFalse(bitsType.getReference().isPresent());
         assertNull("BaseType should be null", bitsType.getBaseType());
         assertNull("Default value should be null", bitsType.getDefaultValue());
         assertEquals("getPath should equal schemaPath", schemaPath, bitsType.getPath());
index 7c57e819478781152b73de40744c53f9d8deac7d..7c32cdfe16689443298902b5f542bfd9d05e74ee 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.booleanType;
@@ -27,7 +28,7 @@ public class BooleanTypeTest {
         assertEquals("getPath gives List of BOOLEAN_QNAME",
                 Collections.singletonList(BaseTypes.BOOLEAN_QNAME), boolType.getPath().getPathFromRoot());
         assertEquals("getQName gives BOOLEAN_QNAME", BaseTypes.BOOLEAN_QNAME, boolType.getQName());
-        assertNull(boolType.getDescription());
+        assertFalse(boolType.getDescription().isPresent());
 
         final String strPath = boolType.getPath().toString();
         assertTrue("Should contain string of getPath", stringBoolType.contains(strPath));
index 366e81b912a7888591dc1f3fbc76513802dbd1ce..cb2ec8777a1f8ed44d8384756f64d96e18a2cf90 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.model.util.type.BaseTypes.emptyType;
 
@@ -29,9 +29,9 @@ public class EmptyTypeTest {
         assertEquals("BaseType", null, emptyType.getBaseType());
         assertEquals("DefaultValue", null, emptyType.getDefaultValue());
         assertEquals("Status", Status.CURRENT, emptyType.getStatus());
-        assertNull("Reference", emptyType.getReference());
+        assertFalse(emptyType.getReference().isPresent());
         assertEquals("Units", null, emptyType.getUnits());
-        assertNull("Description is not null", emptyType.getDescription());
+        assertFalse(emptyType.getDescription().isPresent());
         assertEquals("UnknownSchemaNodes", Collections.EMPTY_LIST, emptyType.getUnknownSchemaNodes());
         assertTrue("toString", emptyType.toString().contains("empty"));
     }
index 3dfe84a8ce54799634bb1cebbe1f255634a4b437..f3d8d258897c3527e70c8c4899adb0f0b441c7db 100644 (file)
@@ -46,8 +46,8 @@ public class LeafrefTest {
         assertNull("Leafref does not have a default value", leafref.getDefaultValue());
         assertEquals(QName.create("test", "List1"), leafref.getQName());
         assertEquals("SchemaPath of 'leafref' is '/Cont1/List1'.", schemaPath, leafref.getPath());
-        assertNull(leafref.getDescription());
-        assertNull(leafref.getReference());
+        assertFalse(leafref.getDescription().isPresent());
+        assertFalse(leafref.getReference().isPresent());
         assertEquals("Status of 'leafref' is current.", Status.CURRENT, leafref.getStatus());
         assertTrue("Object 'leafref' shouldn't have any unknown schema nodes.",
                 leafref.getUnknownSchemaNodes().isEmpty());
index a2b1f8fdf7ad447ffc120106164c4b8a88abab44..de067db4a9374e64eace86301c0be8cd6f04e3fc 100644 (file)
@@ -33,11 +33,11 @@ public class PatternConstraintImplTest {
         final PatternConstraintImpl patternConstraint5 = new PatternConstraintImpl(regexExp2, description2, reference2);
 
         assertNotNull("Object of PatternConstraintImpl shouldn't be null.", patternConstraint);
-        assertEquals("Description should be 'test description'.", "test description",
+        assertEquals("Description should be 'test description'.", Optional.of("test description"),
                 patternConstraint.getDescription());
         assertEquals(Optional.of("invalid-regular-expression"), patternConstraint.getErrorAppTag());
         assertTrue(patternConstraint.getErrorMessage().isPresent());
-        assertEquals("Reference should be equals 'RFC 6020'.", "RFC 6020", patternConstraint.getReference());
+        assertEquals(Optional.of("RFC 6020"), patternConstraint.getReference());
         assertEquals("Regular expression should be equls '\\D'.", "\\D", patternConstraint.getRegularExpression());
         assertNotEquals("Hash codes shouldn't be equals.", patternConstraint.hashCode(), patternConstraint2.hashCode());
         assertFalse("String representation shouldn't be empty.", patternConstraint.toString().isEmpty());
index a60ccfb13078a7332b17e0523d08b849fbab3041..26ab38275ee549d1477c13beaef13c4c653bbfc3 100644 (file)
@@ -607,6 +607,16 @@ public class SchemaContextProxyTest {
                     return module.getSemanticVersion();
                 }
 
+                @Override
+                public Optional<String> getDescription() {
+                    return module.getDescription();
+                }
+
+                @Override
+                public Optional<String> getReference() {
+                    return module.getReference();
+                }
+
                 @Override
                 public String toString() {
                     return String.format("Module: %s, revision:%s", module.getName(), module.getRevision());
index 4a2c575adf17e8003cd035c2c39e58f9a516ba4d..9b2ac4b5c649f66607f1b98fc148b75d01df3829 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertFalse;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -68,8 +69,8 @@ public class BitImplTest {
         // test of getter methods
         assertEquals("Incorrect value for qname.", qnameA2, biA.getQName());
         assertEquals("Incorrect value for schema path.", schemaPathA, biA.getPath());
-        assertEquals("Incorrect value for description.", "description", biA.getDescription());
-        assertEquals("Incorrect value for reference.", "reference", biA.getReference());
+        assertEquals("Incorrect value for description.", Optional.of("description"), biA.getDescription());
+        assertEquals("Incorrect value for reference.", Optional.of("reference"), biA.getReference());
         assertEquals("Incorrect value for status.", Status.CURRENT, biA.getStatus());
         assertEquals("Incorrect value for unknown nodes.", emptyList(), biA.getUnknownSchemaNodes());
 
index 2d173741e4f2d372021cfded3b7f52da40bd16ff..694e9f29317d67f1bc58110c33fe2d1a20cf17d2 100644 (file)
@@ -16,6 +16,7 @@ import static org.mockito.Mockito.mock;
 
 import com.google.common.collect.ImmutableList;
 import java.util.Collection;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
@@ -37,8 +38,8 @@ public class EnumPairImplTest {
 
         assertNotNull(enumPair);
         assertEquals(unknownSchemaNodes, enumPair.getUnknownSchemaNodes());
-        assertEquals("enum description", enumPair.getDescription());
-        assertEquals("enum reference", enumPair.getReference());
+        assertEquals(Optional.of("enum description"), enumPair.getDescription());
+        assertEquals(Optional.of("enum reference"), enumPair.getReference());
         assertEquals(Status.DEPRECATED, enumPair.getStatus());
 
         final EnumPair enumPair2 = EnumPairBuilder.create("enum-zero", 0).setStatus(Status.DEPRECATED)
index 38dfc759afc123c38955dd02b364ded8fd018963..a6957fac444e9ea9057344e15c9f0ccddf386b7e 100644 (file)
@@ -384,9 +384,9 @@ public class TypeTest {
         final BaseBinaryType baseBinaryType1 = BaseBinaryType.INSTANCE;
         final AbstractDerivedType<?> abstractDerivedType = (AbstractDerivedType<?>)
             DerivedTypes.derivedTypeBuilder(baseBinaryType1, SCHEMA_PATH).build();
-        assertEquals(abstractDerivedType.getDescription(), null);
-        assertEquals(abstractDerivedType.getReference(), null);
-        assertEquals(abstractDerivedType.getStatus().toString(), "CURRENT");
+        assertEquals(Optional.empty(), abstractDerivedType.getDescription());
+        assertEquals(Optional.empty(), abstractDerivedType.getReference());
+        assertEquals(Status.CURRENT, abstractDerivedType.getStatus());
         assertFalse(DerivedTypes.isInt8(baseBinaryType1));
         assertFalse(DerivedTypes.isUint8(baseBinaryType1));
         assertFalse(DerivedTypes.isInt16(baseBinaryType1));
index b97edabb1a9344f93e67afd06d452297692380bb..fdabf9029eb4728a706e505f96a94bea140da4f2 100644 (file)
@@ -410,6 +410,16 @@ public abstract class YangModelDependencyInfo {
             return null;
         }
 
+        @Override
+        public Optional<String> getDescription() {
+            return Optional.empty();
+        }
+
+        @Override
+        public Optional<String> getReference() {
+            return Optional.empty();
+        }
+
         @Override
         public int hashCode() {
             final int prime = 31;
index f1edb2d920cfa92cd2b753d5393f5efe56597422..662e7b90cae0756c007a265188e7f44d5598f06d 100644 (file)
@@ -166,6 +166,16 @@ abstract class DependencyResolver {
             return Optional.empty();
         }
 
+        @Override
+        public Optional<String> getDescription() {
+            return Optional.empty();
+        }
+
+        @Override
+        public Optional<String> getReference() {
+            return Optional.empty();
+        }
+
         @Override
         public String getPrefix() {
             return null;
index a2e62f20a0a316b0c0130c4d5d2ec7b21eba390b..f058b44b1ddfddbf01222128758a88961bdf7771 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -52,13 +53,13 @@ public abstract class AbstractEffectiveDocumentedNode<A, D extends DeclaredState
     }
 
     @Override
-    public final String getDescription() {
-        return description;
+    public final Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public final String getReference() {
-        return reference;
+    public final Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Nonnull
index 35b3a41be956f68c0d569a32afd014e058facb24..2b6b325c029856f4186aa506ae310e2337461cd8 100644 (file)
@@ -86,12 +86,12 @@ final class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
     }
 
     @Override
-    public String getDescription() {
+    public Optional<String> getDescription() {
         return caseShorthandNode.getDescription();
     }
 
     @Override
-    public String getReference() {
+    public Optional<String> getReference() {
         return caseShorthandNode.getReference();
     }
 
index d2086a5b07f15e58955997c95f08b9330000bb61..fb232bd40be0ef9e5af33ee1b42a940a95d7ffd3 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
@@ -62,13 +63,13 @@ public class DeviationEffectiveStatementImpl
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index 86cf7d9c955cf30e8df4afcdbbb714e002b2a916..d3feaad3de45f35256c166f685e518b01e6e558b 100644 (file)
@@ -96,13 +96,13 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
@@ -129,9 +129,8 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(this).add("moduleName", getModuleName())
-                .add("revision", getRevision()).add("semantic version", getSemanticVersion())
-                .add("prefix", getPrefix()).add("description", getDescription())
-                .add("reference", getReference()).toString();
+        return MoreObjects.toStringHelper(this).omitNullValues().add("moduleName", getModuleName())
+                .add("revision", revision).add("version", semVer).add("prefix", getPrefix())
+                .add("description", description).add("reference", reference).toString();
     }
 }
index b6a3af42cd91f188b68c7673abedad23231f6276..b03f416be22db456aef13a6a14cc8658e3e2a5ce 100644 (file)
@@ -46,8 +46,8 @@ public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<R
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
@@ -61,8 +61,8 @@ public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<R
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index e2dd62e67113f4bb8757c8865a909feff5c942d7..38c4c256f3bf0c8624175e23d9603a1fba2e3930 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
+import java.util.Optional;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
@@ -37,12 +38,12 @@ public final class RevisionEffectiveStatementImpl extends DeclaredEffectiveState
     }
 
     @Override
-    public String getDescription() {
-        return this.description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
-    public String getReference() {
-        return this.reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 }
index b936e6a363b19107aa96b6924c273c8470dbc0f4..324c9ea7bbfb7f782eecbcbd075909d52045cd72 100644 (file)
@@ -74,8 +74,8 @@ abstract class AbstractConstraintEffectiveStatement<A, D extends DeclaredStateme
     }
 
     @Override
-    public final String getDescription() {
-        return description;
+    public final Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     public final ModifierKind getModifier() {
@@ -83,8 +83,8 @@ abstract class AbstractConstraintEffectiveStatement<A, D extends DeclaredStateme
     }
 
     @Override
-    public final String getReference() {
-        return reference;
+    public final Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index c3be36971b0c87b5d52337b29986dc1f817dbb62..da37904bfdc87bc2d3a8857a8baa28ce42698a8f 100644 (file)
@@ -49,19 +49,20 @@ public final class BitsSpecificationEffectiveStatementImpl extends
                     effectivePos = bitSubStmt.getDeclaredPosition();
                 }
 
-                final Bit b = BitBuilder.create(bitSubStmt.getPath(), effectivePos)
-                        .setDescription(bitSubStmt.getDescription()).setReference(bitSubStmt.getReference())
-                        .setStatus(bitSubStmt.getStatus()).setUnknownSchemaNodes(bitSubStmt.getUnknownSchemaNodes())
-                        .build();
+                final BitBuilder bitBuilder = BitBuilder.create(bitSubStmt.getPath(), effectivePos)
+                        .setStatus(bitSubStmt.getStatus());
+                bitSubStmt.getDescription().ifPresent(bitBuilder::setDescription);
+                bitSubStmt.getReference().ifPresent(bitBuilder::setReference);
 
-                SourceException.throwIf(b.getPosition() < 0L && b.getPosition() > 4294967295L,
-                        ctx.getStatementSourceReference(), "Bit %s has illegal position", b);
+                final Bit bit = bitBuilder.build();
+                SourceException.throwIf(bit.getPosition() < 0L && bit.getPosition() > 4294967295L,
+                        ctx.getStatementSourceReference(), "Bit %s has illegal position", bit);
 
-                if (highestPosition == null || highestPosition < b.getPosition()) {
-                    highestPosition = b.getPosition();
+                if (highestPosition == null || highestPosition < bit.getPosition()) {
+                    highestPosition = bit.getPosition();
                 }
 
-                builder.addBit(b);
+                builder.addBit(bit);
             }
             if (stmt instanceof UnknownEffectiveStatementImpl) {
                 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt);
index 6d775b12c99360e62ebbd0b58a9a5ec12255c5b2..9154554e53d4819fb214703e9b65dc24125fb6c5 100644 (file)
@@ -49,12 +49,11 @@ public final class BitsTypeEffectiveStatementImpl extends DeclaredEffectiveState
                     effectivePos = bitSubStmt.getDeclaredPosition();
                 }
 
-                final Bit b = BitBuilder.create(bitSubStmt.getPath(), effectivePos)
-                        .setDescription(bitSubStmt.getDescription()).setReference(bitSubStmt.getReference())
-                        .setStatus(bitSubStmt.getStatus()).setUnknownSchemaNodes(bitSubStmt.getUnknownSchemaNodes())
-                        .build();
-
-                builder.addBit(b);
+                final BitBuilder bitBuilder = BitBuilder.create(bitSubStmt.getPath(), effectivePos)
+                        .setStatus(bitSubStmt.getStatus());
+                bitSubStmt.getDescription().ifPresent(bitBuilder::setDescription);
+                bitSubStmt.getReference().ifPresent(bitBuilder::setReference);
+                builder.addBit(bitBuilder.build());
             } else if (stmt instanceof UnknownEffectiveStatementImpl) {
                 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt);
             }
index 1b4efe16faa7ccfda5168298b7a35938f276fa0d..82f918c14c3fe41ac86285bff0be2706d780c9ac 100644 (file)
@@ -50,16 +50,17 @@ public final class EnumSpecificationEffectiveStatementImpl extends
                     effectiveValue = enumSubStmt.getDeclaredValue();
                 }
 
-                final EnumPair p = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue)
-                        .setDescription(enumSubStmt.getDescription()).setReference(enumSubStmt.getReference())
-                        .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes())
-                        .build();
+                final EnumPairBuilder pairBuilder = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue)
+                        .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes());
+                enumSubStmt.getDescription().ifPresent(pairBuilder::setDescription);
+                enumSubStmt.getReference().ifPresent(pairBuilder::setReference);
 
-                if (highestValue == null || highestValue < p.getValue()) {
-                    highestValue = p.getValue();
+                final EnumPair pair = pairBuilder.build();
+                if (highestValue == null || highestValue < pair.getValue()) {
+                    highestValue = pair.getValue();
                 }
 
-                builder.addEnum(p);
+                builder.addEnum(pair);
             }
             if (stmt instanceof UnknownEffectiveStatementImpl) {
                 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt);
index 9408310214a6f169faca9a9e80fbe7a5a1d90e0f..be9e835c8f4d5cea506b4c959f94ece2a759b436 100644 (file)
@@ -51,12 +51,12 @@ public final class EnumTypeEffectiveStatementImpl extends DeclaredEffectiveState
                     effectiveValue = enumSubStmt.getDeclaredValue();
                 }
 
-                final EnumPair p = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue)
-                        .setDescription(enumSubStmt.getDescription()).setReference(enumSubStmt.getReference())
-                        .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes())
-                        .build();
+                final EnumPairBuilder pairBuilder = EnumPairBuilder.create(enumSubStmt.getName(), effectiveValue)
+                        .setStatus(enumSubStmt.getStatus()).setUnknownSchemaNodes(enumSubStmt.getUnknownSchemaNodes());
+                enumSubStmt.getDescription().ifPresent(pairBuilder::setDescription);
+                enumSubStmt.getReference().ifPresent(pairBuilder::setReference);
 
-                builder.addEnum(p);
+                builder.addEnum(pairBuilder.build());
             } else if (stmt instanceof UnknownEffectiveStatementImpl) {
                 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl) stmt);
             }
index cb664d969361c91a062ca0a3b819951ef343d437..971dd2be583b0c98bbbc7de33a17b8f139df9d67 100644 (file)
@@ -53,8 +53,8 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
@@ -73,8 +73,8 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint {
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index 8cfbbba08b4dbe573d478423a5a3b90983920821..14a5aad109516acfcce69c31340b2dbf58a438cf 100644 (file)
@@ -24,7 +24,7 @@ public class PatternEffectiveStatementImpl extends
         }
 
         return new PatternConstraintEffectiveImpl(argument.getRegularExpression(), argument.getRawRegularExpression(),
-            getDescription(), getReference(), getErrorAppTag().orElse(null), getErrorMessage().orElse(null),
-            getModifier());
+            getDescription().orElse(null), getReference().orElse(null), getErrorAppTag().orElse(null),
+            getErrorMessage().orElse(null), getModifier());
     }
 }
index 89e277d3c49b552b400946e99245fb1db1712aa2..a5fedd5b9af6beab918232f7ec99b92b83999b65 100644 (file)
@@ -43,8 +43,8 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint {
     }
 
     @Override
-    public String getDescription() {
-        return description;
+    public Optional<String> getDescription() {
+        return Optional.ofNullable(description);
     }
 
     @Override
@@ -58,8 +58,8 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint {
     }
 
     @Override
-    public String getReference() {
-        return reference;
+    public Optional<String> getReference() {
+        return Optional.ofNullable(reference);
     }
 
     @Override
index 416f6295f48dedf73a6820942097e912b214eb0f..974464b15f2205eea0e65f87a7afa9759202d767 100644 (file)
@@ -21,6 +21,7 @@ public class RangeEffectiveStatementImpl extends
     @Override
     final RangeConstraint createCustomizedConstraint(final RangeConstraint rangeConstraint) {
         return new RangeConstraintEffectiveImpl(rangeConstraint.getMin(), rangeConstraint.getMax(),
-                getDescription(), getReference(), getErrorAppTag().orElse(null), getErrorMessage().orElse(null));
+                getDescription().orElse(null), getReference().orElse(null), getErrorAppTag().orElse(null),
+                getErrorMessage().orElse(null));
     }
 }
index 22a75352775ce299f0bbf9eb4fa82f33e59465fa..95198e45c4764375b1b49e6c4079f2adf9a579eb 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
@@ -52,8 +53,10 @@ public class Bug6874Test {
 
         // Test for valid import statement
         ModuleImport importStmt = testModule.getImports().iterator().next();
-        assertEquals("Yang 1.1: Allow description and reference in include and import.", importStmt.getDescription());
-        assertEquals("https://tools.ietf.org/html/rfc7950 section-7.1.5/6", importStmt.getReference());
+        assertEquals(Optional.of("Yang 1.1: Allow description and reference in include and import."),
+            importStmt.getDescription());
+        assertEquals(Optional.of("https://tools.ietf.org/html/rfc7950 section-7.1.5/6"),
+            importStmt.getReference());
     }
 
     @Test
index 00a51c738e6efb87c2ce286b01a8ca8c869a4367..bc5c6dd6fa5e41c7427f9366404ed0cc8cd09e39 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AnyDataSchemaNode;
@@ -34,7 +35,7 @@ public class Bug6883Test {
 
         final AnyDataSchemaNode topAnyData = assertAnyData(schemaContext, ImmutableList.of("top"));
         assertEquals(Status.DEPRECATED, topAnyData.getStatus());
-        assertEquals("top anydata", topAnyData.getDescription());
+        assertEquals(Optional.of("top anydata"), topAnyData.getDescription());
 
         assertAnyData(schemaContext, ImmutableList.of("root", "root-anydata"));
         assertAnyData(schemaContext, ImmutableList.of("root", "aug-anydata"));
index dd4e0889abab78c3ccfd1c5c2a34389a4aa8b3a8..921fc445f87027a3b7cab5dc9cb975cab54b9f87 100644 (file)
@@ -11,9 +11,9 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -43,8 +43,8 @@ public class Bug5481Test {
 
         assertFalse(topContainer.getConstraints().getWhenCondition().isPresent());
         assertEquals(Status.CURRENT, topContainer.getStatus());
-        assertNull(topContainer.getDescription());
-        assertNull(topContainer.getReference());
+        assertFalse(topContainer.getDescription().isPresent());
+        assertFalse(topContainer.getReference().isPresent());
         return topContainer;
     }
 
@@ -58,7 +58,7 @@ public class Bug5481Test {
 
         assertEquals(new RevisionAwareXPathImpl("module1:top = 'extended'", false), whenConditionExtendedLeaf);
         assertEquals(Status.DEPRECATED, extendedLeaf.getStatus());
-        assertEquals("text", extendedLeaf.getDescription());
-        assertEquals("ref", extendedLeaf.getReference());
+        assertEquals(Optional.of("text"), extendedLeaf.getDescription());
+        assertEquals(Optional.of("ref"), extendedLeaf.getReference());
     }
 }
index 05a80e10176a820b14ef7e4870525d12b61d2103..5c7b541529cb3ae782a4875810a41d987c565c8e 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -37,8 +38,8 @@ public class Bug5942Test {
         assertEquals(1, uses.size());
         final UsesNode usesNode = uses.iterator().next();
 
-        assertEquals("uses description", usesNode.getDescription());
-        assertEquals("uses reference", usesNode.getReference());
+        assertEquals(Optional.of("uses description"), usesNode.getDescription());
+        assertEquals(Optional.of("uses reference"), usesNode.getReference());
         assertEquals(Status.DEPRECATED, usesNode.getStatus());
         assertEquals(new RevisionAwareXPathImpl("0!=1", false), usesNode.getWhenCondition().get());
 
index 2700ef44f1f61e36b97e2598526550bd4b3c7ac1..a3a4080e0ffcaec186f22065d28e536c79d44192 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import java.util.regex.Pattern;
 import org.junit.Test;
@@ -36,10 +37,10 @@ public class Bug6180Test {
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
         final Module module = schemaContext.getModules().iterator().next();
-        assertEquals("    1. this text contains \"string enclosed in double quotes\" and"
+        assertEquals(Optional.of("    1. this text contains \"string enclosed in double quotes\" and"
                 + " special characters: \\,\n,\t          2. this text contains \"string enclosed in double quotes\""
                 + " and special characters: \\,\n,\n,                     3. this text contains \"string enclosed in"
-                + " double quotes\" and special characters: \\,\n,\t      ", module.getDescription());
+                + " double quotes\" and special characters: \\,\n,\t      "), module.getDescription());
     }
 
     @Test
index fe79eb6592baf29a443c80cff2c8eb35dc97f8e1..687d0855e5c006bfb28e97e330bd3277dc03397f 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -32,7 +33,7 @@ public class Bug7879Test {
             instanceof ContainerSchemaNode);
         final SchemaNode myEventValueLeaf = findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-value"));
         assertTrue(myEventValueLeaf instanceof LeafSchemaNode);
-        assertEquals("new description", myEventValueLeaf.getDescription());
+        assertEquals(Optional.of("new description"), myEventValueLeaf.getDescription());
     }
 
     private static SchemaNode findNode(final SchemaContext context, final QName... qnames) {
index 14931f5908bc4d7f0cd826365798800648911615..c3dd3c270f6a83beddb8033c320462cb64fcb839 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -31,13 +32,13 @@ public class Bug8597Test {
             switch (moduleImport.getModuleName()) {
                 case "bar":
                     assertEquals(Revision.ofNullable("1970-01-01"), moduleImport.getRevision());
-                    assertEquals("bar-ref", moduleImport.getReference());
-                    assertEquals("bar-desc", moduleImport.getDescription());
+                    assertEquals(Optional.of("bar-ref"), moduleImport.getReference());
+                    assertEquals(Optional.of("bar-desc"), moduleImport.getDescription());
                     break;
                 case "baz":
                     assertEquals(Revision.ofNullable("2010-10-10"), moduleImport.getRevision());
-                    assertEquals("baz-ref", moduleImport.getReference());
-                    assertEquals("baz-desc", moduleImport.getDescription());
+                    assertEquals(Optional.of("baz-ref"), moduleImport.getReference());
+                    assertEquals(Optional.of("baz-desc"), moduleImport.getDescription());
                     break;
                 default:
                     fail("Module 'foo' should only contains import of module 'bar' and 'baz'");
index 6f5fc5de747097d3b4306f74261a948e0394f2dc..cf2353904258322b8ae9c03a7afbbdb85b738e83 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableSet;
+import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -30,7 +31,7 @@ public class Bug8922Test {
         assertNotNull(context);
         final SchemaNode findNode = findNode(context, qN("target"), qN("my-con"));
         assertTrue(findNode instanceof ContainerSchemaNode);
-        assertEquals("New description", ((ContainerSchemaNode) findNode).getDescription());
+        assertEquals(Optional.of("New description"), ((ContainerSchemaNode) findNode).getDescription());
     }
 
     @Test
index fca033d2500f3151c2080c7d03610cc43a90738a..6da3c70dfbd42a69033b398ec1fb11051c8bf417 100644 (file)
@@ -16,6 +16,7 @@ import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResour
 
 import java.text.ParseException;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -53,7 +54,7 @@ public class DeviationStmtTest {
             final List<DeviateDefinition> deviates = deviation.getDeviates();
             final String targetLocalName = deviation.getTargetPath().getLastComponent().getLocalName();
             if ("test-leaf".equals(targetLocalName)) {
-                assertEquals("test-leaf is not supported", deviation.getDescription());
+                assertEquals(Optional.of("test-leaf is not supported"), deviation.getDescription());
                 assertEquals(1, deviates.size());
                 assertEquals(DeviateKind.NOT_SUPPORTED, deviates.iterator().next().getDeviateType());
             } else if ("test-leaf-2".equals(targetLocalName)) {
@@ -114,7 +115,7 @@ public class DeviationStmtTest {
             }
 
             if ("bar-leaf-1".equals(targetLocalName)) {
-                if ("desc".equals(deviation.getDescription())) {
+                if (Optional.of("desc").equals(deviation.getDescription())) {
                     deviation4 = deviation;
                 } else {
                     deviation5 = deviation;
@@ -122,7 +123,7 @@ public class DeviationStmtTest {
             }
 
             if ("bar-leaf-2".equals(targetLocalName)) {
-                if ("ref".equals(deviation.getReference())) {
+                if (Optional.of("ref").equals(deviation.getReference())) {
                     deviation6 = deviation;
                 } else {
                     deviation7 = deviation;
index c96fccc457b2161def2442c65ec9c3ff41537146..7a5a4482b626e5a343ff1a654d52a137d315266e 100644 (file)
@@ -112,7 +112,7 @@ public class EffectiveModuleTest {
         final SchemaPath importedContSchemaPath = SchemaPath.create(true, importedContQName);
         assertEquals(importedContSchemaPath, deviationStmt.getTargetPath());
         assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType());
-        assertEquals("deviate reference", deviationStmt.getReference());
+        assertEquals(Optional.of("deviate reference"), deviationStmt.getReference());
 
         final Set<IdentitySchemaNode> identities = rootModule.getIdentities();
         assertEquals(1, identities.size());
@@ -124,8 +124,8 @@ public class EffectiveModuleTest {
         assertNotNull(featureStmt);
         assertEquals(FEATURE1, featureStmt.getQName());
         assertEquals(FEATURE1_SCHEMA_PATH, featureStmt.getPath());
-        assertEquals("feature1 description", featureStmt.getDescription());
-        assertEquals("feature1 reference", featureStmt.getReference());
+        assertEquals(Optional.of("feature1 description"), featureStmt.getDescription());
+        assertEquals(Optional.of("feature1 reference"), featureStmt.getReference());
         assertEquals(Status.CURRENT, featureStmt.getStatus());
 
         final List<ExtensionDefinition> extensionSchemaNodes = rootModule.getExtensionSchemaNodes();
index 10f09dbd84109ec1a5ba5eba46124a7bf615034e..0197038fdcf1d8c9273e66f601002f4363f6e0fc 100644 (file)
@@ -15,6 +15,7 @@ import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResour
 
 import java.net.URI;
 import java.util.Collection;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -163,7 +164,7 @@ public class EffectiveModulesAndSubmodulesTest {
         final DataSchemaNode containerInRoot = result.getDataChildByName(QName
                 .create(root.getQNameModule(), "container-in-root-module"));
         assertNotNull(containerInRoot);
-        assertEquals("desc", containerInRoot.getDescription());
+        assertEquals(Optional.of("desc"), containerInRoot.getDescription());
     }
 
     private static void findModulesSubTest(final SchemaContext result, final Module root, final Module imported) {
index 176ed80a9f0fc278b3dce73ae912c5a54cf3c44c..702081e2f86f2c81875be6236e878a082ccbb19e 100644 (file)
@@ -87,8 +87,8 @@ public class EffectiveSchemaContextTest {
         assertFalse(schemaContext.isConfiguration());
         assertFalse(schemaContext.isPresenceContainer());
         assertNull(schemaContext.getConstraints());
-        assertNull(schemaContext.getDescription());
-        assertNull(schemaContext.getReference());
+        assertFalse(schemaContext.getDescription().isPresent());
+        assertFalse(schemaContext.getReference().isPresent());
         assertEquals(SchemaContext.NAME, schemaContext.getQName());
         assertEquals(SchemaPath.ROOT, schemaContext.getPath());
         assertEquals(Status.CURRENT, schemaContext.getStatus());
index df387ffb254e4d5b3c6a64341e88857780c4cdcb..dc9072d5f7923040708de5e015613b497e29472c 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
@@ -83,11 +84,11 @@ public class EffectiveStatementTypeTest {
         assertNull(binaryEff.getDefaultValue());
         assertEquals("binary", binaryEff.getQName().getLocalName());
         assertFalse(binaryEff.getLengthConstraint().isPresent());
-        assertEquals("CURRENT", binaryEff.getStatus().toString());
+        assertEquals(Status.CURRENT, binaryEff.getStatus());
         assertEquals("binary", binaryEff.getPath().getPathFromRoot().iterator().next().getLocalName());
         assertNotNull(binaryEff.getUnknownSchemaNodes());
-        assertNull(binaryEff.getDescription());
-        assertNull(binaryEff.getReference());
+        assertFalse(binaryEff.getDescription().isPresent());
+        assertFalse(binaryEff.getReference().isPresent());
     }
 
     @Test
@@ -108,9 +109,9 @@ public class EffectiveStatementTypeTest {
         assertEquals("bits", bitsEff.getQName().getLocalName());
         assertEquals("bits", bitsEff.getPath().getLastComponent().getLocalName());
         assertNotNull(bitsEff.getUnknownSchemaNodes());
-        assertNull(bitsEff.getDescription());
-        assertNull(bitsEff.getReference());
-        assertEquals("CURRENT", bitsEff.getStatus().toString());
+        assertFalse(bitsEff.getDescription().isPresent());
+        assertFalse(bitsEff.getReference().isPresent());
+        assertEquals(Status.CURRENT, bitsEff.getStatus());
         assertNull(bitsEff.getUnits());
         assertNotNull(bitsEff.toString());
         assertNotNull(bitsEff.hashCode());
@@ -122,9 +123,9 @@ public class EffectiveStatementTypeTest {
 
         assertNotNull(bitEff.getPath());
         assertNotNull(bitEff.getUnknownSchemaNodes());
-        assertEquals("test bit", bitEff.getDescription());
-        assertEquals("test bit ref", bitEff.getReference());
-        assertEquals("CURRENT", bitEff.getStatus().toString());
+        assertEquals(Optional.of("test bit"), bitEff.getDescription());
+        assertEquals(Optional.of("test bit ref"), bitEff.getReference());
+        assertEquals(Status.CURRENT, bitEff.getStatus());
         assertNotNull(bitEff.hashCode());
         assertFalse(bitEff.equals(null));
         assertFalse(bitEff.equals("test"));
@@ -149,9 +150,9 @@ public class EffectiveStatementTypeTest {
         assertEquals("boolean", booleanEff.getQName().getLocalName());
         assertNull(booleanEff.getPath().getParent().getParent());
         assertNotNull(booleanEff.getUnknownSchemaNodes());
-        assertNull(booleanEff.getDescription());
-        assertNull(booleanEff.getReference());
-        assertEquals("CURRENT", booleanEff.getStatus().toString());
+        assertFalse(booleanEff.getDescription().isPresent());
+        assertFalse(booleanEff.getReference().isPresent());
+        assertEquals(Status.CURRENT, booleanEff.getStatus());
         assertNotNull(booleanEff.toString());
     }
 
@@ -172,9 +173,9 @@ public class EffectiveStatementTypeTest {
         // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we
         // parse it?
         // allowed under 'type', how come we parse it?
-        assertNull(decimal64Eff.getDescription());
-        assertNull(decimal64Eff.getReference());
-        assertEquals("CURRENT", decimal64Eff.getStatus().toString());
+        assertFalse(decimal64Eff.getDescription().isPresent());
+        assertFalse(decimal64Eff.getReference().isPresent());
+        assertEquals(Status.CURRENT, decimal64Eff.getStatus());
 
         assertEquals(3, decimal64Eff.getRangeConstraints().size());
         assertNotNull(decimal64Eff.toString());
@@ -200,8 +201,8 @@ public class EffectiveStatementTypeTest {
         assertEquals("empty", emptyEff.getQName().getLocalName());
         assertNull(emptyEff.getPath().getParent().getParent());
         assertNotNull(emptyEff.getUnknownSchemaNodes());
-        assertNull(emptyEff.getDescription());
-        assertNull(emptyEff.getReference());
+        assertFalse(emptyEff.getDescription().isPresent());
+        assertFalse(emptyEff.getReference().isPresent());
         assertEquals("CURRENT", emptyEff.getStatus().toString());
         assertNotNull(emptyEff.toString());
     }
@@ -223,9 +224,9 @@ public class EffectiveStatementTypeTest {
         assertEquals(3, enumSpecEff.getValues().size());
         assertNull(enumSpecEff.getBaseType());
         assertNotNull(enumSpecEff.getUnknownSchemaNodes());
-        assertEquals("CURRENT", enumSpecEff.getStatus().toString());
-        assertNull(enumSpecEff.getDescription());
-        assertNull(enumSpecEff.getReference());
+        assertEquals(Status.CURRENT, enumSpecEff.getStatus());
+        assertFalse(enumSpecEff.getDescription().isPresent());
+        assertFalse(enumSpecEff.getReference().isPresent());
         assertNull(enumSpecEff.getUnits());
         assertNotNull(enumSpecEff.toString());
         assertNotNull(enumSpecEff.hashCode());
@@ -235,9 +236,9 @@ public class EffectiveStatementTypeTest {
 
         assertEquals("zero", enumEff.getName());
         assertNotNull(enumEff.getUnknownSchemaNodes());
-        assertEquals("test enum", enumEff.getDescription());
-        assertEquals("test enum ref", enumEff.getReference());
-        assertEquals("CURRENT", enumEff.getStatus().toString());
+        assertEquals(Optional.of("test enum"), enumEff.getDescription());
+        assertEquals(Optional.of("test enum ref"), enumEff.getReference());
+        assertEquals(Status.CURRENT, enumEff.getStatus());
         assertEquals(0, enumEff.getValue());
     }
 
@@ -255,10 +256,10 @@ public class EffectiveStatementTypeTest {
         assertEquals("identityref", identityRefEff.getPath().getLastComponent().getLocalName());
         assertNull(identityRefEff.getBaseType());
         assertNotNull(identityRefEff.getUnknownSchemaNodes());
-        assertEquals("CURRENT", identityRefEff.getStatus().toString());
+        assertEquals(Status.CURRENT, identityRefEff.getStatus());
         assertEquals("test-identity", identityRefEff.getIdentity().getQName().getLocalName());
-        assertNull(identityRefEff.getDescription());
-        assertNull(identityRefEff.getReference());
+        assertFalse(identityRefEff.getDescription().isPresent());
+        assertFalse(identityRefEff.getReference().isPresent());
         assertNotNull(identityRefEff.toString());
 
         // FIXME: the model is wrong, but we accept units in 'type' statement
@@ -281,10 +282,10 @@ public class EffectiveStatementTypeTest {
         assertNull(instanceIdentEff.getBaseType());
         assertNull(instanceIdentEff.getDefaultValue());
         assertNotNull(instanceIdentEff.getUnknownSchemaNodes());
-        assertNull(instanceIdentEff.getDescription());
-        assertNull(instanceIdentEff.getReference());
+        assertFalse(instanceIdentEff.getDescription().isPresent());
+        assertFalse(instanceIdentEff.getReference().isPresent());
         assertNull(instanceIdentEff.getUnits());
-        assertEquals("CURRENT", instanceIdentEff.getStatus().toString());
+        assertEquals(Status.CURRENT, instanceIdentEff.getStatus());
         assertNotNull(instanceIdentEff.hashCode());
         assertFalse(instanceIdentEff.equals(null));
         assertFalse(instanceIdentEff.equals("test"));
@@ -306,11 +307,11 @@ public class EffectiveStatementTypeTest {
         assertNull(leafrefEff.getDefaultValue());
         assertNotNull(leafrefEff.toString());
         assertEquals("leafref", leafrefEff.getQName().getLocalName());
-        assertEquals("CURRENT", leafrefEff.getStatus().toString());
+        assertEquals(Status.CURRENT, leafrefEff.getStatus());
         assertNotNull(leafrefEff.getUnknownSchemaNodes());
         assertEquals("leafref", leafrefEff.getPath().getLastComponent().getLocalName());
-        assertNull(leafrefEff.getDescription());
-        assertNull(leafrefEff.getReference());
+        assertFalse(leafrefEff.getDescription().isPresent());
+        assertFalse(leafrefEff.getReference().isPresent());
         assertNotNull(leafrefEff.hashCode());
         assertFalse(leafrefEff.equals(null));
         assertFalse(leafrefEff.equals("test"));
@@ -383,8 +384,8 @@ public class EffectiveStatementTypeTest {
         assertNull(unionEff.getBaseType());
         assertNull(unionEff.getUnits());
         assertNull(unionEff.getDefaultValue());
-        assertNull(unionEff.getDescription());
-        assertNull(unionEff.getReference());
+        assertFalse(unionEff.getDescription().isPresent());
+        assertFalse(unionEff.getReference().isPresent());
         assertNotNull(unionEff.toString());
         assertNotNull(unionEff.hashCode());
         assertFalse(unionEff.equals(null));
@@ -405,8 +406,8 @@ public class EffectiveStatementTypeTest {
         final Range<Integer> span = lengthConstraint.getAllowedRanges().span();
         assertEquals(1, span.lowerEndpoint().intValue());
         assertEquals(255, span.upperEndpoint().intValue());
-        assertNull(lengthConstraint.getReference());
-        assertNull(lengthConstraint.getDescription());
+        assertFalse(lengthConstraint.getReference().isPresent());
+        assertFalse(lengthConstraint.getDescription().isPresent());
         assertFalse(lengthConstraint.getErrorMessage().isPresent());
         assertFalse(lengthConstraint.getErrorAppTag().isPresent());
         assertNotNull(lengthConstraint.toString());
@@ -438,8 +439,8 @@ public class EffectiveStatementTypeTest {
                 ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0);
 
         assertEquals("^[0-9a-fA-F]*$", patternConstraint.getRegularExpression());
-        assertNull(patternConstraint.getReference());
-        assertNull(patternConstraint.getDescription());
+        assertFalse(patternConstraint.getReference().isPresent());
+        assertFalse(patternConstraint.getDescription().isPresent());
         assertEquals(Optional.of("Supplied value does not match the regular expression ^[0-9a-fA-F]*$."),
             patternConstraint.getErrorMessage());
         assertEquals(Optional.of("invalid-regular-expression"), patternConstraint.getErrorAppTag());
@@ -460,13 +461,13 @@ public class EffectiveStatementTypeTest {
                 .getTypeDefinition();
 
         assertEquals("string", stringEff.getQName().getLocalName());
-        assertEquals("CURRENT", stringEff.getStatus().toString());
+        assertEquals(Status.CURRENT, stringEff.getStatus());
         assertNull(stringEff.getUnits());
         assertNull(stringEff.getDefaultValue());
         assertNotNull(stringEff.getUnknownSchemaNodes());
         assertNull(stringEff.getBaseType());
-        assertNull(stringEff.getDescription());
-        assertNull(stringEff.getReference());
+        assertFalse(stringEff.getDescription().isPresent());
+        assertFalse(stringEff.getReference().isPresent());
         assertNotNull(stringEff.toString());
         assertNotNull(stringEff.hashCode());
         assertFalse(stringEff.equals(null));
index d5e28fd54a6fe3e6d8cd90562d0513bad4ee526f..ce2a075568b1d0156c570cfc869fee33843b2c97 100644 (file)
@@ -11,10 +11,10 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -88,8 +88,8 @@ public class EffectiveUsesRefineAndConstraintsTest {
         assertNotNull(containerInContainerNode);
 
         ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode;
-        assertNull(containerSchemaNode.getReference());
-        assertNull(containerSchemaNode.getDescription());
+        assertFalse(containerSchemaNode.getReference().isPresent());
+        assertFalse(containerSchemaNode.getDescription().isPresent());
         assertTrue(containerSchemaNode.isConfiguration());
         assertFalse(containerSchemaNode.isPresenceContainer());
 
@@ -113,8 +113,8 @@ public class EffectiveUsesRefineAndConstraintsTest {
         assertNotNull(listInContainerNode);
 
         ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode;
-        assertEquals("original reference", listSchemaNode.getReference());
-        assertEquals("original description", listSchemaNode.getDescription());
+        assertEquals(Optional.of("original reference"), listSchemaNode.getReference());
+        assertEquals(Optional.of("original description"), listSchemaNode.getDescription());
         assertFalse(listSchemaNode.isConfiguration());
 
         ConstraintDefinition listConstraints = listSchemaNode.getConstraints();
@@ -128,8 +128,8 @@ public class EffectiveUsesRefineAndConstraintsTest {
         assertNotNull(containerInContainerNode);
 
         ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) containerInContainerNode;
-        assertEquals("new reference", containerSchemaNode.getReference());
-        assertEquals("new description", containerSchemaNode.getDescription());
+        assertEquals(Optional.of("new reference"), containerSchemaNode.getReference());
+        assertEquals(Optional.of("new description"), containerSchemaNode.getDescription());
         assertTrue(containerSchemaNode.isConfiguration());
         assertTrue(containerSchemaNode.isPresenceContainer());
 
@@ -153,8 +153,8 @@ public class EffectiveUsesRefineAndConstraintsTest {
         assertNotNull(listInContainerNode);
 
         ListSchemaNode listSchemaNode = (ListSchemaNode) listInContainerNode;
-        assertEquals("new reference", listSchemaNode.getReference());
-        assertEquals("new description", listSchemaNode.getDescription());
+        assertEquals(Optional.of("new reference"), listSchemaNode.getReference());
+        assertEquals(Optional.of("new description"), listSchemaNode.getDescription());
         assertTrue(listSchemaNode.isConfiguration());
 
         ConstraintDefinition listConstraints = listSchemaNode.getConstraints();
index c3b638a4920a6eaa6aa48f37e6e52c340e3638ce..0dc25d73f0788f025fe231b21c05ad5ea09e2fe6 100644 (file)
@@ -19,6 +19,7 @@ import java.text.ParseException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -98,8 +99,8 @@ public class GroupingTest {
 
         // leaf address
         assertNotNull(refineLeaf);
-        assertEquals("IP address of target node", refineLeaf.getDescription());
-        assertEquals("address reference added by refine", refineLeaf.getReference());
+        assertEquals(Optional.of("IP address of target node"), refineLeaf.getDescription());
+        assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
         assertFalse(refineLeaf.isConfiguration());
         assertFalse(refineLeaf.getConstraints().isMandatory());
         final Set<MustDefinition> leafMustConstraints = refineLeaf.getConstraints().getMustConstraints();
@@ -112,21 +113,21 @@ public class GroupingTest {
         assertNotNull(refineContainer);
         final Set<MustDefinition> mustConstraints = refineContainer.getConstraints().getMustConstraints();
         assertTrue(mustConstraints.isEmpty());
-        assertEquals("description of port defined by refine", refineContainer.getDescription());
-        assertEquals("port reference added by refine", refineContainer.getReference());
+        assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription());
+        assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference());
         assertFalse(refineContainer.isConfiguration());
         assertTrue(refineContainer.isPresenceContainer());
 
         // list addresses
-        assertEquals("description of addresses defined by refine", refineList.getDescription());
-        assertEquals("addresses reference added by refine", refineList.getReference());
+        assertEquals(Optional.of("description of addresses defined by refine"), refineList.getDescription());
+        assertEquals(Optional.of("addresses reference added by refine"), refineList.getReference());
         assertFalse(refineList.isConfiguration());
         assertEquals(2, (int) refineList.getConstraints().getMinElements());
         assertNull(refineList.getConstraints().getMaxElements());
 
         // leaf id
         assertNotNull(refineInnerLeaf);
-        assertEquals("id of address", refineInnerLeaf.getDescription());
+        assertEquals(Optional.of("id of address"), refineInnerLeaf.getDescription());
     }
 
     @Test
@@ -191,8 +192,8 @@ public class GroupingTest {
                 foo.getQNameModule(), "address"));
         assertNotNull(address_u);
         assertEquals("1.2.3.4", address_u.getDefault());
-        assertEquals("IP address of target node", address_u.getDescription());
-        assertEquals("address reference added by refine", address_u.getReference());
+        assertEquals(Optional.of("IP address of target node"), address_u.getDescription());
+        assertEquals(Optional.of("address reference added by refine"), address_u.getReference());
         assertFalse(address_u.isConfiguration());
         assertTrue(address_u.isAddedByUses());
         assertFalse(address_u.getConstraints().isMandatory());
@@ -202,8 +203,8 @@ public class GroupingTest {
         assertNotNull(address_g);
         assertFalse(address_g.isAddedByUses());
         assertNull(address_g.getDefault());
-        assertEquals("Target IP address", address_g.getDescription());
-        assertNull(address_g.getReference());
+        assertEquals(Optional.of("Target IP address"), address_g.getDescription());
+        assertFalse(address_g.getReference().isPresent());
         assertTrue(address_g.isConfiguration());
         assertFalse(address_u.equals(address_g));
         assertTrue(address_g.getConstraints().isMandatory());
@@ -312,8 +313,8 @@ public class GroupingTest {
                 "address"));
         assertNotNull(address_u);
         assertNull(address_u.getDefault());
-        assertEquals("Target IP address", address_u.getDescription());
-        assertNull(address_u.getReference());
+        assertEquals(Optional.of("Target IP address"), address_u.getDescription());
+        assertFalse(address_u.getReference().isPresent());
         assertTrue(address_u.isConfiguration());
         assertTrue(address_u.isAddedByUses());
 
@@ -322,8 +323,8 @@ public class GroupingTest {
         assertNotNull(address_g);
         assertFalse(address_g.isAddedByUses());
         assertNull(address_g.getDefault());
-        assertEquals("Target IP address", address_g.getDescription());
-        assertNull(address_g.getReference());
+        assertEquals(Optional.of("Target IP address"), address_g.getDescription());
+        assertFalse(address_g.getReference().isPresent());
         assertTrue(address_g.isConfiguration());
         assertFalse(address_u.equals(address_g));
         assertEquals(address_g, SchemaNodeUtils.getRootOriginalIfPossible(address_u));
@@ -380,7 +381,7 @@ public class GroupingTest {
         final Set<AugmentationSchemaNode> usesAugments = un.getAugmentations();
         assertEquals(1, usesAugments.size());
         final AugmentationSchemaNode augment = usesAugments.iterator().next();
-        assertEquals("inner augment", augment.getDescription());
+        assertEquals(Optional.of("inner augment"), augment.getDescription());
         final Collection<DataSchemaNode> children = augment.getChildNodes();
         assertEquals(1, children.size());
         final DataSchemaNode leaf = children.iterator().next();
index 2a0cb193ab2d146cbc6c3fd4d4630d936ed185b7..444ad5684835aeec2ab0b8ea5f8f356e8fa6880f 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
@@ -19,6 +18,7 @@ import com.google.common.collect.Iterables;
 import com.google.common.collect.Range;
 import java.net.URI;
 import java.util.List;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -67,8 +67,8 @@ public class TypesResolutionTest {
         assertEquals(14, typedefs.size());
 
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
-        assertTrue(type.getDescription().contains("This value represents the version of the IP protocol."));
-        assertTrue(type.getReference().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"));
+        assertTrue(type.getDescription().get().contains("This value represents the version of the IP protocol."));
+        assertTrue(type.getReference().get().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"));
 
         EnumTypeDefinition enumType = (EnumTypeDefinition) type.getBaseType();
         List<EnumPair> values = enumType.getValues();
@@ -77,17 +77,18 @@ public class TypesResolutionTest {
         EnumPair value0 = values.get(0);
         assertEquals("unknown", value0.getName());
         assertEquals(0, value0.getValue());
-        assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription());
+        assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."),
+            value0.getDescription());
 
         EnumPair value1 = values.get(1);
         assertEquals("ipv4", value1.getName());
         assertEquals(1, value1.getValue());
-        assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription());
+        assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription());
 
         EnumPair value2 = values.get(2);
         assertEquals("ipv6", value2.getName());
         assertEquals(2, value2.getValue());
-        assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription());
+        assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription());
     }
 
     @Test
@@ -103,22 +104,23 @@ public class TypesResolutionTest {
         EnumPair value0 = values.get(0);
         assertEquals("unknown", value0.getName());
         assertEquals(0, value0.getValue());
-        assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription());
+        assertEquals(Optional.of("An unknown or unspecified version of the Internet protocol."),
+            value0.getDescription());
 
         EnumPair value1 = values.get(1);
         assertEquals("ipv4", value1.getName());
         assertEquals(19, value1.getValue());
-        assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription());
+        assertEquals(Optional.of("The IPv4 protocol as defined in RFC 791."), value1.getDescription());
 
         EnumPair value2 = values.get(2);
         assertEquals("ipv6", value2.getName());
         assertEquals(7, value2.getValue());
-        assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription());
+        assertEquals(Optional.of("The IPv6 protocol as defined in RFC 2460."), value2.getDescription());
 
         EnumPair value3 = values.get(3);
         assertEquals("default", value3.getName());
         assertEquals(20, value3.getValue());
-        assertEquals("default ip", value3.getDescription());
+        assertEquals(Optional.of("default ip"), value3.getDescription());
     }
 
     @Test
@@ -277,8 +279,8 @@ public class TypesResolutionTest {
         TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "iana-timezone");
 
         String expectedDesc = "A timezone location as defined by the IANA timezone";
-        assertTrue(testedType.getDescription().contains(expectedDesc));
-        assertNull(testedType.getReference());
+        assertTrue(testedType.getDescription().get().contains(expectedDesc));
+        assertFalse(testedType.getReference().isPresent());
         assertEquals(Status.CURRENT, testedType.getStatus());
 
         QName testedTypeQName = testedType.getQName();
@@ -293,12 +295,12 @@ public class TypesResolutionTest {
         EnumPair enum168 = values.get(168);
         assertEquals("America/Danmarkshavn", enum168.getName());
         assertEquals(168, enum168.getValue());
-        assertEquals("east coast, north of Scoresbysund", enum168.getDescription());
+        assertEquals(Optional.of("east coast, north of Scoresbysund"), enum168.getDescription());
 
         EnumPair enum374 = values.get(374);
         assertEquals("America/Indiana/Winamac", enum374.getName());
         assertEquals(374, enum374.getValue());
-        assertEquals("Eastern Time - Indiana - Pulaski County", enum374.getDescription());
+        assertEquals(Optional.of("Eastern Time - Indiana - Pulaski County"), enum374.getDescription());
     }
 
     @Test
index 25140285ebd01a48504647498f65fc9947e1770a..4ea6c6d2bd8e57e1510eac7f7b0826302c5d5b09 100644 (file)
@@ -64,8 +64,8 @@ public class YangParserSimpleTest {
 
         // test SchemaNode args
         assertEquals(QName.create(SN, "data"), data.getQName());
-        assertEquals("anyxml desc", data.getDescription());
-        assertEquals("data ref", data.getReference());
+        assertEquals(Optional.of("anyxml desc"), data.getDescription());
+        assertEquals(Optional.of("data ref"), data.getReference());
         assertEquals(Status.OBSOLETE, data.getStatus());
         assertEquals(0, data.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
@@ -89,8 +89,8 @@ public class YangParserSimpleTest {
                 found2 = true;
                 assertEquals(Optional.of("An atm MTU must be  64 .. 17966"), must.getErrorMessage());
                 assertEquals(Optional.of("anyxml data error-app-tag"), must.getErrorAppTag());
-                assertEquals("an error occured in data", must.getDescription());
-                assertEquals("data must ref", must.getReference());
+                assertEquals(Optional.of("an error occured in data"), must.getDescription());
+                assertEquals(Optional.of("data must ref"), must.getReference());
             }
         }
         assertTrue(found1);
@@ -108,8 +108,8 @@ public class YangParserSimpleTest {
         // test SchemaNode args
         assertEquals(SN_NODES, nodes.getQName());
         assertEquals(SN_NODES_PATH, nodes.getPath());
-        assertEquals("nodes collection", nodes.getDescription());
-        assertEquals("nodes ref", nodes.getReference());
+        assertEquals(Optional.of("nodes collection"), nodes.getDescription());
+        assertEquals(Optional.of("nodes ref"), nodes.getReference());
         assertEquals(Status.CURRENT, nodes.getStatus());
         assertEquals(0, nodes.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
@@ -136,8 +136,8 @@ public class YangParserSimpleTest {
                 found2 = true;
                 assertFalse(must.getErrorMessage().isPresent());
                 assertFalse(must.getErrorAppTag().isPresent());
-                assertNull(must.getDescription());
-                assertNull(must.getReference());
+                assertFalse(must.getDescription().isPresent());
+                assertFalse(must.getReference().isPresent());
             }
         }
         assertTrue(found1);
@@ -155,8 +155,8 @@ public class YangParserSimpleTest {
         final QName typedefQName = QName.create(SN, "nodes-type");
         assertEquals(typedefQName, nodesType.getQName());
         assertEquals(SN_NODES_PATH.createChild(QName.create(SN, "nodes-type")), nodesType.getPath());
-        assertNull(nodesType.getDescription());
-        assertNull(nodesType.getReference());
+        assertFalse(nodesType.getDescription().isPresent());
+        assertFalse(nodesType.getReference().isPresent());
         assertEquals(Status.CURRENT, nodesType.getStatus());
         assertEquals(0, nodesType.getUnknownSchemaNodes().size());
 
index 42bc8ed3be0bf0e82dbc41b21b5cbe23d0d5f743..85439e2f36e60d8456ee1e0566d147a6ba3b3403 100644 (file)
@@ -111,7 +111,7 @@ public class YangParserTest {
         assertEquals(Optional.of("opendaylight"), foo.getOrganization());
         assertEquals(Optional.of("http://www.opendaylight.org/"), foo.getContact());
         assertEquals(Revision.ofNullable("2013-02-27"), foo.getRevision());
-        assertNull(foo.getReference());
+        assertFalse(foo.getReference().isPresent());
     }
 
     @Test
@@ -126,8 +126,8 @@ public class YangParserTest {
 
         final SchemaPath expectedPath = TestUtils.createPath(true, BAR, "interfaces", "ifEntry");
         assertEquals(expectedPath, ifEntry.getPath());
-        assertNull(ifEntry.getDescription());
-        assertNull(ifEntry.getReference());
+        assertFalse(ifEntry.getDescription().isPresent());
+        assertFalse(ifEntry.getReference().isPresent());
         assertEquals(Status.CURRENT, ifEntry.getStatus());
         assertEquals(0, ifEntry.getUnknownSchemaNodes().size());
         // test DataSchemaNode args
@@ -538,7 +538,7 @@ public class YangParserTest {
         final Set<Deviation> deviations = foo.getDeviations();
         assertEquals(1, deviations.size());
         final Deviation dev = deviations.iterator().next();
-        assertEquals("system/user ref", dev.getReference());
+        assertEquals(Optional.of("system/user ref"), dev.getReference());
 
         final SchemaPath expectedPath = SchemaPath.create(true,
             QName.create(BAR, "interfaces"),
@@ -571,7 +571,8 @@ public class YangParserTest {
         assertEquals(1, extensions.size());
         final ExtensionDefinition extension = extensions.get(0);
         assertEquals("name", extension.getArgument());
-        assertEquals("Takes as argument a name string. Makes the code generator use the given name in the #define.",
+        assertEquals(
+            Optional.of("Takes as argument a name string. Makes the code generator use the given name in the #define."),
                 extension.getDescription());
         assertTrue(extension.isYinElement());
     }
@@ -586,8 +587,8 @@ public class YangParserTest {
         assertEquals(QName.create(BAZ, "event"), notification.getQName());
         final SchemaPath expectedPath = SchemaPath.create(true,  QName.create(BAZ, "event"));
         assertEquals(expectedPath, notification.getPath());
-        assertNull(notification.getDescription());
-        assertNull(notification.getReference());
+        assertFalse(notification.getDescription().isPresent());
+        assertFalse(notification.getReference().isPresent());
         assertEquals(Status.CURRENT, notification.getStatus());
         assertEquals(0, notification.getUnknownSchemaNodes().size());
         // test DataNodeContainer args
@@ -610,8 +611,8 @@ public class YangParserTest {
         assertEquals(1, rpcs.size());
 
         final RpcDefinition rpc = rpcs.iterator().next();
-        assertEquals("Retrieve all or part of a specified configuration.", rpc.getDescription());
-        assertEquals("RFC 6241, Section 7.1", rpc.getReference());
+        assertEquals(Optional.of("Retrieve all or part of a specified configuration."), rpc.getDescription());
+        assertEquals(Optional.of("RFC 6241, Section 7.1"), rpc.getReference());
     }
 
     @Test
index 0bb6d751753e5c742d1cd6eb5a9697966fe4f5d2..af378b1ee4c1f2b6ec6b863d5f7c2ecf4a5808b7 100644 (file)
@@ -18,6 +18,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -256,8 +257,8 @@ public class YangParserWithContextTest {
         // leaf address
         assertNotNull(refineLeaf);
         assertEquals("address", refineLeaf.getQName().getLocalName());
-        assertEquals("description of address defined by refine", refineLeaf.getDescription());
-        assertEquals("address reference added by refine", refineLeaf.getReference());
+        assertEquals(Optional.of("description of address defined by refine"), refineLeaf.getDescription());
+        assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
         assertFalse(refineLeaf.isConfiguration());
         assertTrue(refineLeaf.getConstraints().isMandatory());
         final Set<MustDefinition> leafMustConstraints = refineLeaf.getConstraints().getMustConstraints();
@@ -269,15 +270,15 @@ public class YangParserWithContextTest {
         assertNotNull(refineContainer);
         final Set<MustDefinition> mustConstraints = refineContainer.getConstraints().getMustConstraints();
         assertTrue(mustConstraints.isEmpty());
-        assertEquals("description of port defined by refine", refineContainer.getDescription());
-        assertEquals("port reference added by refine", refineContainer.getReference());
+        assertEquals(Optional.of("description of port defined by refine"), refineContainer.getDescription());
+        assertEquals(Optional.of("port reference added by refine"), refineContainer.getReference());
         assertFalse(refineContainer.isConfiguration());
         assertTrue(refineContainer.isPresenceContainer());
 
         // list addresses
         assertNotNull(refineList);
-        assertEquals("description of addresses defined by refine", refineList.getDescription());
-        assertEquals("addresses reference added by refine", refineList.getReference());
+        assertEquals(Optional.of("description of addresses defined by refine"), refineList.getDescription());
+        assertEquals(Optional.of("addresses reference added by refine"), refineList.getReference());
         assertFalse(refineList.isConfiguration());
         assertEquals(2, (int) refineList.getConstraints().getMinElements());
         assertEquals(12, (int) refineList.getConstraints().getMaxElements());
@@ -392,7 +393,7 @@ public class YangParserWithContextTest {
         assertEquals(1, deviations.size());
         final Deviation dev = deviations.iterator().next();
 
-        assertEquals("system/user ref", dev.getReference());
+        assertEquals(Optional.of("system/user ref"), dev.getReference());
 
         final URI expectedNS = URI.create("urn:opendaylight.bar");
         final Revision expectedRev = Revision.of("2013-07-03");
index ec8879ffb22ea611c108826f61975673b42f012f..60a34dbed0c48a0898485511f5c52857d1d4db48 100644 (file)
@@ -15,6 +15,7 @@ import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
@@ -46,14 +47,14 @@ public class YinFileExtensionStmtTest {
         ExtensionDefinition extension = extIterator.next();
         assertEquals("name", extension.getArgument());
         assertEquals("java-class", extension.getQName().getLocalName());
-        assertEquals("YANG language extension carrying the fully-qualified name of\n"
+        assertEquals(Optional.of("YANG language extension carrying the fully-qualified name of\n"
                 + "a Java class. Code generation tools use the provided reference\n"
-                + "to tie a specific construct to its Java representation.", extension.getDescription());
+                + "to tie a specific construct to its Java representation."), extension.getDescription());
 
         extension = extIterator.next();
         assertEquals("name", extension.getArgument());
         assertEquals("required-identity", extension.getQName().getLocalName());
-        assertEquals("YANG language extension which indicates that a particular\n"
+        assertEquals(Optional.of("YANG language extension which indicates that a particular\n"
                 + "leafref, which points to a identityref, should additionally\n"
                 + "require the target node is actually set to a descendant to\n"
                 + "of a particular identity.\n"
@@ -65,32 +66,31 @@ public class YinFileExtensionStmtTest {
                 + "This extension takes one argument, name, which MUST be the name\n"
                 + "of an identity. Furthermore, that identity MUST be based,\n"
                 + "directly or indirectly, on the identity, which is referenced by\n"
-                + "the leaf reference, which is annotated with this extension.", extension.getDescription());
+                + "the leaf reference, which is annotated with this extension."), extension.getDescription());
 
         extension = extIterator.next();
         assertNull(extension.getArgument());
         assertEquals("inner-state-bean", extension.getQName().getLocalName());
-        assertEquals("YANG language extension which indicates that a particular\n"
+        assertEquals(Optional.of("YANG language extension which indicates that a particular\n"
                 + "list located under module's state should be treated as a list\n"
-                + "of child state beans instead of just an ordinary list attribute", extension.getDescription());
+                + "of child state beans instead of just an ordinary list attribute"), extension.getDescription());
 
         extension = extIterator.next();
         assertEquals("name", extension.getArgument());
         assertEquals("provided-service", extension.getQName().getLocalName());
-        assertEquals("YANG language extension which indicates that a particular\n"
+        assertEquals(Optional.of("YANG language extension which indicates that a particular\n"
                 + "module provides certain service. This extension can be placed\n"
                 + "on identities that are based on module-type. Zero or more services\n"
                 + "can be provided.\n"
                 + "This extension takes one argument - name - which MUST be the name\n"
                 + "of an identity. Furthermore, this identity MUST be based on\n"
-                + "service-type.", extension.getDescription());
+                + "service-type."), extension.getDescription());
 
         extension = extIterator.next();
         assertEquals("java-prefix", extension.getArgument());
         assertEquals("java-name-prefix", extension.getQName().getLocalName());
-        assertEquals("YANG language extension carrying java simple class name prefix\n"
+        assertEquals(Optional.of("YANG language extension carrying java simple class name prefix\n"
                 + "that will be taken into account when generating java code from\n"
-                + "identities that are based on module-type.", extension.getDescription());
+                + "identities that are based on module-type."), extension.getDescription());
     }
-
 }
index c16104fd93da93ba218f67844c3efb2e04a686a5..fe6ed76155c6fac7c0cb68d853ccc66aa2669e5d 100644 (file)
@@ -15,6 +15,7 @@ import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -49,12 +50,12 @@ public class YinFileGroupingStmtTest {
         final Iterator<GroupingDefinition> groupingsIterator = groupings.iterator();
         final GroupingDefinition grouping = groupingsIterator.next();
         assertEquals("service-ref", grouping.getQName().getLocalName());
-        assertEquals("Type of references to a particular service instance. This type\n"
+        assertEquals(Optional.of("Type of references to a particular service instance. This type\n"
                 + "can be used when defining module configuration to refer to a\n"
                 + "particular service instance. Containers using this grouping\n"
                 + "should not define anything else. The run-time implementation\n"
                 + "is expected to inject a reference to the service as the value\n"
-                + "of the container.", grouping.getDescription());
+                + "of the container."), grouping.getDescription());
 
         final Collection<DataSchemaNode> children = grouping.getChildNodes();
         assertEquals(2, children.size());
index b84ae68106c65cd15c26fcef7341f0ffe0cf366e..a642b0cdb3ca1ec9b11b02a54fa27938d09690ba 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -51,7 +52,7 @@ public class YinFileLeafListStmtTest {
                 testModule.getQNameModule(), "capability"));
         assertNotNull(leafList);
         assertEquals("uri", leafList.getType().getQName().getLocalName());
-        assertEquals("List of NETCONF capabilities supported by the server.", leafList.getDescription());
+        assertEquals(Optional.of("List of NETCONF capabilities supported by the server."), leafList.getDescription());
         assertFalse(leafList.isUserOrdered());
     }
 }
index 15b750a49ed5fc47f001089b04f82853f3a20613..135f3551db757b9804b76e5833bcacaec5deac69 100644 (file)
@@ -16,6 +16,7 @@ import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -64,7 +65,7 @@ public class YinFileListStmtTest {
         final Iterator<DataSchemaNode> childrenIterator = children.iterator();
         LeafSchemaNode leaf = (LeafSchemaNode) childrenIterator.next();
         assertEquals("name", leaf.getQName().getLocalName());
-        assertEquals("Unique module instance name", leaf.getDescription());
+        assertEquals(Optional.of("Unique module instance name"), leaf.getDescription());
         assertEquals(BaseTypes.stringType(), leaf.getType());
         assertTrue(leaf.getConstraints().isMandatory());
 
index 7bc5c38c0580bd6b975b18262590726120a56a3b..fdb0467cb73d74f1905b6d1ff8802ffbb8bc6ddd 100644 (file)
@@ -51,13 +51,13 @@ public class YinFileMetaStmtsTest {
                 + "\n"
                 + "Editor:   Martin Bjorklund\n"
                 + "        <mailto:mbj@tail-f.com>"), testModule.getContact());
-        assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n"
+        assertEquals(Optional.of("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n"
                 + "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights "
                 + "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" +  "without "
                 + "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the "
                 + "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions "
                 + "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version "
-                + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.",
+                + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices."),
                 testModule.getDescription());
     }
 }
index e405e3374ef96712ae8be5693899a36d42a53815..97248a8dc371553c9b4fa7a32da7e95e3ae40ed1 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull;
 
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,7 +43,7 @@ public class YinFileRpcStmtTest {
 
         RpcDefinition rpc = rpcs.iterator().next();
         assertEquals("get-schema", rpc.getQName().getLocalName());
-        assertEquals("This operation is used to retrieve a schema from the\n"
+        assertEquals(Optional.of("This operation is used to retrieve a schema from the\n"
                 + "NETCONF server.\n"
                 + "\n"
                 + "Positive Response:\n"
@@ -54,7 +55,7 @@ public class YinFileRpcStmtTest {
                 + "\n"
                 + "If more than one schema matches the requested parameters, the\n"
                 + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
-                + "'data-not-unique'.", rpc.getDescription());
+                + "'data-not-unique'."), rpc.getDescription());
 
         ContainerSchemaNode input = rpc.getInput();
         assertNotNull(input);
index e6be6abdd94e19323e9e5c059148f9266ddd71e8..d6b1590749d1dba089f83df1f4a682e80094ad39 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Set;
 import org.junit.Before;
 import org.junit.Test;
@@ -44,7 +45,7 @@ public class YinFileTypeDefStmtTest {
         Iterator<TypeDefinition<?>> typeDefIterator = typeDefs.iterator();
         TypeDefinition<?> typeDef = typeDefIterator.next();
         assertEquals("service-type-ref", typeDef.getQName().getLocalName());
-        assertEquals("Internal type of references to service type identity.", typeDef.getDescription());
+        assertEquals(Optional.of("Internal type of references to service type identity."), typeDef.getDescription());
         assertEquals("identityref", typeDef.getBaseType().getQName().getLocalName());
     }
 }