Revert "Revert "Updated SchemaNodeIdentifier namespace handling.""
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / UniqueStatementImpl.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
10
11 import java.util.Collection;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
17 import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UniqueEffectiveStatementImpl;
23
24 public class UniqueStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier.Relative>> implements UniqueStatement {
25
26     protected UniqueStatementImpl(StmtContext<Collection<SchemaNodeIdentifier.Relative>, UniqueStatement, ?> context) {
27         super(context);
28     }
29
30     public static class Definition
31             extends
32             AbstractStatementSupport<Collection<SchemaNodeIdentifier.Relative>, UniqueStatement,
33                     EffectiveStatement<Collection<SchemaNodeIdentifier.Relative>, UniqueStatement>> {
34
35         public Definition() {
36             super(Rfc6020Mapping.UNIQUE);
37         }
38
39         @Override
40         public Collection<SchemaNodeIdentifier.Relative> parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws
41                 SourceException {
42             return Utils.transformKeysStringToKeyNodes(ctx, value);
43         }
44
45         @Override
46         public UniqueStatement createDeclared(StmtContext<Collection<Relative>, UniqueStatement, ?> ctx) {
47             return new UniqueStatementImpl(ctx);
48         }
49
50         @Override
51         public EffectiveStatement<Collection<Relative>, UniqueStatement> createEffective
52                 (StmtContext<Collection<Relative>, UniqueStatement, EffectiveStatement<Collection<Relative>,
53                         UniqueStatement>> ctx) {
54             return new UniqueEffectiveStatementImpl(ctx);
55         }
56     }
57
58     @Nonnull
59     @Override
60     public Collection<Relative> getTag() {
61         return argument();
62     }
63 }