Remove RevisionSourceIdentifier
[yangtools.git] / model / 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.NonNull;
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 public enum OpenDaylightExtensionsStatements implements StatementDefinition {
23     // Binding codegen support
24     AUGMENT_IDENTIFIER(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "augment-identifier"),
25         "identifier", AugmentIdentifierStatement.class, AugmentIdentifierEffectiveStatement.class),
26
27     // Mount extension
28     MOUNT(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "mount"), null,
29         MountStatement.class, MountEffectiveStatement.class),
30
31     // Context-aware RPCs
32     CONTEXT_INSTANCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "context-instance"),
33         "context-type", ContextInstanceStatement.class, ContextInstanceEffectiveStatement.class),
34     CONTEXT_REFERENCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "context-reference"),
35         "context-type", ContextReferenceStatement.class, ContextReferenceEffectiveStatement.class),
36     INSTANCE_TARGET(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "instance-target"),
37         "path", InstanceTargetStatement.class, InstanceTargetEffectiveStatement.class),
38     RPC_CONTEXT_REFERENCE(QName.create(OpenDaylightExtensionsConstants.ORIGINAL_MODULE, "rpc-context-reference"),
39         "context-type", RpcContextReferenceStatement.class, RpcContextReferenceEffectiveStatement.class);
40
41     private final @NonNull Class<? extends EffectiveStatement<?, ?>> effectiveRepresentation;
42     private final @NonNull Class<? extends DeclaredStatement<?>> declaredRepresentation;
43     private final @NonNull QName statementName;
44     private final ArgumentDefinition argumentDef;
45
46     OpenDaylightExtensionsStatements(final QName statementName, final String argumentName,
47             final Class<? extends DeclaredStatement<?>> declaredRepresentation,
48             final Class<? extends EffectiveStatement<?, ?>> effectiveRepresentation) {
49         this.statementName = statementName.intern();
50         this.argumentDef = argumentName == null ? null
51             : ArgumentDefinition.of(QName.create(statementName, argumentName).intern(), false);
52         this.declaredRepresentation = requireNonNull(declaredRepresentation);
53         this.effectiveRepresentation = requireNonNull(effectiveRepresentation);
54     }
55
56     @Override
57     public QName getStatementName() {
58         return statementName;
59     }
60
61     @Override
62     public Optional<ArgumentDefinition> getArgumentDefinition() {
63         return Optional.ofNullable(argumentDef);
64     }
65
66     @Override
67     public Class<? extends DeclaredStatement<?>> getDeclaredRepresentationClass() {
68         return declaredRepresentation;
69     }
70
71     @Override
72     public Class<? extends EffectiveStatement<?, ?>> getEffectiveRepresentationClass() {
73         return effectiveRepresentation;
74     }
75 }