+ @Override
+ public StatementContextBase build() {
+ /*
+ * If root is null or root version is other than default,
+ * we need to create new root.
+ */
+ if (root == null) {
+ root = new RootStatementContext(this, SourceSpecificContext.this);
+ } else if (!RootStatementContext.DEFAULT_VERSION.equals(root.getRootVersion())
+ && inProgressPhase == ModelProcessingPhase.SOURCE_LINKAGE) {
+ root = new RootStatementContext(this, SourceSpecificContext.this, root.getRootVersion());
+ } else {
+ final QName rootStatement = root.definition().getStatementName();
+ final String rootArgument = root.rawStatementArgument();
+
+ Preconditions.checkState(Objects.equals(getDefinition().getStatementName(), rootStatement)
+ && Objects.equals(getRawArgument(), rootArgument),
+ "Root statement was already defined as '%s %s'.", rootStatement, rootArgument);
+ }
+ root.resetLists();
+ return root;
+ }
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(SourceSpecificContext.class);
+ private static final Table<YangVersion, String, StatementSupport<?, ?, ?>> BUILTIN_TYPE_SUPPORTS =
+ ImmutableTable.<YangVersion, String, StatementSupport<?, ?, ?>>builder()
+ .put(YangVersion.VERSION_1, TypeUtils.DECIMAL64, new Decimal64SpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1, TypeUtils.UNION, new UnionSpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1, TypeUtils.ENUMERATION, new EnumSpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1, TypeUtils.LEAF_REF, new LeafrefSpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1_1, TypeUtils.LEAF_REF, new LeafrefSpecificationRfc7950Support())
+ .put(YangVersion.VERSION_1, TypeUtils.BITS, new BitsSpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1, TypeUtils.IDENTITY_REF, new IdentityRefSpecificationImpl.Definition())
+ .put(YangVersion.VERSION_1, TypeUtils.INSTANCE_IDENTIFIER, new InstanceIdentifierSpecificationImpl.Definition())
+ .build();
+
+ private static final QName TYPE = YangStmtMapping.TYPE.getStatementName();
+
+ private final Multimap<ModelProcessingPhase, ModifierImpl> modifiers = HashMultimap.create();
+ private final QNameToStatementDefinitionMap qNameToStmtDefMap = new QNameToStatementDefinitionMap();
+ private final PrefixToModuleMap prefixToModuleMap = new PrefixToModuleMap();
+ private final BuildGlobalContext currentContext;
+ private final StatementStreamSource source;