07e5492297d211a5ddf3448461a49444f1af6d93
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / 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.model.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>
17         implements GeneratedPropertyBuilder {
18     private String value;
19     private boolean readOnly;
20
21     public GeneratedPropertyBuilderImpl(final String name) {
22         super(name);
23         this.readOnly = true;
24     }
25
26     @Override
27     public GeneratedPropertyBuilderImpl setValue(final String value) {
28         this.value = value;
29         return this;
30     }
31
32     @Override
33     public GeneratedPropertyBuilderImpl setReadOnly(final boolean isReadOnly) {
34         this.readOnly = isReadOnly;
35         return this;
36     }
37
38     @Override
39     protected GeneratedPropertyBuilderImpl thisInstance() {
40         return this;
41     }
42
43     @Override
44     public GeneratedProperty toInstance(final Type definingType) {
45         final List<AnnotationType> annotations = toAnnotationTypes();
46         return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
47                 getReturnType(), isFinal(), isStatic(), this.readOnly, this.value);
48     }
49
50     @Override
51     public String toString() {
52         final StringBuilder builder = new StringBuilder();
53         builder.append("GeneratedPropertyImpl [name=");
54         builder.append(getName());
55         builder.append(", annotations=");
56         builder.append(getAnnotationBuilders());
57         builder.append(", comment=");
58         builder.append(getComment());
59         builder.append(", returnType=");
60         builder.append(getReturnType());
61         builder.append(", isFinal=");
62         builder.append(isFinal());
63         builder.append(", isReadOnly=");
64         builder.append(this.readOnly);
65         builder.append(", modifier=");
66         builder.append(getAccessModifier());
67         builder.append("]");
68         return builder.toString();
69     }
70 }