@Test public void renameIfDuplicatedToConstructorArgNames_A$String$List$List_notDuplicated() throws Exception { ClassMetaExtractor target = new ClassMetaExtractor(config); String argName = "name"; List<String> constructorArgs = new ArrayList<String>(); constructorArgs.add("category"); List<String> methodArgs = new ArrayList<String>(); String actual = target.renameIfDuplicatedToConstructorArgNames(argName, constructorArgs, methodArgs); String expected = "name"; assertEquals(expected, actual); }
String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; }
ClassMetaExtractor { String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; } }
ClassMetaExtractor { String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; } ClassMetaExtractor(Configuration config); }
ClassMetaExtractor { String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; } ClassMetaExtractor(Configuration config); ClassMeta extract(String sourceCodeString); }
ClassMetaExtractor { String renameIfDuplicatedToConstructorArgNames(String argName, List<String> constructorArgs, List<String> methodArgs) { if (argName == null) { return null; } if (isDuplicatedVariableName(argName)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } for (String consArg : constructorArgs) { if (argName.equals(consArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } for (String methodArg : methodArgs) { if (argName.equals(methodArg)) { return renameIfDuplicatedToConstructorArgNames(argName + "_", constructorArgs, methodArgs); } } return argName; } ClassMetaExtractor(Configuration config); ClassMeta extract(String sourceCodeString);  }