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 com.google.common.collect.Lists;
12 import java.util.List;
14 import static com.google.common.base.Preconditions.checkNotNull;
17 private final String type;
18 private final String name;
19 private final String definition;
20 private final List<String> modifiers;
21 private final boolean needsDepResolver;
23 public Field(String type, String name) {
24 this(Lists.<String> newArrayList(), type, name, null, false);
27 public Field(String type, String name, String definition) {
28 this(Lists.<String> newArrayList(), type, name, definition, false);
31 public Field(List<String> modifiers, String type, String name) {
32 this(modifiers, type, name, null, false);
35 public Field(List<String> modifiers, String type, String name,
37 this(modifiers, type, name, definition, false);
40 public Field(List<String> modifiers, String type, String name,
41 String nullableDefinition, boolean needsDepResolver) {
42 this.modifiers = checkNotNull(modifiers);
43 this.type = checkNotNull(type);
44 this.name = checkNotNull(name);
45 this.definition = nullableDefinition;
46 this.needsDepResolver = needsDepResolver;
49 public Field(String type, String name, String definition, boolean needsDepResolver) {
50 this(Lists.<String> newArrayList(), type, name, definition, needsDepResolver);
53 public boolean isNeedsDepResolver() {
54 return needsDepResolver;
57 public String getType() {
61 public String getGenericInnerType() {
62 return type.substring(type.indexOf("<") + 1, type.indexOf(">"));
65 public List<String> getModifiers() {
69 public String getName() {
73 public String getDefinition() {
77 public boolean isArray() {
78 return type.endsWith("[]");
82 public String toString() {
83 return FieldSerializer.toString(this);