X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FReactorStmtCtx.java;h=5e9f5983e2f2e697cb465a7798414a659adc17f4;hb=0735f709c996762a2ac65338459c465bffc4dbcf;hp=dce395ab28414d3d89bd126160846aeea22af010;hpb=e2364400285404a11c77e509b52f86e0c62c1327;p=yangtools.git
diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java
index dce395ab28..5e9f5983e2 100644
--- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java
+++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java
@@ -154,8 +154,8 @@ abstract class ReactorStmtCtx, E extends Effec
// SchemaPath cache for use with SubstatementContext and InferredStatementContext. This hurts RootStatementContext
// a bit in terms of size -- but those are only a few and SchemaPath is on its way out anyway.
- @Deprecated
- private volatile SchemaPath schemaPath;
+ // FIXME: this should become 'QName'
+ private SchemaPath schemaPath;
ReactorStmtCtx() {
// Empty on purpose
@@ -532,39 +532,43 @@ abstract class ReactorStmtCtx, E extends Effec
//
//
- // Common SchemaPath cache. All of this is bound to be removed once YANGTOOLS-1066 is done.
+ // Various functionality from AbstractTypeStatementSupport. This used to work on top of SchemaPath, now it still
+ // lives here. Ultimate future is either proper graduation or (more likely) move to AbstractTypeStatementSupport.
//
//
@Override
- public @NonNull QName argumentAsTypeQName() {
+ public final QName argumentAsTypeQName() {
final Object argument = argument();
verify(argument instanceof String, "Unexpected argument %s", argument);
return interpretAsQName((String) argument);
}
+ @Override
+ public final QNameModule effectiveNamespace() {
+ // FIXME: there has to be a better way to do this
+ return getSchemaPath().getLastComponent().getModule();
+ }
+
+ //
+ //
+ // Common SchemaPath cache. All of this is bound to be removed once YANGTOOLS-1066 is done.
+ //
+ //
+
// Exists only to support {SubstatementContext,InferredStatementContext}.schemaPath()
@Deprecated
- final @NonNull Optional substatementGetSchemaPath() {
- SchemaPath local = schemaPath;
- if (local == null) {
- synchronized (this) {
- local = schemaPath;
- if (local == null) {
- schemaPath = local = createSchemaPath((StatementContextBase, ?, ?>) coerceParentContext());
- }
- }
+ final @Nullable SchemaPath substatementGetSchemaPath() {
+ if (schemaPath == null) {
+ schemaPath = createSchemaPath((StatementContextBase, ?, ?>) coerceParentContext());
}
-
- return Optional.ofNullable(local);
+ return schemaPath;
}
+ // FIXME: 7.0.0: this method's logic needs to be moved to the respective StatementSupport classes
@Deprecated
private SchemaPath createSchemaPath(final StatementContextBase, ?, ?> parent) {
- final Optional maybeParentPath = parent.schemaPath();
- verify(maybeParentPath.isPresent(), "Parent %s does not have a SchemaPath", parent);
- final SchemaPath parentPath = maybeParentPath.get();
-
+ final SchemaPath parentPath = parent.getSchemaPath();
if (StmtContextUtils.isUnknownStatement(this)) {
return parentPath.createChild(publicDefinition().getStatementName());
}
@@ -572,7 +576,7 @@ abstract class ReactorStmtCtx, E extends Effec
if (argument instanceof QName) {
final QName qname = (QName) argument;
if (producesDeclared(UsesStatement.class)) {
- return maybeParentPath.orElse(null);
+ return parentPath;
}
return parentPath.createChild(qname);
@@ -587,8 +591,8 @@ abstract class ReactorStmtCtx, E extends Effec
return parentPath.createChild(((SchemaNodeIdentifier) argument).getNodeIdentifiers());
}
- // FIXME: this does not look right
- return maybeParentPath.orElse(null);
+ // FIXME: this does not look right, investigate more?
+ return parentPath;
}
private @NonNull QName interpretAsQName(final String argument) {