@Test public void getArgListFromArgsDefAreaString_A$String() throws Exception { String argsDefAreaString = "String str, List<String> list, Map<Object, Object> map, Object obj, Map<String, List<String>> listMap, List<Map<String,String>> mapList, List<Map<Map<String,Object>,List<String>>> deepNest) {"; List<String> actual = ArgExtractorHelper.getArgListFromArgsDefAreaString(argsDefAreaString); assertEquals("String str", actual.get(0)); assertEquals("List<String> list", actual.get(1)); assertEquals("Map<Object,Object> map", actual.get(2)); assertEquals("Object obj", actual.get(3)); assertEquals("Map listMap", actual.get(4)); assertEquals("List mapList", actual.get(5)); assertEquals("List deepNest", actual.get(6)); }
static List<String> getArgListFromArgsDefAreaString(String argsDefAreaString) { Assertion.on("argsDefAreaString").mustNotBeNull(argsDefAreaString); StringBuilder tmp = new StringBuilder(); boolean isInsideOfGeneric = false; boolean isInsideOfNestedGeneric = false; int depthOfNestedGenerics = 0; int len = argsDefAreaString.length(); for (int i = 0; i < len; i++) { char c = argsDefAreaString.charAt(i); if (isInsideOfNestedGeneric) { if (c == '<') { depthOfNestedGenerics++; } if (c == '>') { if (depthOfNestedGenerics == 1) { depthOfNestedGenerics = 0; tmp.append(NESTED_GENERICS_MARK); isInsideOfNestedGeneric = false; } else { depthOfNestedGenerics--; } } continue; } else if (isInsideOfGeneric) { if (c == '<') { isInsideOfNestedGeneric = true; depthOfNestedGenerics = 1; continue; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } tmp.append(c); } argsDefAreaString = tmp.toString(); String[] commaSplittedArray = argsDefAreaString.split(StringValue.Comma); int commaSplittedArrayLength = commaSplittedArray.length; List<String> args = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < commaSplittedArrayLength; i++) { String eachArea = commaSplittedArray[i].trim(); eachArea = eachArea.replaceFirst("\\)\\s*.*\\s*\\{\\s*", StringValue.Empty); if (eachArea.matches(".+?<.+?>.+")) { eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); continue; } if (eachArea.matches(".+?<.+")) { buf.append(eachArea); continue; } if (eachArea.matches(".+?>.+")) { String result = buf.toString() + StringValue.Comma + eachArea; result = trimGenericsAreaIfNestedGenericsExists(result); args.add(result); buf = new StringBuilder(); continue; } if (!buf.toString().equals(StringValue.Empty)) { buf.append(StringValue.Comma); buf.append(eachArea); continue; } eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); } return args; }
ArgExtractorHelper { static List<String> getArgListFromArgsDefAreaString(String argsDefAreaString) { Assertion.on("argsDefAreaString").mustNotBeNull(argsDefAreaString); StringBuilder tmp = new StringBuilder(); boolean isInsideOfGeneric = false; boolean isInsideOfNestedGeneric = false; int depthOfNestedGenerics = 0; int len = argsDefAreaString.length(); for (int i = 0; i < len; i++) { char c = argsDefAreaString.charAt(i); if (isInsideOfNestedGeneric) { if (c == '<') { depthOfNestedGenerics++; } if (c == '>') { if (depthOfNestedGenerics == 1) { depthOfNestedGenerics = 0; tmp.append(NESTED_GENERICS_MARK); isInsideOfNestedGeneric = false; } else { depthOfNestedGenerics--; } } continue; } else if (isInsideOfGeneric) { if (c == '<') { isInsideOfNestedGeneric = true; depthOfNestedGenerics = 1; continue; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } tmp.append(c); } argsDefAreaString = tmp.toString(); String[] commaSplittedArray = argsDefAreaString.split(StringValue.Comma); int commaSplittedArrayLength = commaSplittedArray.length; List<String> args = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < commaSplittedArrayLength; i++) { String eachArea = commaSplittedArray[i].trim(); eachArea = eachArea.replaceFirst("\\)\\s*.*\\s*\\{\\s*", StringValue.Empty); if (eachArea.matches(".+?<.+?>.+")) { eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); continue; } if (eachArea.matches(".+?<.+")) { buf.append(eachArea); continue; } if (eachArea.matches(".+?>.+")) { String result = buf.toString() + StringValue.Comma + eachArea; result = trimGenericsAreaIfNestedGenericsExists(result); args.add(result); buf = new StringBuilder(); continue; } if (!buf.toString().equals(StringValue.Empty)) { buf.append(StringValue.Comma); buf.append(eachArea); continue; } eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); } return args; } }
ArgExtractorHelper { static List<String> getArgListFromArgsDefAreaString(String argsDefAreaString) { Assertion.on("argsDefAreaString").mustNotBeNull(argsDefAreaString); StringBuilder tmp = new StringBuilder(); boolean isInsideOfGeneric = false; boolean isInsideOfNestedGeneric = false; int depthOfNestedGenerics = 0; int len = argsDefAreaString.length(); for (int i = 0; i < len; i++) { char c = argsDefAreaString.charAt(i); if (isInsideOfNestedGeneric) { if (c == '<') { depthOfNestedGenerics++; } if (c == '>') { if (depthOfNestedGenerics == 1) { depthOfNestedGenerics = 0; tmp.append(NESTED_GENERICS_MARK); isInsideOfNestedGeneric = false; } else { depthOfNestedGenerics--; } } continue; } else if (isInsideOfGeneric) { if (c == '<') { isInsideOfNestedGeneric = true; depthOfNestedGenerics = 1; continue; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } tmp.append(c); } argsDefAreaString = tmp.toString(); String[] commaSplittedArray = argsDefAreaString.split(StringValue.Comma); int commaSplittedArrayLength = commaSplittedArray.length; List<String> args = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < commaSplittedArrayLength; i++) { String eachArea = commaSplittedArray[i].trim(); eachArea = eachArea.replaceFirst("\\)\\s*.*\\s*\\{\\s*", StringValue.Empty); if (eachArea.matches(".+?<.+?>.+")) { eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); continue; } if (eachArea.matches(".+?<.+")) { buf.append(eachArea); continue; } if (eachArea.matches(".+?>.+")) { String result = buf.toString() + StringValue.Comma + eachArea; result = trimGenericsAreaIfNestedGenericsExists(result); args.add(result); buf = new StringBuilder(); continue; } if (!buf.toString().equals(StringValue.Empty)) { buf.append(StringValue.Comma); buf.append(eachArea); continue; } eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); } return args; } private  ArgExtractorHelper(); }
ArgExtractorHelper { static List<String> getArgListFromArgsDefAreaString(String argsDefAreaString) { Assertion.on("argsDefAreaString").mustNotBeNull(argsDefAreaString); StringBuilder tmp = new StringBuilder(); boolean isInsideOfGeneric = false; boolean isInsideOfNestedGeneric = false; int depthOfNestedGenerics = 0; int len = argsDefAreaString.length(); for (int i = 0; i < len; i++) { char c = argsDefAreaString.charAt(i); if (isInsideOfNestedGeneric) { if (c == '<') { depthOfNestedGenerics++; } if (c == '>') { if (depthOfNestedGenerics == 1) { depthOfNestedGenerics = 0; tmp.append(NESTED_GENERICS_MARK); isInsideOfNestedGeneric = false; } else { depthOfNestedGenerics--; } } continue; } else if (isInsideOfGeneric) { if (c == '<') { isInsideOfNestedGeneric = true; depthOfNestedGenerics = 1; continue; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } tmp.append(c); } argsDefAreaString = tmp.toString(); String[] commaSplittedArray = argsDefAreaString.split(StringValue.Comma); int commaSplittedArrayLength = commaSplittedArray.length; List<String> args = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < commaSplittedArrayLength; i++) { String eachArea = commaSplittedArray[i].trim(); eachArea = eachArea.replaceFirst("\\)\\s*.*\\s*\\{\\s*", StringValue.Empty); if (eachArea.matches(".+?<.+?>.+")) { eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); continue; } if (eachArea.matches(".+?<.+")) { buf.append(eachArea); continue; } if (eachArea.matches(".+?>.+")) { String result = buf.toString() + StringValue.Comma + eachArea; result = trimGenericsAreaIfNestedGenericsExists(result); args.add(result); buf = new StringBuilder(); continue; } if (!buf.toString().equals(StringValue.Empty)) { buf.append(StringValue.Comma); buf.append(eachArea); continue; } eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); } return args; } private  ArgExtractorHelper();  }
ArgExtractorHelper { static List<String> getArgListFromArgsDefAreaString(String argsDefAreaString) { Assertion.on("argsDefAreaString").mustNotBeNull(argsDefAreaString); StringBuilder tmp = new StringBuilder(); boolean isInsideOfGeneric = false; boolean isInsideOfNestedGeneric = false; int depthOfNestedGenerics = 0; int len = argsDefAreaString.length(); for (int i = 0; i < len; i++) { char c = argsDefAreaString.charAt(i); if (isInsideOfNestedGeneric) { if (c == '<') { depthOfNestedGenerics++; } if (c == '>') { if (depthOfNestedGenerics == 1) { depthOfNestedGenerics = 0; tmp.append(NESTED_GENERICS_MARK); isInsideOfNestedGeneric = false; } else { depthOfNestedGenerics--; } } continue; } else if (isInsideOfGeneric) { if (c == '<') { isInsideOfNestedGeneric = true; depthOfNestedGenerics = 1; continue; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } tmp.append(c); } argsDefAreaString = tmp.toString(); String[] commaSplittedArray = argsDefAreaString.split(StringValue.Comma); int commaSplittedArrayLength = commaSplittedArray.length; List<String> args = new ArrayList<String>(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < commaSplittedArrayLength; i++) { String eachArea = commaSplittedArray[i].trim(); eachArea = eachArea.replaceFirst("\\)\\s*.*\\s*\\{\\s*", StringValue.Empty); if (eachArea.matches(".+?<.+?>.+")) { eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); continue; } if (eachArea.matches(".+?<.+")) { buf.append(eachArea); continue; } if (eachArea.matches(".+?>.+")) { String result = buf.toString() + StringValue.Comma + eachArea; result = trimGenericsAreaIfNestedGenericsExists(result); args.add(result); buf = new StringBuilder(); continue; } if (!buf.toString().equals(StringValue.Empty)) { buf.append(StringValue.Comma); buf.append(eachArea); continue; } eachArea = trimGenericsAreaIfNestedGenericsExists(eachArea); args.add(eachArea); } return args; } private  ArgExtractorHelper();   }