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 org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
16 public class ModuleField extends Field {
18 private final String nullableDefault, attributeName;
19 private final boolean dependent, isListOfDependencies;
20 private final Dependency dependency;
22 private ModuleField(List<String> modifiers, String type, String name, String attributeName, String nullableDefault,
23 boolean isDependency, Dependency dependency, boolean isListOfDependencies, boolean needsDepResolver) {
24 super(modifiers, type, name, null, needsDepResolver);
25 this.dependent = isDependency;
26 this.dependency = dependency;
27 this.attributeName = attributeName;
28 if (type.startsWith(List.class.getName()) && nullableDefault == null) {
29 String generics = type.substring(List.class.getName().length());
30 nullableDefault = "new " + ArrayList.class.getName() + generics + "()";
32 this.nullableDefault = nullableDefault;
33 this.isListOfDependencies = isListOfDependencies;
36 public ModuleField(String type, String name, String attributeName, String nullableDefault, boolean isDependency,
37 Dependency dependency, boolean isListOfDependencies, boolean needsDepResolve) {
38 this(Collections.<String> emptyList(), type, name, attributeName, nullableDefault, isDependency, dependency,
39 isListOfDependencies, needsDepResolve);
42 public boolean isIdentityRef() {
47 public String toString() {
48 return ModuleFieldSerializer.toString(this);
51 public Dependency getDependency() {
55 public String getNullableDefault() {
56 return nullableDefault;
59 public boolean isDependent() {
63 public boolean isListOfDependencies() {
64 return isListOfDependencies;
67 public String getAttributeName() {
72 public boolean isList() {
73 return getType().startsWith("java.util.List");