// very low. We'd have to know the yang type but, even if we did, we can't let a null value pass upstream
// so we'd have to drop the leaf which might cause other issues.
case LithiumValue.NULL_TYPE:
- return Empty.getInstance();
+ return Empty.value();
default:
return null;
case MagnesiumValue.BOOLEAN_TRUE:
return Boolean.TRUE;
case MagnesiumValue.EMPTY:
- return Empty.getInstance();
+ return Empty.value();
case MagnesiumValue.INT8:
return input.readByte();
case MagnesiumValue.INT8_0:
new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
.withChild(entry1).withChild(entry2).build())
.withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4}))
- .withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.getInstance()))
+ .withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.value()))
.withChild(Builders.orderedMapBuilder()
.withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME))
.withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME,
@Override
public Empty parseValue(final Object ctx, final String input) {
- return Empty.getInstance();
+ return Empty.value();
}
@Override
static final ContainerNode CONT1_WITH_EMPTYLEAF = Builders.containerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT_1))
- .addChild(ImmutableNodes.leafNode(EMPTY_LEAF, Empty.getInstance()))
+ .addChild(ImmutableNodes.leafNode(EMPTY_LEAF, Empty.value()))
.build();
static EffectiveModelContext schemaContext;
@Override
public Empty parseValue(final NamespaceContext ctx, final String str) {
- return Empty.getInstance();
+ return Empty.value();
}
@Override
private static final Empty INSTANCE = new Empty();
private Empty() {
-
+ // Hidden on purpose
}
+ /**
+ * Return the singleton {@link Empty} value.
+ *
+ * @return Empty value.
+ * @deprecated Use {@link #value()} instead.
+ */
+ @Deprecated(since = "7.0.10", forRemoval = true)
public static Empty getInstance() {
+ return value();
+ }
+
+ /**
+ * Return the singleton {@link Empty} value.
+ *
+ * @return Empty value.
+ */
+ public static Empty value() {
return INSTANCE;
}
@Test
public void testInstanceNotNull() {
- assertNotNull(Empty.getInstance());
+ assertNotNull(Empty.value());
}
@Test
public void testToString() {
- assertEquals("empty", Empty.getInstance().toString());
+ assertEquals("empty", Empty.value().toString());
}
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
- oos.writeObject(Empty.getInstance());
+ oos.writeObject(Empty.value());
}
final Object read;
read = ois.readObject();
}
- assertSame(Empty.getInstance(), read);
+ assertSame(Empty.value(), read);
}
}
@Override
protected Empty deserializeImpl(final String product) {
checkArgument(product.isEmpty(), "The value must be empty");
- return Empty.getInstance();
+ return Empty.value();
}
@Override
static final class LeafListEntryNormalization extends InstanceIdToSimpleNodes<NodeWithValue> {
LeafListEntryNormalization(final LeafListSchemaNode potential) {
// We are fudging a value here
- super(new NodeWithValue<>(potential.getQName(), Empty.getInstance()));
+ super(new NodeWithValue<>(potential.getQName(), Empty.value()));
}
@Override
public void testSerialize() {
EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
- assertEquals("serialize", "", codec.serialize(Empty.getInstance()));
+ assertEquals("serialize", "", codec.serialize(Empty.value()));
}
@SuppressWarnings("unchecked")
public void testDeserialize() {
EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
- assertEquals("deserialize", Empty.getInstance(), codec.deserialize(""));
+ assertEquals("deserialize", Empty.value(), codec.deserialize(""));
TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");
}
assertEquals("deserialize", 123, codec.deserialize("123"));
assertEquals("deserialize", -123, codec.deserialize("-123"));
assertEquals("deserialize", 41234567890L, codec.deserialize("41234567890"));
- assertEquals("deserialize", Empty.getInstance(), codec.deserialize(""));
+ assertEquals("deserialize", Empty.value(), codec.deserialize(""));
deserializeWithExpectedIllegalArgEx(codec, "enum3");
deserializeWithExpectedIllegalArgEx(codec, "123o");
final class LeafListEntryContextNode extends AbstractLeafNodeContext<NodeWithValue<?>, LeafListSchemaNode> {
LeafListEntryContextNode(final LeafListSchemaNode potential) {
- super(new NodeWithValue<>(potential.getQName(), Empty.getInstance()), potential);
+ super(new NodeWithValue<>(potential.getQName(), Empty.value()), potential);
}
@Override
@Override
public Object argument() {
final String raw = rawArgument();
- return raw != null ? raw : Empty.getInstance();
+ return raw != null ? raw : Empty.value();
}
}
@Override
public final Empty argument() {
- return Empty.getInstance();
+ return Empty.value();
}
@Override
// Parse and populate our argument to be picked up when we build the effecitve statement
final String argument = SourceException.throwIfNull(ctx.argument(), ctx, "yang-data requires an argument");
final QName qname = StmtContextUtils.parseIdentifier(ctx, argument);
- ctx.addToNs(YangDataArgumentNamespace.class, Empty.getInstance(), qname);
+ ctx.addToNs(YangDataArgumentNamespace.class, Empty.value(), qname);
}
@Override
}
return new YangDataEffectiveStatementImpl(stmt, substatements,
- verifyNotNull(stmt.namespaceItem(YangDataArgumentNamespace.class, Empty.getInstance())));
+ verifyNotNull(stmt.namespaceItem(YangDataArgumentNamespace.class, Empty.value())));
}
}
// Pick up the marker left by onFullDefinitionDeclared() inference action. If it is present we need to pass our
// children through target's implicit wrapping.
final StatementContextBase<?, ?, ?> implicitDef = stmt.getFromNamespace(AugmentImplicitHandlingNamespace.class,
- Empty.getInstance());
+ Empty.value());
return implicitDef == null ? substatements : Lists.transform(substatements, subCtx -> {
verify(subCtx instanceof StatementContextBase);
return implicitDef.wrapWithImplicit((StatementContextBase<?, ?, ?>) subCtx);
// We are targeting a context which is creating implicit nodes. In order to keep things consistent,
// we will need to circle back when creating effective statements.
if (augmentTargetCtx.hasImplicitParentSupport()) {
- augmentNode.addToNs(AugmentImplicitHandlingNamespace.class, Empty.getInstance(), augmentTargetCtx);
+ augmentNode.addToNs(AugmentImplicitHandlingNamespace.class, Empty.value(), augmentTargetCtx);
}
copyFromSourceToTarget((StatementContextBase<?, ?, ?>) augmentNode, augmentTargetCtx);
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
InferenceException.throwIf(substatements.isEmpty(), stmt, "Unexpected empty effective import statement");
return EffectiveStatements.createImport(stmt.declared(), substatements,
- verifyNotNull(stmt.getFromNamespace(ImportedVersionNamespace.class, Empty.getInstance())));
+ verifyNotNull(stmt.getFromNamespace(ImportedVersionNamespace.class, Empty.value())));
}
}
final SourceIdentifier importedModuleIdentifier =
stmt.getFromNamespace(ModuleCtxToSourceIdentifier.class, importedModule);
- stmt.addToNs(ImportedVersionNamespace.class, Empty.getInstance(), importedModuleIdentifier);
+ stmt.addToNs(ImportedVersionNamespace.class, Empty.value(), importedModuleIdentifier);
final QNameModule mod = InferenceException.throwIfNull(stmt.getFromNamespace(
ModuleCtxToModuleQName.class, importedModule), stmt, "Failed to find module of %s", importedModule);
ModuleCtxToSourceIdentifier.class, importedModule);
final SemVerSourceIdentifier semVerModuleIdentifier = createSemVerModuleIdentifier(
importedModuleIdentifier, importedVersion);
- stmt.addToNs(ImportedVersionNamespace.class, Empty.getInstance(), semVerModuleIdentifier);
+ stmt.addToNs(ImportedVersionNamespace.class, Empty.value(), semVerModuleIdentifier);
linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class, importedModuleIdentifier,
importedModule);
firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class), stmt,
"Prefix of the module [%s] is missing", stmt.argument());
- stmt.addToNs(QNameModuleNamespace.class, Empty.getInstance(), qNameModule);
+ stmt.addToNs(QNameModuleNamespace.class, Empty.value(), qNameModule);
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
stmt.addToNs(ModuleNameToModuleQName.class, moduleName, qNameModule);
stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
submodules.add((Submodule) submodule);
}
- final QNameModule qnameModule = verifyNotNull(stmt.namespaceItem(QNameModuleNamespace.class,
- Empty.getInstance()));
+ final QNameModule qnameModule = verifyNotNull(stmt.namespaceItem(QNameModuleNamespace.class, Empty.value()));
try {
return new ModuleEffectiveStatementImpl(stmt, substatements, submodules, qnameModule);
} catch (SubstatementIndexingException e) {
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
// Empty refine is exceedingly unlikely: let's be lazy and reuse the implementation
return new RefineEffectiveStatementImpl(stmt.declared(), substatements,
- (SchemaNode) verifyNotNull(stmt.namespaceItem(RefineTargetNamespace.class, Empty.getInstance()))
+ (SchemaNode) verifyNotNull(stmt.namespaceItem(RefineTargetNamespace.class, Empty.value()))
.buildEffective());
}
}
final BuiltinEffectiveStatement builtin = STATIC_BUILT_IN_TYPES.get(stmt.getRawArgument());
if (builtin != null) {
- stmt.addToNs(BaseTypeNamespace.class, Empty.getInstance(), builtin);
+ stmt.addToNs(BaseTypeNamespace.class, Empty.value(), builtin);
return;
}
@Override
public void apply(final InferenceContext ctx) {
// Note: do not attempt to call buildEffective() here
- stmt.addToNs(BaseTypeNamespace.class, Empty.getInstance(), typePrereq.resolve(ctx));
+ stmt.addToNs(BaseTypeNamespace.class, Empty.value(), typePrereq.resolve(ctx));
}
@Override
* @throws SourceException if the target type cannot be found
*/
private static @NonNull TypeEffectiveStatement<TypeStatement> resolveType(final Current<QName, ?> ctx) {
- final Object obj = verifyNotNull(ctx.namespaceItem(BaseTypeNamespace.class, Empty.getInstance()));
+ final Object obj = verifyNotNull(ctx.namespaceItem(BaseTypeNamespace.class, Empty.value()));
if (obj instanceof BuiltinEffectiveStatement) {
return (BuiltinEffectiveStatement) obj;
} else if (obj instanceof StmtContext) {
copyFromSourceToTarget(sourceGrpStmtCtx, targetNodeStmtCtx, usesNode);
resolveUsesNode(usesNode, targetNodeStmtCtx);
StmtContextUtils.validateIfFeatureAndWhenOnListKeys(usesNode);
- usesNode.addToNs(SourceGroupingNamespace.class, Empty.getInstance(), sourceGrpStmtCtx);
+ usesNode.addToNs(SourceGroupingNamespace.class, Empty.value(), sourceGrpStmtCtx);
}
@Override
protected UsesEffectiveStatement createEffective(final Current<QName, UsesStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
final EffectiveStatement<?, ?> source =
- verifyNotNull(stmt.getFromNamespace(SourceGroupingNamespace.class, Empty.getInstance())).buildEffective();
+ verifyNotNull(stmt.getFromNamespace(SourceGroupingNamespace.class, Empty.value())).buildEffective();
verify(source instanceof GroupingDefinition, "Unexpected source %s", source);
final GroupingDefinition sourceGrouping = (GroupingDefinition) source;
// Target is a prerequisite for the 'refine', hence if the target is not supported, the refine is not supported
// as well. Otherwise add a pointer to the target into refine's local namespace.
if (refineTargetNodeCtx.isSupportedToBuildEffective()) {
- subStmtCtx.addToNs(RefineTargetNamespace.class, Empty.getInstance(), refineTargetNodeCtx);
+ subStmtCtx.addToNs(RefineTargetNamespace.class, Empty.value(), refineTargetNodeCtx);
} else {
subStmtCtx.setIsSupportedToBuildEffective(false);
}
assertNotNull(output);
assertEquals(QName.create("urn:test:bug1412:ext:definitions", "2014-07-25", "output"),
output.statementDefinition().getStatementName());
- assertEquals(Empty.getInstance(), output.argument());
+ assertEquals(Empty.value(), output.argument());
}
}
ThirdPartyExtensionEffectiveStatementImpl(final Current<String, ThirdPartyExtensionStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
super(stmt.declared(), stmt.argument(), stmt.history(), substatements);
- valueFromNamespace = stmt.getFromNamespace(ThirdPartyNamespace.class, Empty.getInstance());
+ valueFromNamespace = stmt.getFromNamespace(ThirdPartyNamespace.class, Empty.value());
}
@Override
public void onFullDefinitionDeclared(
final Mutable<String, ThirdPartyExtensionStatement, ThirdPartyExtensionEffectiveStatement> stmt) {
super.onFullDefinitionDeclared(stmt);
- stmt.addToNs(ThirdPartyNamespace.class, Empty.getInstance(), "Third-party namespace test.");
+ stmt.addToNs(ThirdPartyNamespace.class, Empty.value(), "Third-party namespace test.");
}
@Override
@Override
public final Empty parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
InferenceException.throwIf(value != null, ctx, "Unexpected argument value %s", value);
- return Empty.getInstance();
+ return Empty.value();
}
}