Added NotificationListener interfaces
[yangtools.git] / code-generator / binding-generator-util / src / main / java / org / opendaylight / yangtools / 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.yangtools.binding.generator.util.generated.type.builder;
9
10 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
11 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
12 import org.opendaylight.yangtools.sal.binding.model.api.Type;
13 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
14
15 import java.util.List;
16
17 final class GeneratedPropertyBuilderImpl extends AbstractTypeMemberBuilder<GeneratedPropertyBuilder> 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 GeneratedPropertyBuilderImpl setReadOnly(boolean isReadOnly) {
28         this.isReadOnly = isReadOnly;
29         return this;
30     }
31
32     @Override
33     protected GeneratedPropertyBuilderImpl thisInstance() {
34         return this;
35     }
36     
37     @Override
38     public GeneratedProperty toInstance(Type definingType) {
39         final List<AnnotationType> annotations = toAnnotationTypes();
40         return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
41                 getReturnType(), isFinal(), isReadOnly);
42     }
43
44     @Override
45     public String toString() {
46         StringBuilder builder = new StringBuilder();
47         builder.append("GeneratedPropertyImpl [name=");
48         builder.append(getName());
49         builder.append(", annotations=");
50         builder.append(getAnnotationBuilders());
51         builder.append(", comment=");
52         builder.append(getComment());
53         builder.append(", returnType=");
54         builder.append(getReturnType());
55         builder.append(", isFinal=");
56         builder.append(isFinal());
57         builder.append(", isReadOnly=");
58         builder.append(isReadOnly);
59         builder.append(", modifier=");
60         builder.append(getAccessModifier());
61         builder.append("]");
62         return builder.toString();
63     }
64 }