74e5bb0490c5de483a357476ecf3bde7b3aeb790
[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, String attributeName, String nullableDefault,
24             boolean isDependency, Dependency dependency, boolean isListOfDependencies, boolean needsDepResolver) {
25         super(modifiers, type, name, null, needsDepResolver);
26         this.dependent = isDependency;
27         this.dependency = dependency;
28         this.attributeName = attributeName;
29         if (type.startsWith(List.class.getName()) && nullableDefault == null) {
30             String generics = type.substring(List.class.getName().length());
31             nullableDefault = "new " + ArrayList.class.getName() + generics + "()";
32         }
33         this.nullableDefault = nullableDefault;
34         this.isListOfDependencies = isListOfDependencies;
35     }
36
37     public ModuleField(String type, String name, String attributeName, String nullableDefault, boolean isDependency,
38             Dependency dependency, boolean isListOfDependencies, boolean needsDepResolve) {
39         this(Collections.<String> emptyList(), type, name, attributeName, nullableDefault, isDependency, dependency,
40                 isListOfDependencies, needsDepResolve);
41     }
42
43     public boolean isIdentityRef() {
44         return false;
45     }
46
47     public Dependency getDependency() {
48         return dependency;
49     }
50
51     public String getNullableDefault() {
52         return nullableDefault;
53     }
54
55     public boolean isDependent() {
56         return dependent;
57     }
58
59     public boolean isListOfDependencies() {
60         return isListOfDependencies;
61     }
62
63     public String getAttributeName() {
64         return attributeName;
65     }
66
67 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.