Bug 7759 - TEST - Getter of BA object fails to construct class instance
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / generator / util / generated / type / builder / GeneratedPropertyBuilderImpl.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.mdsal.binding.generator.util.generated.type.builder;
9
10 import java.util.List;
11 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
12 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
13 import org.opendaylight.mdsal.binding.model.api.Type;
14 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedPropertyBuilder;
15
16 public final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder> implements GeneratedPropertyBuilder {
17     private String value;
18     private boolean isReadOnly;
19
20     public GeneratedPropertyBuilderImpl(final String name) {
21         super(name);
22         this.isReadOnly = true;
23     }
24
25     @Override
26     public GeneratedPropertyBuilderImpl setValue(final String value) {
27         this.value = value;
28         return this;
29     }
30
31     @Override
32     public GeneratedPropertyBuilderImpl setReadOnly(final boolean isReadOnly) {
33         this.isReadOnly = isReadOnly;
34         return this;
35     }
36
37     @Override
38     protected GeneratedPropertyBuilderImpl thisInstance() {
39         return this;
40     }
41
42     @Override
43     public GeneratedProperty toInstance(final Type definingType) {
44         final List<AnnotationType> annotations = toAnnotationTypes();
45         return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
46                 getReturnType(), isFinal(), isStatic(), this.isReadOnly, this.value);
47     }
48
49     @Override
50     public String toString() {
51         final StringBuilder builder = new StringBuilder();
52         builder.append("GeneratedPropertyImpl [name=");
53         builder.append(getName());
54         builder.append(", annotations=");
55         builder.append(getAnnotationBuilders());
56         builder.append(", comment=");
57         builder.append(getComment());
58         builder.append(", returnType=");
59         builder.append(getReturnType());
60         builder.append(", isFinal=");
61         builder.append(isFinal());
62         builder.append(", isReadOnly=");
63         builder.append(this.isReadOnly);
64         builder.append(", modifier=");
65         builder.append(getAccessModifier());
66         builder.append("]");
67         return builder.toString();
68     }
69 }