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 java.util.ArrayList;
13 import java.util.List;
14 import javax.lang.model.element.Modifier;
17 private final String type;
18 private final String name;
19 private final String definition;
20 private final List<Modifier> modifiers;
21 private final boolean needsDepResolver;
23 public Field(String type, String name) {
24 this(new ArrayList<>(), type, name, null, false);
27 public Field(String type, String name, String definition) {
28 this(new ArrayList<>(), type, name, definition, false);
31 public Field(List<Modifier> modifiers, String type, String name) {
32 this(modifiers, type, name, null, false);
35 public Field(List<Modifier> modifiers, String type, String name,
37 this(modifiers, type, name, definition, false);
40 public Field(List<Modifier> 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(new ArrayList<>(), 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<Modifier> 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);