diff --git a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java index 1b9703c..5300c55 100644 --- a/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java +++ b/src/org/ntlab/pushPullRefactoring/PushPullProcessor.java @@ -666,7 +666,17 @@ } public String generatePutMethod(Type updatedValueType, Type[] paramTypes, String[] srcNames) { - var args = "@FormParam(\"" + srcNames[0] + "\") String " + srcNames[0] + "_json"; + String paramType = "String"; + + if (paramTypes[0] instanceof ParameterizedType) { + //�]�����̌^�����X�g�������ꍇ, PUT���\�b�h���󂯂Ƃ�p�����[�^�[�̌^��List�ɂ��� + var ptype = (ParameterizedType) paramTypes[0]; + if (ptype.getType().toString().equals("List")) { + paramType = "List"; + } + } + + var args = "@FormParam(\"" + srcNames[0] + "\") "+paramType+" " + srcNames[0] + "_json"; String srcs = Arrays.stream(srcNames).map(x -> "\"" + x + "\"").collect(Collectors.joining(", ")); String result = "@PUT" + System.getProperty("line.separator") + "@Message({" + srcs + "})" + System.getProperty("line.separator") + "public void update" + "(" + args @@ -674,16 +684,40 @@ // �^�錾 for (int i = 0; i < paramTypes.length; i++) { - - result += paramTypes[i].toString() + " " + srcNames[i] + ";" + System.getProperty("line.separator"); - + String initializer = ""; + if (paramTypes[i] instanceof ParameterizedType) { + var ptype = (ParameterizedType) paramTypes[i]; + if (ptype.getType().toString().equals("List")) { + initializer = " = new ArrayList<>()"; + } + } + result += paramTypes[i].toString() + " " + srcNames[i] + initializer + ";" + System.getProperty("line.separator"); + } for (int i = 0; i < paramTypes.length; i++) { result += "{" + System.getProperty("line.separator") + "\t"; if (paramTypes[i] instanceof ParameterizedType) { var ptype = (ParameterizedType) paramTypes[i]; if (ptype.getType().toString().equals("List")) { - + var argType = (Type)ptype.typeArguments().get(0); + String initializer = ""; + if(argType instanceof ParameterizedType) { + if (((ParameterizedType)argType).getType().toString().equals("Map.Entry")) { + initializer = " new ObjectMapper().readValue(str, HashMap.class);"; + } + //((ParameterizedType)argType).getType(); + }else { + if(argType.toString().equals("Integer")) { + initializer = " Integer.parseInt(str);"; + } + } + result += argType.toString() +" i =" + initializer; + result += "for(String str: "+srcNames[i]+"_json ){ " + System.getProperty("line.separator"); + result += srcNames[i].toString()+".add("; + // String value, String tmpValue, Type type + result += geterateParameterizedTypeStatements("i", "i", argType); + result += ");" + System.getProperty("line.separator"); + result += "}" + System.getProperty("line.separator"); } if (ptype.getType().toString().equals("Map.Entry")) { result += convertType(ptype) + " i = new ObjectMapper().readValue(" + srcNames[i]