@Test public void trimGenericsIfNested_A$String_StringIsNull() throws Exception { String returnTypeDef = null; String actual = MethodMetaExtractor.trimGenericsIfNested(returnTypeDef); String expected = null; assertThat(actual, is(equalTo(expected))); }
static String trimGenericsIfNested(String returnTypeDef) { if (returnTypeDef == null) { return null; } boolean isInsideOfGeneric = false; boolean hasNestedGenerics = false; int len = returnTypeDef.length(); for (int i = 0; i < len; i++) { char c = returnTypeDef.charAt(i); if (isInsideOfGeneric) { if (c == '<') { hasNestedGenerics = true; break; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } } if (hasNestedGenerics) { return returnTypeDef.replaceFirst(RegExp.Generics, StringValue.Empty).replaceAll("<", StringValue.Empty) .replaceAll(">", StringValue.Empty); } return returnTypeDef; }
MethodMetaExtractor { static String trimGenericsIfNested(String returnTypeDef) { if (returnTypeDef == null) { return null; } boolean isInsideOfGeneric = false; boolean hasNestedGenerics = false; int len = returnTypeDef.length(); for (int i = 0; i < len; i++) { char c = returnTypeDef.charAt(i); if (isInsideOfGeneric) { if (c == '<') { hasNestedGenerics = true; break; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } } if (hasNestedGenerics) { return returnTypeDef.replaceFirst(RegExp.Generics, StringValue.Empty).replaceAll("<", StringValue.Empty) .replaceAll(">", StringValue.Empty); } return returnTypeDef; } }
MethodMetaExtractor { static String trimGenericsIfNested(String returnTypeDef) { if (returnTypeDef == null) { return null; } boolean isInsideOfGeneric = false; boolean hasNestedGenerics = false; int len = returnTypeDef.length(); for (int i = 0; i < len; i++) { char c = returnTypeDef.charAt(i); if (isInsideOfGeneric) { if (c == '<') { hasNestedGenerics = true; break; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } } if (hasNestedGenerics) { return returnTypeDef.replaceFirst(RegExp.Generics, StringValue.Empty).replaceAll("<", StringValue.Empty) .replaceAll(">", StringValue.Empty); } return returnTypeDef; } MethodMetaExtractor(Configuration config); }
MethodMetaExtractor { static String trimGenericsIfNested(String returnTypeDef) { if (returnTypeDef == null) { return null; } boolean isInsideOfGeneric = false; boolean hasNestedGenerics = false; int len = returnTypeDef.length(); for (int i = 0; i < len; i++) { char c = returnTypeDef.charAt(i); if (isInsideOfGeneric) { if (c == '<') { hasNestedGenerics = true; break; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } } if (hasNestedGenerics) { return returnTypeDef.replaceFirst(RegExp.Generics, StringValue.Empty).replaceAll("<", StringValue.Empty) .replaceAll(">", StringValue.Empty); } return returnTypeDef; } MethodMetaExtractor(Configuration config); MethodMetaExtractor initialize(String sourceCodeString); MethodMetaExtractor initialize(ClassMeta classMeta); MethodMetaExtractor initialize(ClassMeta classMeta, String sourceCodeString); List<MethodMeta> extract(String sourceCodeString); }
MethodMetaExtractor { static String trimGenericsIfNested(String returnTypeDef) { if (returnTypeDef == null) { return null; } boolean isInsideOfGeneric = false; boolean hasNestedGenerics = false; int len = returnTypeDef.length(); for (int i = 0; i < len; i++) { char c = returnTypeDef.charAt(i); if (isInsideOfGeneric) { if (c == '<') { hasNestedGenerics = true; break; } if (c == '>') { isInsideOfGeneric = false; } } else { if (c == '<') { isInsideOfGeneric = true; } if (c == '>') { isInsideOfGeneric = false; } } } if (hasNestedGenerics) { return returnTypeDef.replaceFirst(RegExp.Generics, StringValue.Empty).replaceAll("<", StringValue.Empty) .replaceAll(">", StringValue.Empty); } return returnTypeDef; } MethodMetaExtractor(Configuration config); MethodMetaExtractor initialize(String sourceCodeString); MethodMetaExtractor initialize(ClassMeta classMeta); MethodMetaExtractor initialize(ClassMeta classMeta, String sourceCodeString); List<MethodMeta> extract(String sourceCodeString);  }