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;
10 import static com.google.common.base.Preconditions.checkNotNull;
12 import com.google.common.collect.Lists;
13 import java.util.List;
16 private final String type;
17 private final String name;
18 private final String definition;
19 private final List<String> modifiers;
20 private final boolean needsDepResolver;
22 public Field(String type, String name) {
23 this(Lists.<String> newArrayList(), type, name, null, false);
26 public Field(String type, String name, String definition) {
27 this(Lists.<String> newArrayList(), type, name, definition, false);
30 public Field(List<String> modifiers, String type, String name) {
31 this(modifiers, type, name, null, false);
34 public Field(List<String> modifiers, String type, String name,
36 this(modifiers, type, name, definition, false);
39 public Field(List<String> modifiers, String type, String name,
40 String nullableDefinition, boolean needsDepResolver) {
41 this.modifiers = checkNotNull(modifiers);
42 this.type = checkNotNull(type);
43 this.name = checkNotNull(name);
44 this.definition = nullableDefinition;
45 this.needsDepResolver = needsDepResolver;
48 public Field(String type, String name, String definition, boolean needsDepResolver) {
49 this(Lists.<String> newArrayList(), type, name, definition, needsDepResolver);
52 public boolean isNeedsDepResolver() {
53 return needsDepResolver;
56 public String getType() {
60 public String getGenericInnerType() {
61 return type.substring(type.indexOf("<") + 1, type.indexOf(">"));
64 public List<String> getModifiers() {
68 public String getName() {
72 public String getDefinition() {
76 public boolean isArray() {
77 return type.endsWith("[]");
81 public String toString() {
82 return FieldSerializer.toString(this);