Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Commit a1c3bcd

Browse files
authored
Merge pull request #60 from yagolasse/master
feat: Added money type as Long to Java target
2 parents 89e9975 + 4285860 commit a1c3bcd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/target/java.cr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ abstract class JavaTarget < Target
2121
when AST::StringPrimitiveType ; "String"
2222
when AST::IntPrimitiveType ; "Integer"
2323
when AST::UIntPrimitiveType ; "Integer"
24+
when AST::MoneyPrimitiveType ; "Long"
2425
when AST::FloatPrimitiveType ; "Double"
2526
when AST::DatePrimitiveType ; "Calendar"
2627
when AST::DateTimePrimitiveType; "Calendar"
@@ -201,6 +202,8 @@ END
201202

202203
def type_from_json(t : AST::Type, obj : String, name : String)
203204
case t
205+
when AST::MoneyPrimitiveType
206+
"#{obj}.getLong(#{name})"
204207
when AST::StringPrimitiveType
205208
"#{obj}.getString(#{name})"
206209
when AST::IntPrimitiveType, AST::UIntPrimitiveType
@@ -236,7 +239,7 @@ END
236239

237240
def type_to_json(t : AST::Type, src : String)
238241
case t
239-
when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType
242+
when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType, AST::MoneyPrimitiveType
240243
"#{src}"
241244
when AST::DatePrimitiveType
242245
"DateHelpers.encodeDate(#{src})"

0 commit comments

Comments
 (0)