Merge "Refactor Subnet.isSubnetOf - reduce number of 'if' statements. Added unitests."
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / model / ModuleField.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.config.yangjmxgenerator.plugin.ftl.model;
9
10
11 import org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
12
13 import java.util.ArrayList;
14 import java.util.Collections;
15 import java.util.List;
16
17 public class ModuleField extends Field {
18
19     private final String nullableDefault, attributeName;
20     private final boolean dependent, isListOfDependencies;
21     private final Dependency dependency;
22
23     private ModuleField(List<String> modifiers, String type, String name,
24             String attributeName, String nullableDefault, boolean isDependency,
25             Dependency dependency, boolean isListOfDependencies) {
26         super(modifiers, type, name);
27         this.dependent = isDependency;
28         this.dependency = dependency;
29         this.attributeName = attributeName;
30         if (type.startsWith(List.class.getName()) && nullableDefault == null) {
31             String generics = type.substring(List.class.getName().length());
32             nullableDefault = "new " + ArrayList.class.getName() + generics + "()";
33         }
34         this.nullableDefault = nullableDefault;
35         this.isListOfDependencies = isListOfDependencies;
36     }
37
38     public ModuleField(String type, String name, String attributeName,
39             String nullableDefault, boolean isDependency, Dependency dependency, boolean isListOfDependencies) {
40         this(Collections.<String> emptyList(), type, name, attributeName,
41                 nullableDefault, isDependency, dependency, isListOfDependencies);
42     }
43
44     public Dependency getDependency() {
45         return dependency;
46     }
47
48     public String getNullableDefault() {
49         return nullableDefault;
50     }
51
52     public boolean isDependent() {
53         return dependent;
54     }
55
56     public boolean isListOfDependencies() {
57         return isListOfDependencies;
58     }
59
60     public String getAttributeName() {
61         return attributeName;
62     }
63
64 }