Clean up GeneratedProperty use
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / BuilderGeneratedProperty.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, 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.mdsal.binding.java.api.generator;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.util.List;
13 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
14 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
15 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
16 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
17 import org.opendaylight.mdsal.binding.model.api.MethodSignature.ValueMechanics;
18 import org.opendaylight.mdsal.binding.model.api.Type;
19
20 final class BuilderGeneratedProperty implements GeneratedProperty {
21     private final MethodSignature method;
22     private final String name;
23
24     BuilderGeneratedProperty(final String name, final MethodSignature method) {
25         this.name = requireNonNull(name);
26         this.method = requireNonNull(method);
27     }
28
29     @Override
30     public String getName() {
31         return name;
32     }
33
34     @Override
35     public Type getReturnType() {
36         return method.getReturnType();
37     }
38
39     ValueMechanics getMechanics() {
40         return method.getMechanics();
41     }
42
43     @Override
44     public int hashCode() {
45         return name.hashCode();
46     }
47
48     @Override
49     public boolean equals(final Object obj) {
50         if (obj == this) {
51             return true;
52         }
53         if (!(obj instanceof BuilderGeneratedProperty)) {
54             return false;
55         }
56         final BuilderGeneratedProperty other = (BuilderGeneratedProperty) obj;
57         return name.equals(other.name) && method.equals(other.method);
58     }
59
60     @Override
61     public String getComment() {
62         throw uoe();
63     }
64
65     @Override
66     public List<AnnotationType> getAnnotations() {
67         throw uoe();
68     }
69
70     @Override
71     public AccessModifier getAccessModifier() {
72         throw uoe();
73     }
74
75     @Override
76     public boolean isStatic() {
77         throw uoe();
78     }
79
80     @Override
81     public boolean isFinal() {
82         throw uoe();
83     }
84
85     @Override
86     public Type getDefiningType() {
87         throw uoe();
88     }
89
90     @Override
91     public String getValue() {
92         throw uoe();
93     }
94
95     @Override
96     public boolean isReadOnly() {
97         throw uoe();
98     }
99
100     private static UnsupportedOperationException uoe() {
101         return new UnsupportedOperationException("Method not supported");
102     }
103 }