Skip to content

Commit 4abbf68

Browse files
committed
Chenged genType and genWrapperType from ArrayList, HashMap to List, Map
1 parent fd1b2cf commit 4abbf68

File tree

1 file changed

+16
-16
lines changed
  • msgpack-idl/Language/MessagePack/IDL/CodeGen

1 file changed

+16
-16
lines changed

msgpack-idl/Language/MessagePack/IDL/CodeGen/Java.hs

+16-16
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ genStruct :: [(T.Text, Type)] -> Config -> Decl -> IO()
104104
genStruct alias Config{..} MPMessage {..} = do
105105
let params = if null msgParam then "" else [lt|<#{T.intercalate ", " msgParam}>|]
106106
resolvedMsgFields = map (resolveFieldAlias alias) msgFields
107-
hashMapImport | not $ null [() | TMap _ _ <- map fldType resolvedMsgFields] = [lt|import java.util.HashMap;|]
108-
| otherwise = ""
109-
arrayListImport | not $ null [() | TList _ <- map fldType resolvedMsgFields] = [lt|import java.util.ArrayList;|]
110-
| otherwise = ""
107+
mapImport | not $ null [() | TMap _ _ <- map fldType resolvedMsgFields] = [lt|import java.util.Map;|]
108+
| otherwise = ""
109+
listImport | not $ null [() | TList _ <- map fldType resolvedMsgFields] = [lt|import java.util.List;|]
110+
| otherwise = ""
111111
dirName = joinPath $ map LT.unpack $ LT.split (== '.') $ LT.pack configPackage
112112
fileName = dirName ++ "/" ++ (T.unpack $ formatClassNameT msgName) ++ ".java"
113113

114114
LT.writeFile fileName $ templ configFilePath [lt|
115115
package #{configPackage};
116116

117-
#{hashMapImport}
118-
#{arrayListImport}
117+
#{mapImport}
118+
#{listImport}
119119
import org.msgpack.MessagePack;
120120
import org.msgpack.annotation.Message;
121121

@@ -190,18 +190,18 @@ genException _ _ _ = return ()
190190
genClient :: [(T.Text, Type)] -> Config -> Decl -> IO()
191191
genClient alias Config {..} MPService {..} = do
192192
let resolvedServiceMethods = map (resolveMethodAlias alias) serviceMethods
193-
hashMapImport | not $ null [() | TMap _ _ <- map methodRetType resolvedServiceMethods ] = [lt|import java.util.HashMap;|]
194-
| otherwise = ""
195-
arrayListImport | not $ null [() | TList _ <- map methodRetType resolvedServiceMethods] = [lt|import java.util.ArrayList;|]
196-
| otherwise = ""
193+
mapImport | not $ null [() | TMap _ _ <- map methodRetType resolvedServiceMethods ] = [lt|import java.util.Map;|]
194+
| otherwise = ""
195+
listImport | not $ null [() | TList _ <- map methodRetType resolvedServiceMethods] = [lt|import java.util.List;|]
196+
| otherwise = ""
197197
dirName = joinPath $ map LT.unpack $ LT.split (== '.') $ LT.pack configPackage
198198
fileName = dirName ++ "/" ++ (T.unpack className) ++ ".java"
199199

200200
LT.writeFile fileName $ templ configFilePath [lt|
201201
package #{configPackage};
202202

203-
#{hashMapImport}
204-
#{arrayListImport}
203+
#{mapImport}
204+
#{listImport}
205205
import org.msgpack.rpc.Client;
206206
import org.msgpack.rpc.loop.EventLoop;
207207

@@ -312,9 +312,9 @@ genType TRaw =
312312
genType TString =
313313
[lt|String|]
314314
genType (TList typ) =
315-
[lt|ArrayList<#{genWrapperType typ} >|]
315+
[lt|List<#{genWrapperType typ} >|]
316316
genType (TMap typ1 typ2) =
317-
[lt|HashMap<#{genType typ1}, #{genType typ2} >|]
317+
[lt|Map<#{genType typ1}, #{genType typ2} >|]
318318
genType (TUserDef className params) =
319319
[lt|#{formatClassNameT className} #{associateBracket $ map genType params}|]
320320
genType (TTuple ts) =
@@ -364,9 +364,9 @@ genWrapperType TRaw =
364364
genWrapperType TString =
365365
[lt|String|]
366366
genWrapperType (TList typ) =
367-
[lt|ArrayList<#{genWrapperType typ} >|]
367+
[lt|List<#{genWrapperType typ} >|]
368368
genWrapperType (TMap typ1 typ2) =
369-
[lt|HashMap<#{genWrapperType typ1}, #{genWrapperType typ2} >|]
369+
[lt|Map<#{genWrapperType typ1}, #{genWrapperType typ2} >|]
370370
genWrapperType (TUserDef className params) =
371371
[lt|#{formatClassNameT className} #{associateBracket $ map genWrapperType params}|]
372372
genWrapperType (TTuple ts) =

0 commit comments

Comments
 (0)