-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.yangtools.yang.data.impl.leafref;
import com.google.common.collect.ImmutableMap;
-import java.io.IOException;
import java.util.Map;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-final public class LeafRefContext {
+// FIXME: 3.0.0 hide this class
+public final class LeafRefContext {
private final QName currentNodeQName;
private final SchemaPath currentNodePath;
private final Module module;
private final LeafRefPath leafRefTargetPath;
- private final LeafRefPath absoluteLeafRefTargetPath ;
+ private final LeafRefPath absoluteLeafRefTargetPath;
private final String leafRefTargetPathString;
private final boolean isReferencedBy;
private final Map<QName, LeafRefContext> referencedByChilds;
private final Map<QName, LeafRefContext> referencedByLeafRefCtx;
+ // FIXME: this looks like it's related to absoluteLeafRefTargetPath, but the original use in LeafRefValidation
+ // fast path did not make it clear. Analyze the relationship between this field and
+ // absoluteLeafRefTargetPath.
+ private volatile LeafRefPath leafRefNodePath = null;
+
LeafRefContext(final LeafRefContextBuilder leafRefContextBuilder) {
this.currentNodeQName = leafRefContextBuilder.getCurrentNodeQName();
this.currentNodePath = leafRefContextBuilder.getCurrentNodePath();
public static LeafRefContext create(final SchemaContext ctx) {
try {
return new LeafRefContextTreeBuilder(ctx).buildLeafRefContextTree();
- } catch (IOException | LeafRefYangSyntaxErrorException e) {
- throw new RuntimeException(e);
+ } catch (LeafRefYangSyntaxErrorException e) {
+ throw new IllegalArgumentException(e);
}
}
return referencedByLeafRefCtx;
}
+ LeafRefPath getLeafRefNodePath() {
+ LeafRefPath ret = leafRefNodePath;
+ if (ret == null) {
+ synchronized (this) {
+ ret = leafRefNodePath;
+ if (ret == null) {
+ ret = leafRefNodePath = LeafRefUtils.schemaPathToLeafRefPath(currentNodePath, module);
+ }
+ }
+ }
+ return ret;
+ }
}