Populate data/ hierarchy
[yangtools.git] / yang / odlext-model-api / src / main / java / org / opendaylight / yangtools / odlext / model / api / OpenDaylightExtensionsStatements.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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 package org.opendaylight.yangtools.odlext.model.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.meta.ArgumentDefinition;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
20
21 @Beta
22 @NonNullByDefault
23 public enum OpenDaylightExtensionsStatements implements StatementDefinition {
24     // Binding codegen support
25     AUGMENT_IDENTIFIER(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "augment-identifier"),
26         "identifier", AugmentIdentifierStatement.class, AugmentIdentifierEffectiveStatement.class),
27
28     // Context-aware RPCs
29     CONTEXT_INSTANCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "context-instance"),
30         "context-type", ContextInstanceStatement.class, ContextInstanceEffectiveStatement.class),
31     CONTEXT_REFERENCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "context-reference"),
32         "context-type", ContextReferenceStatement.class, ContextReferenceEffectiveStatement.class),
33     INSTANCE_TARGET(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "instance-target"),
34         "path", InstanceTargetStatement.class, InstanceTargetEffectiveStatement.class),
35     RPC_CONTEXT_REFERENCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "rpc-context-reference"),
36         "context-type", RpcContextReferenceStatement.class, RpcContextReferenceEffectiveStatement.class);
37
38     private final Class<? extends EffectiveStatement<?, ?>> effectiveRepresentation;
39     private final Class<? extends DeclaredStatement<?>> declaredRepresentation;
40     private final QName statementName;
41     private final ArgumentDefinition argumentDef;
42
43     OpenDaylightExtensionsStatements(final QName statementName, final String argumentName,
44             final Class<? extends DeclaredStatement<?>> declaredRepresentation,
45             final Class<? extends EffectiveStatement<?, ?>> effectiveRepresentation) {
46         this.statementName = statementName.intern();
47         this.argumentDef = ArgumentDefinition.of(QName.create(statementName, argumentName).intern(), false);
48         this.declaredRepresentation = requireNonNull(declaredRepresentation);
49         this.effectiveRepresentation = requireNonNull(effectiveRepresentation);
50     }
51
52     @Override
53     public QName getStatementName() {
54         return statementName;
55     }
56
57     @Override
58     public Optional<ArgumentDefinition> getArgumentDefinition() {
59         return Optional.of(argumentDef);
60     }
61
62     @Override
63     public Class<? extends DeclaredStatement<?>> getDeclaredRepresentationClass() {
64         return declaredRepresentation;
65     }
66
67     @Override
68     public Class<? extends EffectiveStatement<?, ?>> getEffectiveRepresentationClass() {
69         return effectiveRepresentation;
70     }
71 }