Make description/reference work on Optional and fixup users.
Change-Id: I744b9c59c8c3cc160636ef8c3ff18298c66a275a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
}
@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
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;
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();
}
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();
}
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.
/**
* 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();
}
*/
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.
*
default Set<ActionDefinition> getActions() {
return ImmutableSet.of();
}
+
+ @Override
+ default Optional<String> getDescription() {
+ return Optional.empty();
+ }
+
+ @Override
+ default Optional<String> getReference() {
+ return Optional.empty();
+ }
}
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) {
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();
}
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) {
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();
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();
}
// 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")
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) {
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();
}
private void emitDecimal64Specification(final DecimalTypeDefinition typeDefinition) {
emitFranctionDigitsNode(typeDefinition.getFractionDigits());
emitRangeNodeOptional(typeDefinition.getRangeConstraints());
-
}
private void emitFranctionDigitsNode(final Integer fractionDigits) {
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();
}
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();
}
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();
}
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();
}
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) {
}
}
+ 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) {
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);
}
}
// 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);
}
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);
return SchemaPath.ROOT;
}
- @Override
- public String getDescription() {
- return null;
- }
-
- @Override
- public String getReference() {
- return null;
- }
-
@Nonnull
@Override
public Status getStatus() {
/**
* Proxy for AugmentationSchema. Child node schemas are replaced with actual schemas from parent.
- *
*/
public final class EffectiveAugmentationSchema implements AugmentationSchemaNode {
private final AugmentationSchemaNode delegate;
}
@Override
- public String getDescription() {
+ public Optional<String> getDescription() {
return delegate.getDescription();
}
@Override
- public String getReference() {
+ public Optional<String> getReference() {
return delegate.getReference();
}
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
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;
}
@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
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;
}
@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
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;
}
@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();
}
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;
}
@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
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);
}
/**
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;
}
@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
static final LengthConstraint INTEGER_SIZE_CONSTRAINTS = new LengthConstraint() {
@Override
- public String getReference() {
- return null;
+ public Optional<String> getReference() {
+ return Optional.empty();
}
@Override
}
@Override
- public String getDescription() {
- return null;
+ public Optional<String> getDescription() {
+ return Optional.empty();
}
@Override
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;
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);
}
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);
}
}
@Override
- public String getDescription() {
+ public Optional<String> getDescription() {
return meta.getDescription();
}
}
@Override
- public String getReference() {
+ public Optional<String> getReference() {
return meta.getReference();
}
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;
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());
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;
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));
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;
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"));
}
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());
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());
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());
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;
// 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());
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;
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)
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));
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;
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;
*/
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;
}
@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
}
@Override
- public String getDescription() {
+ public Optional<String> getDescription() {
return caseShorthandNode.getDescription();
}
@Override
- public String getReference() {
+ public Optional<String> getReference() {
return caseShorthandNode.getReference();
}
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;
}
@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
}
@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
@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();
}
}
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
*/
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;
}
@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);
}
}
}
@Override
- public final String getDescription() {
- return description;
+ public final Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
public final ModifierKind getModifier() {
}
@Override
- public final String getReference() {
- return reference;
+ public final Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
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);
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);
}
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);
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);
}
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
}
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());
}
}
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
@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));
}
}
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;
// 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
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;
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"));
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;
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;
}
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());
}
}
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;
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());
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;
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
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;
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) {
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;
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'");
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;
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
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;
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)) {
}
if ("bar-leaf-1".equals(targetLocalName)) {
- if ("desc".equals(deviation.getDescription())) {
+ if (Optional.of("desc").equals(deviation.getDescription())) {
deviation4 = deviation;
} else {
deviation5 = deviation;
}
if ("bar-leaf-2".equals(targetLocalName)) {
- if ("ref".equals(deviation.getReference())) {
+ if (Optional.of("ref").equals(deviation.getReference())) {
deviation6 = deviation;
} else {
deviation7 = deviation;
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());
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();
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;
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) {
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());
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;
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
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());
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"));
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());
}
// 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());
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());
}
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());
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());
}
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
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"));
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"));
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));
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());
((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());
.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));
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;
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());
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();
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());
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();
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;
// 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();
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
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());
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());
"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());
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));
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();
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;
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;
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();
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
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
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();
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
// 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
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);
// 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
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);
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());
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
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
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"),
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());
}
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
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
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;
// 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();
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());
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");
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;
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"
+ "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());
}
-
}
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;
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());
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;
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());
}
}
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;
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());
+ "\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());
}
}
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.Optional;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
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"
+ "\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);
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;
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());
}
}