View Javadoc

1   /*******************************************************************************
2    * Copyright (c) 2009 Ordina and committers to Mod4j
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *     Ordina - initial implementation
10   *******************************************************************************/
11  package org.mod4j.dslcommon.generator.helpers;
12  
13  public class JavaTypeHelpers {
14  
15      public static String javaPrimitiveType(String typename, boolean nullable) {
16          if (typename.equalsIgnoreCase("boolean")) {
17              if (nullable) {
18                  return "Boolean";
19              } else {
20                  return "boolean";
21              }
22          } else if (typename.equalsIgnoreCase("string")) {
23              return "String";
24          } else if (typename.equalsIgnoreCase("integer")) {
25              if (nullable) {
26                  return "Integer";
27              } else {
28                  return "int";
29              }
30          } else if (typename.equalsIgnoreCase("decimal")) {
31              if (nullable) {
32                  return "Float";
33              } else {
34                  return "float";
35              }
36          } else if (typename.equalsIgnoreCase("datetime")) {
37              return "DateTime";
38          }
39          return "void";
40      }
41  
42  }