5c9665e086a7269f4abb38a34b058d340c6e3c2c
[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     private boolean nullifyEmpty;
21
22     public GeneratedPropertyBuilderImpl(final String name) {
23         super(name);
24         this.readOnly = true;
25         this.nullifyEmpty = false;
26     }
27
28     @Override
29     public GeneratedPropertyBuilderImpl setValue(final String value) {
30         this.value = value;
31         return this;
32     }
33
34     @Override
35     public GeneratedPropertyBuilderImpl setReadOnly(final boolean isReadOnly) {
36         this.readOnly = isReadOnly;
37         return this;
38     }
39
40     @Override
41     public GeneratedPropertyBuilderImpl setNullifyEmpty(final boolean flag) {
42         this.nullifyEmpty = flag;
43         return this;
44     }
45
46     @Override
47     protected GeneratedPropertyBuilderImpl thisInstance() {
48         return this;
49     }
50
51     @Override
52     public GeneratedProperty toInstance(final Type definingType) {
53         final List<AnnotationType> annotations = toAnnotationTypes();
54         return new GeneratedPropertyImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
55                 getReturnType(), isFinal(), isStatic(), this.readOnly, this.nullifyEmpty, this.value);
56     }
57
58     @Override
59     public String toString() {
60         final StringBuilder builder = new StringBuilder();
61         builder.append("GeneratedPropertyImpl [name=");
62         builder.append(getName());
63         builder.append(", annotations=");
64         builder.append(getAnnotationBuilders());
65         builder.append(", comment=");
66         builder.append(getComment());
67         builder.append(", returnType=");
68         builder.append(getReturnType());
69         builder.append(", isFinal=");
70         builder.append(isFinal());
71         builder.append(", isReadOnly=");
72         builder.append(this.readOnly);
73         builder.append(", modifier=");
74         builder.append(getAccessModifier());
75         builder.append("]");
76         return builder.toString();
77     }
78 }