Merge "OF plugin classes must have a strict dependency on Connection Service"
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-util / src / main / java / org / opendaylight / controller / 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.controller.binding.generator.util.generated.type.builder;
9
10 import org.opendaylight.controller.sal.binding.model.api.AnnotationType;
11 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
12 import org.opendaylight.controller.sal.binding.model.api.Type;
13 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
14
15 import java.util.List;
16
17 final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder implements GeneratedPropertyBuilder {
18
19     private boolean isReadOnly;
20
21     public GeneratedPropertyBuilderImpl(String name) {
22         super(name);
23         this.isReadOnly = true;
24     }
25
26     @Override
27     public void setReadOnly(boolean isReadOnly) {
28         this.isReadOnly = isReadOnly;
29     }
30
31     @Override
32     public GeneratedProperty toInstance(Type definingType) {
33         final List<AnnotationType> annotations = toAnnotationTypes();
34         return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
35                 getReturnType(), isFinal(), isReadOnly);
36     }
37
38     @Override
39     public String toString() {
40         StringBuilder builder = new StringBuilder();
41         builder.append("GeneratedPropertyImpl [name=");
42         builder.append(getName());
43         builder.append(", annotations=");
44         builder.append(getAnnotationBuilders());
45         builder.append(", comment=");
46         builder.append(getComment());
47         builder.append(", returnType=");
48         builder.append(getReturnType());
49         builder.append(", isFinal=");
50         builder.append(isFinal());
51         builder.append(", isReadOnly=");
52         builder.append(isReadOnly);
53         builder.append(", modifier=");
54         builder.append(getAccessModifier());
55         builder.append("]");
56         return builder.toString();
57     }
58 }