2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
14 import javax.lang.model.element.Modifier;
15 import org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
17 public class ModuleField extends Field {
19 private final String nullableDefault, attributeName;
20 private final boolean dependent, isListOfDependencies;
21 private final Dependency dependency;
23 private ModuleField(List<Modifier> modifiers, String type, String name, String attributeName,
24 String nullableDefault, boolean isDependency, Dependency dependency, boolean isListOfDependencies,
25 boolean needsDepResolver) {
26 super(modifiers, type, name, null, needsDepResolver);
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 + "()";
34 this.nullableDefault = nullableDefault;
35 this.isListOfDependencies = isListOfDependencies;
38 public ModuleField(String type, String name, String attributeName, String nullableDefault, boolean isDependency,
39 Dependency dependency, boolean isListOfDependencies, boolean needsDepResolve) {
40 this(Collections.emptyList(), type, name, attributeName, nullableDefault, isDependency, dependency,
41 isListOfDependencies, needsDepResolve);
44 public boolean isIdentityRef() {
49 public String toString() {
50 return ModuleFieldSerializer.toString(this);
53 public Dependency getDependency() {
57 public String getNullableDefault() {
58 return nullableDefault;
61 public boolean isDependent() {
65 public boolean isListOfDependencies() {
66 return isListOfDependencies;
69 public String getAttributeName() {
74 public boolean isList() {
75 return getType().startsWith("java.util.List");