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