@Test public void classToTypeNameTest() throws Exception { assertEquals(TypeName.INT, ScalarTypes.classToTypeName(int.class)); assertEquals(TypeName.INT.box(), ScalarTypes.classToTypeName(Integer.class)); }
public static TypeName classToTypeName(Class scalar) { if (scalar.isPrimitive()) { switch (scalar.getSimpleName()) { case "int": return TypeName.INT; case "boolean": return TypeName.BOOLEAN; case "double": return TypeName.DOUBLE; case "float": return TypeName.FLOAT; case "byte": return TypeName.BYTE; case "char": return TypeName.CHAR; case "short": return TypeName.SHORT; case "long": return TypeName.LONG; case "void": return TypeName.VOID; default: throw new GenerationException("can't handle type: " + scalar); } } else { return ClassName.get(scalar); } }
ScalarTypes { public static TypeName classToTypeName(Class scalar) { if (scalar.isPrimitive()) { switch (scalar.getSimpleName()) { case "int": return TypeName.INT; case "boolean": return TypeName.BOOLEAN; case "double": return TypeName.DOUBLE; case "float": return TypeName.FLOAT; case "byte": return TypeName.BYTE; case "char": return TypeName.CHAR; case "short": return TypeName.SHORT; case "long": return TypeName.LONG; case "void": return TypeName.VOID; default: throw new GenerationException("can't handle type: " + scalar); } } else { return ClassName.get(scalar); } } }
ScalarTypes { public static TypeName classToTypeName(Class scalar) { if (scalar.isPrimitive()) { switch (scalar.getSimpleName()) { case "int": return TypeName.INT; case "boolean": return TypeName.BOOLEAN; case "double": return TypeName.DOUBLE; case "float": return TypeName.FLOAT; case "byte": return TypeName.BYTE; case "char": return TypeName.CHAR; case "short": return TypeName.SHORT; case "long": return TypeName.LONG; case "void": return TypeName.VOID; default: throw new GenerationException("can't handle type: " + scalar); } } else { return ClassName.get(scalar); } }  }
ScalarTypes { public static TypeName classToTypeName(Class scalar) { if (scalar.isPrimitive()) { switch (scalar.getSimpleName()) { case "int": return TypeName.INT; case "boolean": return TypeName.BOOLEAN; case "double": return TypeName.DOUBLE; case "float": return TypeName.FLOAT; case "byte": return TypeName.BYTE; case "char": return TypeName.CHAR; case "short": return TypeName.SHORT; case "long": return TypeName.LONG; case "void": return TypeName.VOID; default: throw new GenerationException("can't handle type: " + scalar); } } else { return ClassName.get(scalar); } }  static boolean extendsScalarRamlType(TypeDeclaration typeDeclaration); static TypeName classToTypeName(Class scalar); }
ScalarTypes { public static TypeName classToTypeName(Class scalar) { if (scalar.isPrimitive()) { switch (scalar.getSimpleName()) { case "int": return TypeName.INT; case "boolean": return TypeName.BOOLEAN; case "double": return TypeName.DOUBLE; case "float": return TypeName.FLOAT; case "byte": return TypeName.BYTE; case "char": return TypeName.CHAR; case "short": return TypeName.SHORT; case "long": return TypeName.LONG; case "void": return TypeName.VOID; default: throw new GenerationException("can't handle type: " + scalar); } } else { return ClassName.get(scalar); } }  static boolean extendsScalarRamlType(TypeDeclaration typeDeclaration); static TypeName classToTypeName(Class scalar);  }