d884dcf94486e2e7927e96a8ff9b0519c17fc607
[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 getter;
22     private final String name;
23
24     BuilderGeneratedProperty(final String name, final MethodSignature getter) {
25         this.name = requireNonNull(name);
26         this.getter = requireNonNull(getter);
27     }
28
29     @Override
30     public String getName() {
31         return name;
32     }
33
34     @Override
35     public Type getReturnType() {
36         return getter.getReturnType();
37     }
38
39     ValueMechanics getMechanics() {
40         return getter.getMechanics();
41     }
42
43     String getGetterName() {
44         return getter.getName();
45     }
46
47     @Override
48     public int hashCode() {
49         return name.hashCode();
50     }
51
52     @Override
53     public boolean equals(final Object obj) {
54         if (obj == this) {
55             return true;
56         }
57         if (!(obj instanceof BuilderGeneratedProperty)) {
58             return false;
59         }
60         final BuilderGeneratedProperty other = (BuilderGeneratedProperty) obj;
61         return name.equals(other.name) && getter.equals(other.getter);
62     }
63
64     @Override
65     public String getComment() {
66         throw uoe();
67     }
68
69     @Override
70     public List<AnnotationType> getAnnotations() {
71         throw uoe();
72     }
73
74     @Override
75     public AccessModifier getAccessModifier() {
76         throw uoe();
77     }
78
79     @Override
80     public boolean isStatic() {
81         throw uoe();
82     }
83
84     @Override
85     public boolean isFinal() {
86         throw uoe();
87     }
88
89     @Override
90     public Type getDefiningType() {
91         throw uoe();
92     }
93
94     @Override
95     public String getValue() {
96         throw uoe();
97     }
98
99     @Override
100     public boolean isReadOnly() {
101         throw uoe();
102     }
103
104     private static UnsupportedOperationException uoe() {
105         return new UnsupportedOperationException("Method not supported");
106     }
107 }